Esempio n. 1
0
 public Fins(PlcProtocolType protocol, byte network, byte unit, byte node, int timeout,
     int localHostEthIndex, IXCom comm)
     : this(protocol, network, unit, node, comm)
 {
     _timeout = timeout;
     this.localHostEthIndex = localHostEthIndex;
     SrcNode = NetPoint.LocalHostPoint[localHostEthIndex].IPAddress.GetAddressBytes()[3];
     Header = new FinsHeader(ProtType, SrcNetwork, SrcUnit, SrcNode, DstNetwork, DstUnit, DstNode);
 }
Esempio n. 2
0
 public LaserProtocol(IXCom xCom)
 {
     Magic = 0x00;
     Array.Clear(Content, 0, Convert.ToInt32(ContentLength));
     Array.Clear(Reserve, 0, Convert.ToInt32(ReserveLenth));
     Ack = 0x00;
     _comm = xCom;
     IsStart = false;
     Messages = new List< byte[]>();
     OnMessageReceive += LaserProtocol_OnMessageReceive;
 }
Esempio n. 3
0
 public Fins(PlcProtocolType pt, byte network, byte unit, byte node, IXCom comm)
     : this(pt, comm)
 {
     DstNetwork = network;
     SrcNetwork = network;
     DstNode = node;
     SrcNode = NetPoint.LocalHostPoint[0].IPAddress.GetAddressBytes()[3];
     DstUnit = unit;
     DstUnit = unit;
     Header = new FinsHeader(ProtType, SrcNetwork, SrcUnit, SrcNode, DstNetwork, DstUnit, DstNode);
 }
Esempio n. 4
0
 public virtual bool BindComModule(IXCom comModule)
 {
     if(comModule!=null)
     {
         ComModule = comModule;
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 5
0
        public override bool BindComModule(IXCom comModule)
        {
            bool isOK;
            isOK = base.BindComModule(comModule);
            if (isOK)
            {
                ComModule.OnConnect += ComModule_OnConnect;
                ComModule.OnDisconnect += ComModule_OnDisconnect;
                ComModule.OnReceive += ComModule_OnReceive;
                ComModule.OnSend += ComModule_OnSend;
                try
                {
                    isOK = comModule.Connect();
                }
                catch(Exception)
                {
                    return false;
                }
                if (!isOK)
                    return false;
                if (_updateCoord == null)
                {
                    _updateCoord = new Thread(UpdateCoordFun);
                    _updateCoord.Start();
                }
                else
                {
                    _updateCoord.Abort();
                    _updateCoord = new Thread(UpdateCoordFun);
                    _updateCoord.Start();
                }
                if (_receiveParse == null)
                {

                    _receiveParse = new Thread(ParseResult);
                    _receiveParse.Start();
                }
                else
                {
                    _receiveParse.Abort();
                    _receiveParse = new Thread(ParseResult);
                    _receiveParse.Start();
                }
                return true;
            }

            else
            {
                return false;
            }
        }
Esempio n. 6
0
 public Fins(PlcProtocolType pt, IXCom comm)
     : this(comm)
 {
     ProtType = pt;
     switch(pt)
     {
         case PlcProtocolType.FinsUDP:
             FrameIndexBase = 0;
             break;
         default:
             break;
     }
     Header = new FinsHeader(ProtType, SrcNetwork, SrcUnit, SrcNode, DstNetwork, DstUnit, DstNode);
 }
Esempio n. 7
0
 public Fins(IXCom comm)
     : base(comm)
 {
     SID = 0;
     Header = new FinsHeader(ProtType, SrcNetwork, SrcUnit, SrcNode, DstNetwork, DstUnit, DstNode);
 }
Esempio n. 8
0
        public void Start(int devIndex)
        {
            string key = "";
            if (IsStart)
                return;
            try
            {
                CognexClientInfo info = CognexManager.CognexCilentDict[devIndex];
                if(info.ProtocoType=="TCP/IP")
                {
                    key = NetKey.BuildNetKey(info.ComKey, new NetParameter(info.IPAddress, info.Port));
                }
                _comm = XComManager.XComsDict[key].Instance();
                cvsInSightDisplay.Connect(info.IPAddress, info.UserName, info.PassWord, true);
                LogOn(info);

            }
            catch(Exception e)
            {
                throw new APXExeception(e.Message);
            }
        }
Esempio n. 9
0
        private bool disposedValue = false; // 要检测冗余调用

        #endregion Fields

        #region Constructors

        public PlcProtocol(IXCom comm)
        {
            Comm = comm;
            IsStarted = false;
        }
Esempio n. 10
0
        public bool UnBindComModule(IXCom comModule)
        {
            bool isOK;
            if (comModule == null)
                return true;
            ComModule.OnConnect -= ComModule_OnConnect;
            ComModule.OnDisconnect -= ComModule_OnDisconnect;
            ComModule.OnReceive -= ComModule_OnReceive;
            ComModule.OnSend -= ComModule_OnSend;
            try
            {
                isOK = comModule.Disconnect();
            }
            catch (Exception)
            {
                return false;
            }
            if (!isOK)
                return false;
            if (_updateCoord == null)
            {
                _updateCoord.Abort();
            }

            if (_receiveParse == null)
            {
                _receiveParse.Abort();
            }
            return true;
        }