Exemplo n.º 1
0
        public byte[] BeginRead(int station, string type, int strVar, int numberOfElements, string DataBlockName)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                lock (LockObject)
                {
                    string tempStrg     = string.Empty;
                    string buffReceiver = string.Empty;
                    byte[] frame        = ReadBytes(station, type, strVar, numberOfElements);
                    this.SerialAdaper.Write(frame, 0, frame.Length);

                    //   _RequestAndResponseMessage = new RequestAndResponseMessage("Reception", "XGT slave", frame);

                    Thread.Sleep(500);
                    buffReceiver = SerialAdaper.ReadExisting();

                    if (buffReceiver == "null")
                    {
                        return(null);
                    }
                    // _RequestAndResponseMessage = new RequestAndResponseMessage("Transmission", "XGT slave", buffReceiver);
                    tempStrg = buffReceiver.Substring(1, buffReceiver.Length - 2);
                    tempStrg = tempStrg.Remove(0, 9);

                    return(Conversion.HexToBytes(tempStrg));
                }
            }
            catch (TimeoutException ex)
            {
                EventscadaException?.Invoke(this.GetType().Name,
                                            $"Write : {ex.Message} : {ex.Message} : TimeElapsedMilliseconds :={stopwatch.ElapsedTicks} ");

                throw ex;
            }
        }
Exemplo n.º 2
0
        public byte[] BeginRead(Channel ch, Device dv, DataBlock db)
        {
            byte[] frame = _PollingTo(ch, dv, db);
            this.SerialAdaper.Write(frame, 0, frame.Length);

            //   _RequestAndResponseMessage = new RequestAndResponseMessage("Reception", "XGT slave", frame);
            string tempStrg     = string.Empty;
            string buffReceiver = string.Empty;

            Thread.Sleep(DELAY);
            buffReceiver = SerialAdaper.ReadExisting();

            if (buffReceiver == "null")
            {
                return(null);
            }
            //    _RequestAndResponseMessage = new RequestAndResponseMessage("Transmission", "XGT slave", buffReceiver);
            tempStrg = buffReceiver.Substring(1, buffReceiver.Length - 2);
            tempStrg = tempStrg.Remove(0, 9);

            return(Conversion.HexToBytes(tempStrg));
        }