Ejemplo n.º 1
0
 public bool Init(IOCardCfg ioCfg, ICommunicationPortCfg communicationPortCfg)
 {
     this.ioCfg = ioCfg;
     comport    = CommunicationMgr.Instance.FindPortByPortName(ioCfg.PortName) as Comport;
     if (comport == null)
     {
         return(false);
     }
     else
     {
         _controller = IrixiEE0017.CreateInstance(ioCfg.PortName);
         if (_controller != null)
         {
             _controller.OnOutputStateChanged += _controller_OnOutputStateChanged;
             _controller.OnInputStateChanged  += _controller_OnInputStateChanged;
             if (ioCfg.NeedInit)
             {
                 return(_controller.Init(Int32.Parse(comport.ToString().ToLower().Replace("com", ""))));
             }
             else
             {
                 return(true);
             }
         }
         return(false);
     }
 }
Ejemplo n.º 2
0
 public bool Init(IOCardCfg ioCfg, ICommunicationPortCfg communicationPortCfg)
 {
     try
     {
         this.ioCfg = ioCfg;
         ComportCfg portCfg = communicationPortCfg as ComportCfg;
         comport = CommunicationMgr.Instance.FindPortByPortName(ioCfg.PortName) as Comport;
         if (comport == null)
         {
             return(false);
         }
         else
         {
             _controller = M12Wrapper.CreateInstance(portCfg.Port, portCfg.BaudRate);
             _controller.Open();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }