예제 #1
0
 public void Disconnection()
 {
     try
     {
         SerialAdaper.Close();
     }
     catch (TimeoutException ex)
     {
         EventscadaException?.Invoke(this.GetType().Name, $"Could Not Connect to Server : {ex.Message}");
     }
 }
예제 #2
0
 public void Disconnection()
 {
     try
     {
         SerialAdaper.Close();
     }
     catch (TimeoutException ex)
     {
         EventscadaException?.Invoke(this.GetType().Name, string.Format("Could Not Connect to Server : {0}", this.GetType().Name, ex.Message));
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            SerialPortAdapter port1 = new SerialPortAdapter(3, 9600, Parity.None, 8, StopBits.One);

            port1.Open();
            var owenProtocol = OwenProtocolMaster.Create(port1);

            if (port1.IsOpened != true)
            {
                Console.WriteLine("Ошибка открытия порта COM3: {0}", port1.ToString());
            }
            else
            {
                try
                {
                    var dataFromDevice = owenProtocol.OwenRead(16, AddressLengthType.Bits8, "dev");
                    Console.WriteLine($"Value - {BitConverter.ToString(dataFromDevice)}");
                    Console.ReadLine();
                    port1.Close();
                    try
                    {
                        var converterString = new ConverterAscii(16);
                        var value           = converterString.ConvertBack(dataFromDevice);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        Console.ReadLine();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadLine();
                }
            }
        }
 public void Disconnection()
 {
     SerialAdaper.Close();
 }