public State(String tID, StateRoutine tRoutine, StateErrorHandler tErrorHandler, AutoResetEvent tEvent, State tParent) { m_Event = tEvent; m_Parent = tParent; m_ID = tID; m_ErrorHandler = tErrorHandler; if (null == m_Event) { m_Event = new AutoResetEvent(false); } if (null == m_Parent) { return; } if (null == tID) { return; } else if ("" == tID.Trim()) { return; } else if (null == tRoutine) { return; } m_Routine = tRoutine; m_Status = Status.FSM_IDLE; m_Available = true; }
public Boolean CallFSM(SafeID tID, String tReturnID, params Object[] tArgs) { if (!this.Available) { return(false); } else if (!this.IsActive) { return(false); } lock (m_Locker) { State tTarget = m_FreeStateSet.Find(tID); if (null != tTarget) { if (!tTarget.Available) { return(false); } if (tTarget.IsFSM) { IFSM tFSM = tTarget as IFSM; if (null == tFSM) { return(false); } m_FreeStateSet.Remove(tID); m_ActiveFSMSet.Add(tTarget); tFSM.Reset(); do { miniFSM tminiFSM = tFSM as miniFSM; if (null == tminiFSM) { break; } tminiFSM.m_ReturnStateID = tReturnID; }while (false); tFSM.Start(tArgs); } else { m_FreeStateSet.Remove(tID); m_ActiveStateSet.Add(tTarget); } } } m_StateChanged = true; RefreshState(); return(true); }
//! \brief constructor with data and command ID public ESCommandReadBlock(System.Byte[] Datas, SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_READ; if (null != Datas) { m_Data = (Byte[])Datas.Clone(); } }
//! \brief constructor with data and command ID public ESCommandWriteWord(UInt16 hwData, SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_WORD_WRITE; m_Data = new Byte[2]; m_Data[0] = (Byte)(hwData & 0x00FF); m_Data[1] = (Byte)(hwData >> 8); }
public SerialPort.TelegraphCOMAdapter Create(SafeID tID, params Object[] tArgs) { SerialPort.TelegraphCOMAdapter tAdapter = new SerialPort.TelegraphCOMAdapter(tID); if (null != tAdapter) { tAdapter.Name = "Serial Port"; } return(tAdapter); }
private void Initialize() { if (null == m_EndPoint) { return; } m_ID = m_EndPoint.ToString(); m_Available = true; }
public USB.HID.TelegraphHIDAdapter Create(SafeID tID, params Object[] tArgs) { USB.HID.TelegraphHIDAdapter tAdapter = new ESnail.Device.Adapters.USB.HID.TelegraphHIDAdapter(tID); if (null != tAdapter) { tAdapter.Name = "AT SB200/BM300"; } return(tAdapter); }
//! \brief construcotr with data and command ID public ESCommandWriteBlock(Byte[] Datas, SafeID ID) : base(ID) { if (null != Datas) { m_Data = (Byte[])Datas.Clone(); } m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_WRITE; }
//! constructor public Adapter(SafeID tID) { m_LogWriter = new AdapterLog(this); m_ID = tID; if (null != m_WindowsMessageHandler) { m_WindowsMessageHandler.WindowsMessageArrived += new WindowsMessageProcessor(this.DeviceMessageProcess); } WriteLogLine("Adapter Initialized."); }
//! find object public TObject Find(SafeID tID) { lock (((ICollection)m_ObjectList).SyncRoot) { int tIndex = m_ObjectList.Keys.IndexOf(tID); if (tIndex >= 0) { return(m_ObjectList.Values[tIndex]); } } return(default(TObject)); }
//! \brief constructor with word and command ID public ESCommandWriteWord(Byte[] Datas, SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_WORD_WRITE; m_Data = new Byte[2]; if (null != Datas) { if (Datas.Length >= 2) { m_Data[0] = Datas[0]; m_Data[1] = Datas[1]; } } }
//! \brief find component public IBMComponentDesign FindComponent(SafeID tID) { BMComponentItem tItem = m_ComponentSet.Find(tID); if (null == tItem) { return(null); } else if (!tItem.Available) { return(null); } return(tItem.Component); }
public void RemoveBefore(SafeID tID) { Int32 tEndIndex = m_ObjectList.Keys.IndexOf(tID); if (-1 == tEndIndex) { return; } for (Int32 tIndex = 0; tIndex < tEndIndex; tIndex++) { m_ObjectList.RemoveAt(0); } }
//! \brief initialize this object private void Initialize() { InitializeComponent(); if (null == m_Adapter) { m_Adapter = new TelegraphHIDAdapter(m_AdapterID); } else { m_AdapterID = m_Adapter.ID; } //this.Visible = false; }
public void RemoveAfter(SafeID tID) { Int32 tStartIndex = m_ObjectList.Keys.IndexOf(tID) + 1; Int32 tLength = m_ObjectList.Count - tStartIndex; if (0 == tStartIndex) { return; } for (Int32 n = 0; n < tLength; n++) { m_ObjectList.RemoveAt(tStartIndex); } }
public Boolean TriggerFSM(SafeID tID, params Object[] tArgs) { if (!this.Available) { return(false); } else if (!this.IsActive) { return(false); } lock (m_Locker) { State tTarget = m_FreeStateSet.Find(tID); if (null != tTarget) { if (!tTarget.Available) { return(false); } if (tTarget.IsFSM) { IFSM tFSM = tTarget as IFSM; if (null == tFSM) { return(false); } m_FreeStateSet.Remove(tID); m_ActiveFSMSet.Add(tTarget); tFSM.Reset(); tFSM.Start(tArgs); } else { m_FreeStateSet.Remove(tID); m_ActiveStateSet.Add(tTarget); } } } m_StateChanged = true; RefreshState(); return(true); }
//! remove object from set public Boolean Remove(SafeID tID) { #if false TObject tTarget = Find(tID); if (null == tTarget) { return(false); } #endif lock (((ICollection)m_ObjectList).SyncRoot) { m_ObjectList.Remove(tID); //OnNotifyCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,tTarget)); } return(true); }
//! \brief create a adapter public Adapter CreateAdapter(SafeID tID) { if (null == m_Adapter) { return(null); } Adapter tAdapter = m_Adapter.CreateAdapter(tID); if ((null != tAdapter) && (null != Adapter.m_WindowsMessageHandler)) { tAdapter.RegisterDeviceMessageHandler(ref Adapter.m_WindowsMessageHandler, m_Handle); } else { m_UnRegiesterAdapterList.Add(tAdapter); } return(tAdapter); }
public AdapterType(Adapter tAdapter) { if (null == tAdapter) { return; } m_ID = GetTypeID(tAdapter); m_Adapter = tAdapter.CreateAdapter(m_ID); m_Adapter.Name = tAdapter.Name; if (null == m_Adapter) { return; } m_Available = true; }
public AdapterType(Adapter tAdapter, String tAssembly) { if (null == tAdapter) { return; } m_ID = GetTypeID(tAdapter); m_Adapter = tAdapter.CreateAdapter(m_ID); m_Adapter.Name = tAdapter.Name; if (null == m_Adapter) { return; } m_Assembly = System.IO.Path.GetFullPath(tAssembly); m_Available = true; }
public Boolean RemoveState(SafeID tID) { if ((!this.Available) || ((!m_DynamicMode && IsActive))) { return(false); } lock (m_Locker) { State tTarget = m_FreeStateSet.Find(tID); if (null == tTarget) { return(false); } m_FreeStateSet.Remove(tID); } RefreshState(); return(true); }
//! override the base.CopyConstruct public override ESCommand CopyConstruct(System.Byte[] Datas, SafeID ID) { return(new ESCommandReadBlock(Datas, ID)); }
//! constructor public TelegraphHIDAdapter(SafeID tID) : base(tID) { Initiliaze(); }
public override Adapter CreateAdapter(SafeID tID) { return(new TelegraphHIDAdapter(tID)); }
//! override the base.CopyConstruct with command ID public override ESCommand CopyConstruct(Byte[] Datas, SafeID ID) { return(new ESCommandWriteWord(Datas, ID)); }
//! \brief constructor with command ID public ESCommand(SafeID ID) { m_ID = ID; }
//! \brief constructor with command ID public ESCommandReadBlock(SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_READ; }
//! \brief constructor with command ID public ESCommandWriteWord(SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_WORD_WRITE; m_Data = new Byte[2]; }
//! \brief constructor command ID public ESCommandWriteBlock(SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_WRITE; }
//! \brief constructor with command ID public ESCommandReadWord(SafeID ID) : base(ID) { m_CommandType = BM_CMD_TYPE.BM_CMD_TYPE_WORD_READ; m_Data = new Byte[2]; }