Esempio n. 1
0
        public override int HalConnect()
        {
            /**  real
             * try
             * {
             *  var connected = false;
             *  if (_ldd == null)
             *  {
             *      lock (getLddObject)
             *      {
             *          if (_ldd == null)
             *          {
             *              _ldd = new MvGudengLoadPortLdd(DeviceIP, DevicePort, DeviceIndex);
             *              this.BindEvents();
             *              connected = _ldd.StartListenServerThread();
             *
             *              if (!connected)
             *              {
             *                  _ldd = null;
             *                  IsConnected = false;
             *              }
             #region 2020/10/23 13:58 King [C]
             *              else
             *              {
             *                  IsConnected = true;
             *              }
             #endregion
             *          }
             *      }
             *  }
             *  return connected ? 1 : 0;
             * }
             * catch (Exception ex)
             * {
             *  _ldd = null;
             *  IsConnected = false;
             *  return 0;
             * }*/

            #region Fake

            if (_ldd == null)
            {
                lock (getLddObject)
                {
                    if (_ldd == null)
                    {
                        _ldd = new MvGudengLoadPortLdd(DeviceIP, DevicePort, DeviceId);
                        this.BindEvents();
                        IsConnected = true;

                        Debug.WriteLine("[Fake]  Loadport HalConnect(); DeviceIP=" + DeviceIP + ", DevicePort=" + DevicePort + ", DeviceIndex=" + DeviceId);
                    }
                }
            }
            return(1);

            #endregion
        }
Esempio n. 2
0
 /// <summary>如果 Loadport 的TCP Server 忽然斷線</summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnHostLostTcpServer(object sender, EventArgs e)
 {
     IsConnected = false;
     _ldd        = null;
     if (OnHostLostLoadPortConnectionHandler != null)
     {
         OnHostLostLoadPortConnectionHandler.Invoke(this, e);
     }
 }
Esempio n. 3
0
        public UtHalLoadPort()
        {
            LoadPort1 = ldd.CreateLoadPort("192.168.0.20", 1024, 1);
            // LoadPort1 = ldd.CreateLoadPort("127.0.0.1", 1024, 1);
            LoadPort2 = ldd.CreateLoadPort("192.168.0.21", 1024, 2);
            BindEventHandler();

            LoadPort1.StartListenServerThread();
            LoadPort2.StartListenServerThread();
        }
Esempio n. 4
0
 public override int HalClose()
 {
     try
     {
         _ldd = null;
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }