예제 #1
0
 public void opcWriteConnectSockets()
 {
     if (dataSocket.IsConnected)
     {
         dataSocket.Disconnect();
     }
     dataSocket.Connect(opcurl, AccessMode.Write);//Connect to OPC
 }
예제 #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
 }
예제 #3
0
        public double GetOpcValue()
        {
            _datasocket.Connect(_opcUrl, AccessMode.Read);
            _datasocket.Update();
            var value = Convert.ToDouble(_datasocket.Data.Value);

            _datasocket.Disconnect();

            return(value);
        }
예제 #4
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());
     }
 }
예제 #5
0
파일: OPC.cs 프로젝트: Zhangnamstyle/SCADA
 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);
     }
 }
예제 #6
0
        public static DataSocket f_建立OPC连接(string URL, AccessMode _Mode)
        {
            DataSocket dataSocket = new DataSocket();

            dataSocket.Connect(URL, _Mode);
            return(dataSocket);
        }
예제 #7
0
파일: Opc.cs 프로젝트: haavardnk/IIA2017
 public void SetOpcValue(double value)
 {
     _dataSocket.Connect(_opcUrl, AccessMode.Write);
     _dataSocket.Data.Value = value;
     _dataSocket.Update();
     _dataSocket.Disconnect();
 }
예제 #8
0
 public void 加载触屏数据()
 {
     U = new DataSocket();
     U.Connect("opc://localhost/National Instruments.NIOPCServers/kaiquan.kaiquan.Anyway.U", AccessMode.WriteAutoUpdate);
     I = new DataSocket();
     I.Connect("opc://localhost/National Instruments.NIOPCServers/kaiquan.kaiquan.Anyway.I", AccessMode.WriteAutoUpdate);
     P = new DataSocket();
     P.Connect("opc://localhost/National Instruments.NIOPCServers/kaiquan.kaiquan.Anyway.P", AccessMode.WriteAutoUpdate);
 }
예제 #9
0
 public void 加载触屏数据()
 {
     U = new DataSocket();
     U.Connect("opc://localhost/National Instruments.NIOPCServers/kaiquan.kaiquan.Anyway.U", AccessMode.WriteAutoUpdate);
     I = new DataSocket();
     I.Connect("opc://localhost/National Instruments.NIOPCServers/kaiquan.kaiquan.Anyway.I", AccessMode.WriteAutoUpdate);
     P = new DataSocket();
     P.Connect("opc://localhost/National Instruments.NIOPCServers/kaiquan.kaiquan.Anyway.P", AccessMode.WriteAutoUpdate);
 }
예제 #10
0
파일: OPC.cs 프로젝트: Zhangnamstyle/SCADA
 public void writeToOPC(bool opcValue)
 {
     using (DataSocket ds = new DataSocket())
     {
         ds.Connect(itURL, AccessMode.Write);
         ds.Data.Value = opcValue;
         ds.Update();
     }
 }
예제 #11
0
        public RDPSessionPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);

            //InitializeComponent();

            if (GlobalConfiguration.isStdOutOff)
            {
                Utils.setStdoutOff();
            }

            if (GlobalConfiguration.isEnableImageStreaming || GlobalConfiguration.isEnableInputDeviceController)
            {
                canvas = new SKCanvasView
                {
                    //VerticalOptions = LayoutOptions.FillAndExpand
                    VerticalOptions   = LayoutOptions.Fill,
                    HorizontalOptions = LayoutOptions.Fill
                };
                canvas.PaintSurface += OnCanvasViewPaintSurface;
                // Skiaを利用する場合、ビットマップデータのバッファはここで用意してしまう
                skiaBufStreams = new MemoryStream[2];
                skiaBufStreams.SetValue(new MemoryStream(), 0);
                skiaBufStreams.SetValue(new MemoryStream(), 1);
            }

            Title   = "RDPSession";
            layout  = new AbsoluteLayout();
            Content = layout;

            socket = new DataSocket(NetworkTypes.Client);

            if (GlobalConfiguration.isEnableSoundStreaming && !GlobalConfiguration.isClientRunWithoutConn)
            {
                connectToSoundServer();                                                                                            // start recieve sound data which playing on remote PC
            }
            if (GlobalConfiguration.isEnableInputDeviceController)
            {
                setupInputManager();
            }

            if ((GlobalConfiguration.isEnableImageStreaming || GlobalConfiguration.isEnableInputDeviceController) && !GlobalConfiguration.isClientRunWithoutConn)
            {
                socket.ConnectedCallback         += Socket_ConnectedCallback;
                socket.DisconnectedCallback      += Socket_DisconnectedCallback;
                socket.ConnectionFailedCallback  += Socket_ConnectionFailedCallback;
                socket.DataRecievedCallback      += Socket_DataRecievedCallback;
                socket.StartDataRecievedCallback += Socket_StartDataRecievedCallback;
                socket.EndDataRecievedCallback   += Socket_EndDataRecievedCallback;
                socket.Connect(IPAddress.Parse(GlobalConfiguration.ServerAddress), GlobalConfiguration.ImageAndInputServerPort);
            }
        }
예제 #12
0
        public bool Connect(string opcUrl)
        {
            if (_dataSocket.IsConnected)
            {
                this.Disconnect();
                return(_dataSocket.IsConnected);
            }

            _dataSocket.Connect(opcUrl, AccessMode.Read);
            _dataSocket.Update();

            return(_dataSocket.IsConnected);
        }
