From d538eefe789b73757ca6127cba582e8f369bf049 Mon Sep 17 00:00:00 2001 From: MRIIOT Date: Thu, 16 Nov 2023 12:53:07 -0600 Subject: [PATCH] * pmc and macro expando --- examples/windows/config.machines.yml | 12 ++++++------ fanuc/veneers/Macro.cs | 16 +++++++++++++++- fanuc/veneers/Pmc.cs | 18 +++++++++++++++--- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/examples/windows/config.machines.yml b/examples/windows/config.machines.yml index 1081128..b105792 100644 --- a/examples/windows/config.machines.yml +++ b/examples/windows/config.machines.yml @@ -72,7 +72,7 @@ machines: ## - id: f_sim_mqtt_long ## enabled: enable or disable collection for this machine - enabled: !!bool true + enabled: !!bool false ## type: machine type type: l99.driver.fanuc.FanucMachine, fanuc ## strategy: strategy type @@ -275,7 +275,7 @@ machines: ## mtconnect example ## - id: f_sim_mtc_long - enabled: !!bool false + enabled: !!bool true type: l99.driver.fanuc.FanucMachine, fanuc strategy: l99.driver.fanuc.strategies.FanucMultiStrategy, fanuc handler: l99.driver.fanuc.handlers.FanucOne, fanuc @@ -294,11 +294,11 @@ machines: # 3: [ % ] collectors: - l99.driver.fanuc.collectors.MachineInfo, fanuc - #- l99.driver.fanuc.collectors.Alarms, fanuc - #- l99.driver.fanuc.collectors.Messages, fanuc + - l99.driver.fanuc.collectors.Alarms, fanuc + - l99.driver.fanuc.collectors.Messages, fanuc - l99.driver.fanuc.collectors.StateData, fanuc - #- l99.driver.fanuc.collectors.ToolData, fanuc - #- l99.driver.fanuc.collectors.ProductionData, fanuc + - l99.driver.fanuc.collectors.ToolData, fanuc + - l99.driver.fanuc.collectors.ProductionData, fanuc #- l99.driver.fanuc.collectors.GCodeData, fanuc #- l99.driver.fanuc.collectors.AxisData, fanuc #- l99.driver.fanuc.collectors.SpindleData, fanuc diff --git a/fanuc/veneers/Macro.cs b/fanuc/veneers/Macro.cs index b5f796f..4ca101f 100644 --- a/fanuc/veneers/Macro.cs +++ b/fanuc/veneers/Macro.cs @@ -1,4 +1,5 @@ -using l99.driver.@base; +using System.Dynamic; +using l99.driver.@base; // ReSharper disable once CheckNamespace namespace l99.driver.fanuc.veneers; @@ -14,14 +15,27 @@ protected override async Task AnyAsync(dynamic[] nativeInputs, dynamic[ { if (nativeInputs.All(o => o.success == true)) { + Func toExpando = (item) => + { + dynamic eo = new ExpandoObject(); + eo.address = item.request.cnc_rdmacro.number; + eo.value = item.response.cnc_rdmacro.macro.mcr_val / + (double)Math.Pow(10, item.response.cnc_rdmacro.macro.dec_val); + return eo; + }; + var currentValue = nativeInputs.ToDictionary( item => item.bag["id"], + item => toExpando(item)); + + /* item => new { address = item.request.cnc_rdmacro.number, value = item.response.cnc_rdmacro.macro.mcr_val / (double)Math.Pow(10, item.response.cnc_rdmacro.macro.dec_val) }); + */ await OnDataArrivedAsync(nativeInputs, additionalInputs, currentValue); diff --git a/fanuc/veneers/Pmc.cs b/fanuc/veneers/Pmc.cs index fa2a2be..da73b6c 100644 --- a/fanuc/veneers/Pmc.cs +++ b/fanuc/veneers/Pmc.cs @@ -1,4 +1,5 @@ -using l99.driver.@base; +using System.Dynamic; +using l99.driver.@base; // ReSharper disable once CheckNamespace namespace l99.driver.fanuc.veneers; @@ -14,14 +15,25 @@ protected override async Task AnyAsync(dynamic[] nativeInputs, dynamic[ { if (nativeInputs.All(o => o.success == true)) { + Func toExpando = (item) => + { + dynamic eo = new ExpandoObject(); + eo.address = item.bag["address"]; + eo.type = item.bag["type"]; + eo.value = item.bag["value"]; + return eo; + }; + var currentValue = nativeInputs.ToDictionary( item => item.bag["id"], - item => new + item => toExpando(item)); + + /*item => new dynamic() { address = item.bag["address"], type = item.bag["type"], value = item.bag["value"] - }); + });*/ await OnDataArrivedAsync(nativeInputs, additionalInputs, currentValue);