public CUpdateFirmware02(string stationUUID, CStationFrames02_SF frames_02) { m_UUID = stationUUID; m_FramesSF_02 = frames_02; m_FramesSF_02.ClearingFlashFinished += Event_UpdateFirmwareStepFinished; m_FramesSF_02.AddressMemoryFlashFinished += Event_UpdateFirmwareStepFinished; m_FramesSF_02.DataMemoryFlashFinished += Event_UpdateFirmwareStepFinished; m_FramesSF_02.EndProgFinished += Event_UpdateFirmwareStepFinished; }
public string Initialize() { string UUID = ""; //Initialize address communication channel m_ComChannel.AddStack(m_StationNumDevice); //Initialize station frames m_Frames_02 = new CStationFrames02_SF(m_StationData, m_PortData, m_ComChannel, m_StationNumDevice); m_Frames_02.Detected_SubStation += Event_Detected_SubStation; m_Frames_02.ConnectionError += ConnectionError; m_Frames_02.EndedTransaction += AddEndedTransaction; //Initialize UUID if empty m_Frames_02.ReadDeviceUID(); uint transactionID = SetTransaction(); int retriesCheckUUIDInitialized = RETRIES_CHECK_UUID_INITIALIZED; while (retriesCheckUUIDInitialized > 0) { if (QueryEndedTransaction(transactionID)) { if (string.IsNullOrEmpty(m_StationData.Info.UUID)) { SetControlMode(ControlModeConnection.CONTROL); SetNewStationUUID(); SetControlMode(ControlModeConnection.MONITOR); } UUID = m_StationData.Info.UUID; break; } retriesCheckUUIDInitialized--; Thread.Sleep(100); } //If we do not have the UUID the station was not initialized correctly if (!string.IsNullOrEmpty(UUID)) { //Initialize update data process m_ThreadUpdateData = new Thread(new System.Threading.ThreadStart(UpdateDataProcess)); m_ThreadUpdateData.IsBackground = true; m_ThreadUpdateData.Start(); //Check data initialized m_ThreadCheckDataInitialized = new Thread(new System.Threading.ThreadStart(CheckDataInitialized)); m_ThreadCheckDataInitialized.IsBackground = true; m_ThreadCheckDataInitialized.Start(); } return(UUID); }