public void RaiseDeviceManagerNotification(string command, string info,string source) { var newDMArgs = new StateMachineEventArgs(command, "Device Manager Event" + info, source, "", StateMachineEventType.Notification); if (DeviceManagerNotification != null) { DeviceManagerNotification(this, newDMArgs); } }
public void RaiseDeviceManagerEvent(string p, string name) { var newDMArgs= new StateMachineEventArgs(name,"Device Manager Event"+ name,"Device Manager","",StateMachineEventType.System); if (DeviceManagerEvent != null) { DeviceManagerEvent(this, newDMArgs); } }
private void RaiseEventManagerEvent(string eventName,string eventInfo, StateMachineEventType eventType) { var newArgs=new StateMachineEventArgs(eventName,eventInfo,String.Empty, String.Empty, eventType); if (EventManagerEvent != null) { EventManagerEvent(this, newArgs); } }
public void DeviceCommandHandler(object sender, StateMachineEventArgs args) { if(args.EventType!=StateMachineEventType.Command) return; try { if(!DeviceList.ContainsKey(args.Target))return; var device = DeviceList[args.Target]; var deviceMethod = device.GetType().GetMethod(args.EventName); deviceMethod.Invoke(device, new object[] {}); RaiseDeviceManagerEvent("Device Command",args.Target); } catch (Exception ex) { RaiseDeviceManagerEvent("Device Command error", ex.ToString()); } }
public void SystemEventHandler(object sender, StateMachineEventArgs args) { if (args.EventName == "OnInit" && args.EventType == StateMachineEventType.Command) { foreach (var dev in DeviceList) { try { var initMethod = dev.Value.GetType().GetMethod("OnInit"); initMethod.Invoke(dev.Value, new object[] { }); RaiseDeviceManagerEvent("DeviceManager -Initialization device", dev.Key); } catch (Exception ex ) { RaiseDeviceManagerEvent("DeviceManager -Initialization device exception", dev.Key); } } } if (args.EventType == StateMachineEventType.Command) { if (args.EventName == "OnInit") { return; } DeviceCommandHandler(this,args); } }
public void Log(object sender, StateMachineEventArgs args) { Debug.Print(args.EventName); }