Exemplo n.º 1
0
 public double?ReadFloatingTag(string tag)
 {
     try
     {
         if (_socket.IsConnected)
         {
             _socket.Disconnect();
         }
         _socket.Connect(_url + tag, AccessMode.Read);
         if (_socket.IsConnected)
         {
             _socket.Update();
             var value = Convert.ToDouble(_socket.Data.Value);
             _socket.Disconnect();
             ClearConnectionError(tag);
             return(value);
         }
         else
         {
             LogConnectionError(tag);
             return(null);
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
 }
Exemplo n.º 2
0
 public void opcWriteConnectSockets() //Method for setting OPC communication to write
 {
     if (dataSocket.IsConnected)
     {
         dataSocket.Disconnect();
     }
     dataSocket.Connect(opcurl, AccessMode.Write);//Connect to OPC
 }
Exemplo n.º 3
0
 public void opcWriteConnectSockets()
 {
     if (dataSocket.IsConnected)
     {
         dataSocket.Disconnect();
     }
     dataSocket.Connect(opcurl, AccessMode.Write);//Connect to OPC
 }
Exemplo n.º 4
0
        public double GetOpcValue()
        {
            _datasocket.Connect(_opcUrl, AccessMode.Read);
            _datasocket.Update();
            var value = Convert.ToDouble(_datasocket.Data.Value);

            _datasocket.Disconnect();

            return(value);
        }
Exemplo n.º 5
0
 public void writeToOPC(double temperature, double u)
 {
     try
     {
         using (DataSocket ds = new DataSocket())
         {
             if (ds.IsConnected)
             {
                 ds.Disconnect();
             }
             if (tName == "Temperature")
             {
                 ds.Data.Value = temperature;
             }
             else if (tName == "Control")
             {
                 ds.Data.Value = u;
             }
             ds.Connect(itURL, AccessMode.Write);
             ds.Update();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 6
0
 public void SetOpcValue(double value)
 {
     _dataSocket.Connect(_opcUrl, AccessMode.Write);
     _dataSocket.Data.Value = value;
     _dataSocket.Update();
     _dataSocket.Disconnect();
 }
Exemplo n.º 7
0
        public void WriteToServer(string tag, double value)
        {
            try
            {
                if (_socket.IsConnected)
                {
                    _socket.Disconnect();
                }
                _socket.Connect(_url + tag, AccessMode.Write);

                _socket.Data.Value = value;
                _socket.Update();
                _socket.Disconnect();
                //_socket.SyncWrite(value, 2000);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 8
0
 public void writeToOPC(bool opcValue)
 {
     using (DataSocket ds = new DataSocket())
     {
         if (ds.IsConnected)
         {
             ds.Disconnect();
         }
         var temp = opcValue;
         ds.Connect(itURL, AccessMode.Write);
         ds.Data.Value = temp;
         ds.Update();
     }
 }
Exemplo n.º 9
0
 public void Disconnect()
 {
     _dataSocket.Disconnect();
 }