public GetVelocityRegulatorGainCommand(EltraDevice device) : base(device) { Name = "GetVelocityRegulatorGain"; }
public RelayVcs(AgentConnector connector, EltraDevice device) : base(connector, device) { }
private async Task <bool> ExecuteCommand(EltraDevice device, ExecuteCommand executeCommand) { bool result = false; try { if (executeCommand != null && _executeCommandCache.CanExecute(executeCommand)) { var s = MsgLogger.BeginTimeMeasure(); var sourceChannelId = executeCommand.SourceChannelId; var commandName = executeCommand.Command?.Name; var deviceCommand = device.FindCommand(commandName); if (deviceCommand != null) { if (await DeviceControllerAdapter.SetCommandStatus(executeCommand, ExecCommandStatus.Executing)) { try { MsgLogger.WriteDebug($"{GetType().Name} - ExecuteCommand", $"Clone Command '{commandName}'"); var clonedDeviceCommand = deviceCommand.Clone(); if (clonedDeviceCommand != null) { MsgLogger.WriteDebug($"{GetType().Name} - ExecuteCommand", $"Sync Command '{commandName}'"); clonedDeviceCommand.Sync(executeCommand.Command); MsgLogger.WriteDebug($"{GetType().Name} - ExecuteCommand", $"Execute Command '{commandName}', channel '{executeCommand.SourceChannelId}'"); try { var start = MsgLogger.BeginTimeMeasure(); result = clonedDeviceCommand.Execute(executeCommand.SourceChannelId, executeCommand.SourceLoginName); MsgLogger.EndTimeMeasure($"{GetType().Name} - ExecuteCommand", start, $"command '{executeCommand.Command.Name}' executed, result = {result}"); } catch (Exception e) { MsgLogger.Exception($"{GetType().Name} - ExecuteCommand", e); } if (result) { var start = MsgLogger.BeginTimeMeasure(); MsgLogger.WriteDebug($"{GetType().Name} - ExecuteCommand", $"Sync Response Command '{commandName}'"); executeCommand.Command?.Sync(clonedDeviceCommand); MsgLogger.WriteDebug($"{GetType().Name} - ExecuteCommand", $"Push Response for Command '{commandName}'"); executeCommand.SourceChannelId = Channel.Id; executeCommand.TargetChannelId = sourceChannelId; result = await DeviceControllerAdapter.PushCommand(executeCommand, ExecCommandStatus.Executed); if (result) { MsgLogger.WriteDebug($"{GetType().Name} - ExecuteCommand", $"Command '{commandName}' successfully processed!"); } else { MsgLogger.WriteError($"{GetType().Name} - ExecuteCommand", $"Set command '{commandName}' status to exectuted failed!"); } MsgLogger.EndTimeMeasure($"{GetType().Name} - ExecuteCommand", start, $"command '{executeCommand.Command.Name}' state synchronized, result = {result}"); } else { var command = executeCommand.Command; MsgLogger.WriteError($"{GetType().Name} - ExecuteCommand", command != null ? $"Command '{command.Name}' uuid '{executeCommand.CommandId}' execution failed!" : $"Command '?' uuid '{executeCommand.CommandId}' execution failed!"); executeCommand.SourceChannelId = Channel.Id; executeCommand.TargetChannelId = sourceChannelId; await DeviceControllerAdapter.SetCommandStatus(executeCommand, ExecCommandStatus.Failed); } } else { await DeviceControllerAdapter.SetCommandStatus(executeCommand, ExecCommandStatus.Failed); MsgLogger.WriteError($"{GetType().Name} - ExecuteCommand", $"Command '{commandName}' cloning failed!"); } } catch (Exception e) { await DeviceControllerAdapter.SetCommandStatus(executeCommand, ExecCommandStatus.Failed); MsgLogger.Exception($"{GetType().Name} - ExecuteCommand", e); } } else { MsgLogger.WriteError($"{GetType().Name} - ExecuteCommand", $"Set Command '{commandName}' status to executing failed!"); } } else { MsgLogger.WriteError($"{GetType().Name} - ExecuteCommand", $"Command '{commandName}' not found!"); } MsgLogger.EndTimeMeasure($"{GetType().Name} - ExecuteCommand", s, $"command '{executeCommand.Command?.Name}' executed, result = {result}"); } } catch (Exception e) { result = false; MsgLogger.Exception($"{GetType().Name} - ExecuteCommand", e); } return(result); }
public XddParameterBase(EltraDevice device, XmlNode source) : base(device, source) { }
public StructuredParameter(EltraDevice device, XmlNode source) : base(device, source) { }
public SetSensorTypeCommand(EltraDevice device) : base(device) { Name = "SetSensorType"; }
public XddDeviceVersion(EltraDevice device) { _device = device; }
public GetPositionMarkerParameterCommand(EltraDevice device) : base(device) { Name = "GetPositionMarkerParameter"; }
public ActivatePositionCompareCommand(EltraDevice device) : base(device) { Name = "ActivatePositionCompare"; }
/// <summary> /// MasterVcs /// </summary> /// <param name="masterAgent"></param> /// <param name="device"></param> /// <param name="updateInterval"></param> /// <param name="timeout"></param> public MasterVcs(SyncCloudAgent masterAgent, EltraDevice device, uint updateInterval, uint timeout) : base(masterAgent.Url, device.ChannelId, masterAgent.Identity, updateInterval, timeout) { Device = device; }
public XddProfileBody(EltraDevice device) { _device = device; }
public GetPositionRegulatorFeedForwardCommand(EltraDevice device) : base(device) { Name = "GetPositionRegulatorFeedForward"; }
public Epos4ObjectDictionary(EltraDevice device) : base(device) { }
public SetPositionRegulatorGainCommand(EltraDevice device) : base(device) { Name = "SetPositionRegulatorGain"; }
public ShowChannelDataDlgCommand(EltraDevice device) : base(device) { Name = "ShowChannelDataDlg"; }
public GetStepDirectionParameterCommand(EltraDevice device) : base(device) { Name = "GetStepDirectionParameter"; }
public XddApplicationProcess(EltraDevice device, XddDeviceManager deviceManager) { _device = device; _deviceManager = deviceManager; }
public VirtualCommandSet CreateVcs(AgentConnector agent, EltraDevice device) { return(new RelayVcs(agent, device)); }
public SetEcMotorParameterCommand(EltraDevice device) : base(device) { Name = "SetEcMotorParameter"; }
public EnableAnalogCurrentSetpointCommand(EltraDevice device) : base(device) { Name = "EnableAnalogCurrentSetpoint"; }
public GetIpmBufferParameterCommand(EltraDevice device) : base(device) { Name = "GetIpmBufferParameter"; }
public ReadDataBufferCommand(EltraDevice device) : base(device) { Name = "ReadDataBuffer"; }
public StopIpmTrajectoryCommand(EltraDevice device) : base(device) { Name = "StopIpmTrajectory"; }
public GetVersionCommand(EltraDevice device) : base(device) { Name = "GetVersion"; }
public GetFreeIpmBufferSizeCommand(EltraDevice device) : base(device) { Name = "GetFreeIpmBufferSize"; }
public DisableAnalogPositionSetpointCommand(EltraDevice device) : base(device) { Name = "DisableAnalogPositionSetpoint"; }
public GetHomingStateCommand(EltraDevice device) : base(device) { Name = "GetHomingState"; }
public async Task <bool> PlayWithDevice(EltraDevice device) { bool result = false; Console.WriteLine($"device = {device.Name}, node id = {device.NodeId}, version = {device.Version}, serial number = {device.Identification.SerialNumber:X8}"); //0x3000, 0x00 is address of the counter parameter in object dictionary var counterParameter = device.SearchParameter(0x3000, 0x00) as Parameter; var controlWordParameter = device.SearchParameter(0x6040, 0x00) as Parameter; var cp = await device.GetParameter(0x3000, 0x00) as Parameter; if (counterParameter != null && controlWordParameter != null) { const ushort readyFlag = 1; const ushort sleepingFlag = 0; //let's get the current value stored in local object dictionary (can be outdated) controlWordParameter.GetValue(out ushort controlWord); // force parameter update, ok, now we are sure that the value is synchronized with master object dictionary await controlWordParameter.ReadValue(); //control word is defined as UINT16 - RW, let's modify value of this parameter in local object dictionary controlWordParameter.SetValue(readyFlag); //synchronize value with master object dictionary await controlWordParameter.Write(); // this method is reliable, but to keep the local object dictionary up-to-date not quiete effective // (object dictionary can contain more than 100 parameters) // your agent usually, doesn't need the current value information about all parameters // to limit the read requests, you can specify explicite the parameters you are interested in Console.WriteLine($"register parameter 0x{counterParameter.Index:X4}:0x{counterParameter.SubIndex:X2} for updates"); //we would like to be informed each time the parameter is changed counterParameter.ParameterChanged += OnParameterChanged; // to activate this feature, call RegisterUpdate // priority is transfered to the master and is up to master to decide what low, high or medium priority is counterParameter.AutoUpdate(ParameterUpdatePriority.High); //from now on, our local object dictionary will be actualized each time the {counterParameter} is changed by remote party // execute command on the remote master device, // our dummy master has 2 simple methods, start and stop counting // let's start counting and observe how our counter parameter {counterParameter} is changing ... // on the end, we will stop counting, to give our master some peace ... var sampleCommands = new SampleCommands(device); await sampleCommands.PlayWithDeviceCommands(); //we don't need the notifications at this point counterParameter?.StopUpdate(ParameterUpdatePriority.High); //remove events handling counterParameter.ParameterChanged -= OnParameterChanged; //in case our parameter is supporting <backup> flag, we can grab some historic data await PlayWithParameterStatistics(device); //reset control word parameter value controlWordParameter.SetValue(sleepingFlag); result = true; } return(result); }
public async Task <bool> IsDeviceRegistered(EltraDevice device) { var status = await DeviceControllerAdapter.GetDeviceStatus(device); return(status == DeviceStatus.Registered || status == DeviceStatus.Ready); }
public EnableAnalogVelocitySetpointCommand(EltraDevice device) : base(device) { Name = "EnableAnalogVelocitySetpoint"; }