예제 #1
0
        public void SwitchControl(仪表选择 control)
        {
            while (Interlocked.Read(ref _NumberForInterLock) == 0)
            {
                Thread.Sleep(5);
            }
            Interlocked.Decrement(ref _NumberForInterLock);

            _CreateUdpClient(Function_Module.GetConfig("本机IP"), Convert.ToInt32(Function_Module.GetConfig("本机端口")));
            byte[] sendBytes = GetSwitchControl(control);
            try
            {
                _UdpClient.Send(sendBytes, sendBytes.Length, _RemoteIP, _RemotePort);
                _UdpClient.Close();
                Interlocked.Increment(ref _NumberForInterLock);
            }
            catch (Exception)
            {
                if (_UdpClient != null)
                {
                    _UdpClient.Close();
                }
                Interlocked.Increment(ref _NumberForInterLock);
            }
        }
예제 #2
0
 public byte[] GetSwitchControl(仪表选择 control)
 {
     byte[] sendBytes = new byte[6] {
         0xff, 0xcc, 0x00, 0x00, 0x00, 0xdd
     };
     sendBytes[2] = (byte)control;
     return(sendBytes);
 }