Skip to content

Commit

Permalink
* windows32 0.1 service release
Browse files Browse the repository at this point in the history
  • Loading branch information
MRIIOT committed Feb 16, 2022
1 parent 5041ce9 commit b199d0d
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 128 deletions.
36 changes: 34 additions & 2 deletions fanuc/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
using System.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;
using l99.driver.@base;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.WindowsServices;

namespace l99.driver.fanuc
{
class Program
{
static async Task Main(string[] args)
{
dynamic config = await Bootstrap.Start(args);
System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

var hostBuilder = Host.CreateDefaultBuilder(args);

if (WindowsServiceHelpers.IsWindowsService())
hostBuilder.UseWindowsService();

hostBuilder.ConfigureServices((hostContext, services) =>
{
services.AddSingleton(args);
services.AddHostedService<FanucService>();
})
.Build()
.Run();
}
}

public class FanucService : BackgroundService
{
public FanucService(string[] args)
{
_args = args;
}

private string[] _args;

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
dynamic config = await Bootstrap.Start(_args);
Machines machines = await Machines.CreateMachines(config);
await machines.RunAsync();
await Bootstrap.Stop();
Expand Down
12 changes: 6 additions & 6 deletions fanuc/collectors/Alarms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override async Task InitPathsAsync()

public override async Task CollectForEachPathAsync(short current_path, string[] axis, string[] spindle, dynamic path_marker)
{
var obs_focas_support = strategy.Get($"obs+focas_support+{current_path}");
var obs_focas_support = strategy.GetKeyed($"obs+focas_support");

if (obs_focas_support == null)
{
Expand All @@ -30,31 +30,31 @@ public override async Task CollectForEachPathAsync(short current_path, string[]
_warned = true;
}

await strategy.SetNative($"alarms+{current_path}",
await strategy.SetNativeKeyed($"alarms",
await strategy.Platform.RdAlmMsg2Async(-1, 10));
}
else
{
if(Regex.IsMatch(string.Join("",obs_focas_support),
"30i[A-Z]?|31i[A-Z]?|32i[A-Z]?|0i[D|F]|PMi[A]?"))
{
await strategy.SetNative($"alarms+{current_path}",
await strategy.SetNativeKeyed($"alarms",
await strategy.Platform.RdAlmMsg2Async(-1, 10));
}
else
{
await strategy.SetNative($"alarms+{current_path}",
await strategy.SetNativeKeyed($"alarms",
await strategy.Platform.RdAlmMsgAsync(-1, 10));
}
}

var obs_alarms = await strategy.Peel("alarms",
strategy.Get($"alarms+{current_path}"),
strategy.GetKeyed($"alarms"),
current_path,
axis,
obs_focas_support);

strategy.Set($"obs+alarms+{current_path}",
strategy.SetKeyed($"obs+alarms",
obs_alarms.veneer.LastChangedValue.alarms);
}
}
Expand Down
28 changes: 13 additions & 15 deletions fanuc/collectors/AxisData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ public override async Task InitAxisAndSpindleAsync()

public override async Task CollectForEachPathAsync(short current_path, string[] axis, string[] spindle, dynamic path_marker)
{
await strategy.SetNative($"figures+{current_path}",
await strategy.SetNativeKeyed($"figures",
await strategy.Platform.GetFigureAsync(0, 32));

await strategy.SetNative($"axis_load+{current_path}",
await strategy.SetNativeKeyed($"axis_load",
await strategy.Platform.RdSvMeterAsync());
}

public override async Task CollectForEachAxisAsync(short current_path, short current_axis, string axis_name, dynamic axis_split, dynamic axis_marker)
{
var axis_key = string.Join("/", axis_split);

var obs_focas_support = strategy.Get($"obs+focas_support+{current_path}");
var obs_alarms = strategy.Get($"obs+alarms+{current_path}");

Expand All @@ -52,35 +50,35 @@ public override async Task CollectForEachAxisAsync(short current_path, short cur
// 300 servo error

// 308 byte motor temperature (c)
await strategy.SetNative($"diag_servo_temp+{axis_key}",
await strategy.SetNativeKeyed($"diag_servo_temp",
await strategy.Platform.DiagnossByteAsync(308, current_axis));

// 309 byte coder temperature (c)
await strategy.SetNative($"diag_coder_temp+{axis_key}",
await strategy.SetNativeKeyed($"diag_coder_temp",
await strategy.Platform.DiagnossByteAsync(309, current_axis));

// 4901 dword servo power consumption (watt)
await strategy.SetNative($"diag_power+{axis_key}",
await strategy.SetNativeKeyed($"diag_power",
await strategy.Platform.DiagnossDoubleWordAsync(4901, current_axis));

await strategy.SetNative($"axis_dynamic+{axis_key}",
await strategy.SetNativeKeyed($"axis_dynamic",
await strategy.Platform.RdDynamic2Async(current_axis, 44, 2));

await strategy.Peel("axis",
current_axis,
strategy.Get($"axis_names+{current_path}"),
strategy.Get($"axis_dynamic+{axis_key}"),
strategy.GetKeyed($"axis_dynamic"),
strategy.Get($"figures+{current_path}"),
strategy.Get($"axis_load+{current_path}"),
strategy.Get($"diag_servo_temp+{axis_key}"),
strategy.Get($"diag_coder_temp+{axis_key}"),
strategy.Get($"diag_power+{axis_key}"),
strategy.GetKeyed($"diag_servo_temp"),
strategy.GetKeyed($"diag_coder_temp"),
strategy.GetKeyed($"diag_power"),
obs_focas_support,
obs_alarms,
strategy.Get($"axis_dynamic+last+{axis_key}"));
strategy.GetKeyed($"axis_dynamic+last"));

strategy.Set($"axis_dynamic+last+{axis_key}",
strategy.Get($"axis_dynamic+{axis_key}"));
strategy.SetKeyed($"axis_dynamic+last",
strategy.GetKeyed($"axis_dynamic"));
}
}
}
6 changes: 3 additions & 3 deletions fanuc/collectors/GCodeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public override async Task InitPathsAsync()
public override async Task CollectForEachPathAsync(short current_path, string[] axis, string[] spindle, dynamic path_marker)
{
await strategy.Peel("gcode",
await strategy.SetNative($"blkcount+{current_path}",
await strategy.SetNativeKeyed($"blkcount",
await strategy.Platform.RdBlkCountAsync()),
await strategy.SetNative($"actpt+{current_path}",
await strategy.SetNativeKeyed($"actpt",
await strategy.Platform.RdActPtAsync()),
await strategy.SetNative($"execprog+{current_path}",
await strategy.SetNativeKeyed($"execprog",
await strategy.Platform.RdExecProgAsync(256)));
}
}
Expand Down
16 changes: 11 additions & 5 deletions fanuc/collectors/MachineInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using l99.driver.fanuc.strategies;

namespace l99.driver.fanuc.collectors
Expand All @@ -9,21 +10,26 @@ public MachineInfo(FanucMultiStrategy strategy) : base(strategy)
{

}

public override async Task InitPathsAsync()
{
await strategy.Apply(typeof(fanuc.veneers.SysInfo), "machine");
}

public override async Task CollectForEachPathAsync(short current_path, string[] axis, string[] spindle, dynamic path_marker)
{
await strategy.SetNative($"machine+{current_path}",
if (strategy.HasKeyed($"{this.GetType().Name}"))
return;

await strategy.SetKeyed($"{this.GetType().Name}", true);

await strategy.SetNativeKeyed($"machine",
await strategy.Platform.SysInfoAsync());

var obs_machine = await strategy.Peel($"machine",
strategy.Get($"machine+{current_path}"));
strategy.GetKeyed($"machine"));

strategy.Set($"obs+focas_support+{current_path}",
strategy.SetKeyed($"obs+focas_support",
obs_machine.veneer.LastArrivedValue.focas_support);
}
}
Expand Down
6 changes: 3 additions & 3 deletions fanuc/collectors/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override async Task InitPathsAsync()

public override async Task CollectForEachPathAsync(short current_path, string[] axis, string[] spindle, dynamic path_marker)
{
var obs_focas_support = strategy.Get($"obs+focas_support+{current_path}");
var obs_focas_support = strategy.GetKeyed($"obs+focas_support");

short msg_type = 0;
short msg_length = 6 + 256;
Expand All @@ -41,11 +41,11 @@ public override async Task CollectForEachPathAsync(short current_path, string[]
msg_length = 578;
}

await strategy.SetNative($"messages+{current_path}",
await strategy.SetNativeKeyed($"messages",
await strategy.Platform.RdOpMsgAsync(msg_type, msg_length));

await strategy.Peel("messages",
strategy.Get($"messages+{current_path}"));
strategy.GetKeyed($"messages"));
}

}
Expand Down
18 changes: 9 additions & 9 deletions fanuc/collectors/ProductionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ public override async Task InitPathsAsync()

public override async Task CollectForEachPathAsync(short current_path, string[] axis, string[] spindle, dynamic path_marker)
{
await strategy.SetNative($"program_name+{current_path}",
await strategy.SetNativeKeyed($"program_name",
await strategy.Platform.ExePrgNameAsync());
var o_num = strategy.Get($"program_name+{current_path}")
var o_num = strategy.GetKeyed($"program_name")
.response.cnc_exeprgname.exeprg.o_num;

await strategy.Peel("production",
strategy.Get($"program_name+{current_path}"),
await strategy.SetNative($"prog_dir+{current_path}",
strategy.GetKeyed($"program_name"),
await strategy.SetNativeKeyed($"prog_dir",
await strategy.Platform.RdProgDir3Async(o_num)),
await strategy.SetNative($"pieces_produced+{current_path}",
await strategy.SetNativeKeyed($"pieces_produced",
await strategy.Platform.RdParamDoubleWordNoAxisAsync(6711)),
await strategy.SetNative($"pieces_produced_life+{current_path}",
await strategy.SetNativeKeyed($"pieces_produced_life",
await strategy.Platform.RdParamDoubleWordNoAxisAsync(6712)),
await strategy.SetNative($"pieces_remaining+{current_path}",
await strategy.SetNativeKeyed($"pieces_remaining",
await strategy.Platform.RdParamDoubleWordNoAxisAsync(6713)),
await strategy.SetNative($"cycle_time_min+{current_path}",
await strategy.SetNativeKeyed($"cycle_time_min",
await strategy.Platform.RdParamDoubleWordNoAxisAsync(6758)),
await strategy.SetNative($"cycle_time_ms+{current_path}",
await strategy.SetNativeKeyed($"cycle_time_ms",
await strategy.Platform.RdParamDoubleWordNoAxisAsync(6757)));
}
}
Expand Down
Loading

0 comments on commit b199d0d

Please sign in to comment.