Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void SetNewStationUUID(int iSequence = 0)
        {
            int iSeqLen = iSequence.ToString().Length;

            if (iSeqLen > 8)
            {
                if (UserErrorEvent != null)
                {
                    UserErrorEvent(UUID, new Cerror(Cerror.cErrorCodes.INVALID_STATION_NAME, "Invalid internal ID - Max. Sequence Length = 8."));
                }
                return;
            }

            // 30/03/2015 Falta habilitar ReadDeviceID (también en ControlStackSold01 y 02) y WriteDeviceID cuando se implemente definitivamente en las estaciones
            // 30/05/2016 Se habilita la lectura y grabación de UID de la estación
            clsStationUID stationUUID = new clsStationUID();

            stationUUID.NewGUIDS();
            // write bytes
            m_Frames_02.WriteDeviceUID(stationUUID.StationData);
            m_Frames_02.ReadDeviceUID();
        }