예제 #13
0
파일: OPC.cs 프로젝트: Zhangnamstyle/SCADA
        public bool readFromOPC()
        {
            bool OPCvalue = false;

            using (DataSocket ds = new DataSocket())
            {
                ds.Connect(itURL, AccessMode.Read);
                ds.Update();
                OPCvalue = Convert.ToBoolean(ds.Data.Value);
            }

            return(OPCvalue);
        }
예제 #14
0
파일: OPC.cs 프로젝트: Zhangnamstyle/SCADA
 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();
     }
 }
예제 #15
0
        public bool Setup()
        {
            if (Config.Address == 0)
            {
                throw new InvalidOperationException("Configuration address not configured");
            }
            if (Config.Port == 0)
            {
                throw new InvalidOperationException("Configuration port not configured");
            }

            try
            {
                //check if the camera is active
                DataSocket.Connect(new IPEndPoint(Config.Address, Config.Port));
                DataSocket.Send(Encoding.ASCII.GetBytes((int)CameraRequest.Alive + Constants.EndOfMessage));

                //grab data
                byte[] recieveData = new byte[1000];
                int    bytesRec    = DataSocket.Receive(recieveData);
                //if there was no data the camera must have been off
                if (bytesRec <= 0)
                {
                    Console.WriteLine("Camera not active, No data recieved");
                    DataSocket.Shutdown(SocketShutdown.Both);
                    DataSocket.Close();
                    return(false);
                }
                else
                {
                    Console.WriteLine("Camera response = {0}",
                                      Encoding.ASCII.GetString(recieveData, 0, bytesRec - Constants.EndOfMessage.Length));
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("Socket Exception : {0}", e);

                if (!DataSocket.Connected)
                {
                    return(false);
                }

                DataSocket.Shutdown(SocketShutdown.Both);
                DataSocket.Close();
                return(false);
            }

            return(true);
        }
예제 #16
0
파일: OPC.cs 프로젝트: Zhangnamstyle/SCADA
        public double readFromOPC()
        {
            double OPCvalue = 0;

            try
            {
                using (DataSocket ds = new DataSocket())
                {
                    ds.Connect(itURL, AccessMode.Read);
                    ds.Update();
                    OPCvalue   = Convert.ToDouble(ds.Data.Value);
                    opcQuality = ds.Data.Attributes["Quality"].Value.ToString();
                }
            }
            catch (Exception ex)
            {
                OPCvalue = 998;
            }
            return(OPCvalue);
        }
예제 #17
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;
            }
        }
예제 #18
0
        private void connectButton_Click(object sender, RoutedEventArgs e)
        {
            // handle pause
            if (uiState == UIStates.Streaming || uiState == UIStates.Paused)
            {
                var state = uiState;
                SetConnectionUIStates(state == UIStates.Streaming ? UIStates.Paused : UIStates.Streaming);

                var metaData = new MetaData()
                {
                    type     = state == UIStates.Streaming ? MetaDataTypes.PauseCapture : MetaDataTypes.ResumeCapture,
                    dataSize = -1
                };

                socket.SendMetaData(metaData);
                return;
            }

            // handle connect
            SetConnectionUIStates(UIStates.Streaming);

            NetworkHost host = null;

            if (settingsOverlay.settings.customSocketAddress.enabled)
            {
                if (string.IsNullOrEmpty(serverTextBox.Text))
                {
                                        #if DEBUG
                    connectedToLocalPC = true;
                    host = new NetworkHost("localhost")
                    {
                        endpoints = new List <IPEndPoint>()
                        {
                            new IPEndPoint(IPAddress.Loopback, 8888)
                        }
                    };
                                        #else
                    return;
                                        #endif
                }
                else
                {
                    host = new NetworkHost(serverTextBox.Text)
                    {
                        endpoints = new List <IPEndPoint>()
                        {
                            new IPEndPoint(IPAddress.Loopback, 8888)
                        }
                    };

                    connectedToLocalPC = host.name == Dns.GetHostName() || host.name.ToLower() == "localhost" || host.name == "127.0.0.1";
                }
            }
            else
            {
                if (serverComboBox.SelectedIndex == -1)
                {
                                        #if DEBUG
                    connectedToLocalPC = true;
                    host = new NetworkHost("localhost")
                    {
                        endpoints = new List <IPEndPoint>()
                        {
                            new IPEndPoint(IPAddress.Loopback, 8888)
                        }
                    };
                                        #else
                    return;
                                        #endif
                }
                else
                {
                    host = (NetworkHost)serverComboBox.SelectedValue;
                    connectedToLocalPC = host.name == Dns.GetHostName();
                }
            }

            socket = new DataSocket(NetworkTypes.Client);
            socket.ConnectedCallback         += Socket_ConnectedCallback;
            socket.DisconnectedCallback      += Socket_DisconnectedCallback;
            socket.ConnectionFailedCallback  += Socket_ConnectionFailedCallback;
            socket.DataRecievedCallback      += Socket_DataRecievedCallback;
            socket.StartDataRecievedCallback += Socket_StartDataRecievedCallback;
            socket.EndDataRecievedCallback   += Socket_EndDataRecievedCallback;
            socket.Connect(host.endpoints[0]);
        }
예제 #19
0
 public static DataSocket f_建立OPC连接(string URL, AccessMode _Mode)
 {
     DataSocket dataSocket = new DataSocket();
     dataSocket.Connect(URL, _Mode);
     return dataSocket;
 }