public bool Init(MotionCardCfg motionCfg, ICommunicationPortCfg communicationPortCfg) { this.motionCfg = motionCfg; MAX_AXIS = motionCfg.MaxAxisNo; MIN_AXIS = motionCfg.MinAxisNo; comport = CommunicationMgr.Instance.FindPortByPortName(motionCfg.PortName) as Comport; _controller = IrixiEE0017.CreateInstance(motionCfg.PortName); if (comport == null) { return(false); } _controller = IrixiEE0017.CreateInstance(motionCfg.PortName); if (_controller != null) { _controller.OnAxisStateChanged += OnIrixiAxisStateChanged; if (motionCfg.NeedInit) { return(_controller.Init(Int32.Parse(comport.ToString().ToLower().Replace("com", "")))); } else { return(true); } } return(false); }
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); } }
public override bool Init(LightCfg cfg, ICommunicationPortCfg communicationPort) { try { this.lightCfg = cfg; MAXCH = this.lightCfg.MaxChannelNo; MINCH = this.lightCfg.MinChannelNo; if (lightCfg.NeedInit) { if (Comport == null) { Comport = new SerialPort(); } ComportCfg portCfg = communicationPort as ComportCfg; if (portCfg == null) { return(false); } Comport.BaudRate = portCfg.BaudRate; Comport.StopBits = StopBits.One; Comport.Parity = Parity.None; Comport.DataBits = 8; Comport.PortName = string.IsNullOrEmpty(portCfg.Port.ToUpper()) ? Comport.PortName : portCfg.Port.ToUpper(); Comport.ReadTimeout = 1000; Comport.WriteTimeout = 1000; if (Comport.IsOpen) { Comport.Close(); } Comport.Open(); return(GetLightValue(MINCH) >= 0); } else { return(true); } } catch (Exception ex) { return(false); } }
public bool Init(MotionCardCfg motionCfg, ICommunicationPortCfg communicationPortCfg) { try { this.motionCfg = motionCfg; MAX_AXIS = motionCfg.MaxAxisNo; MIN_AXIS = motionCfg.MinAxisNo; ComportCfg portCfg = communicationPortCfg as ComportCfg; comport = CommunicationMgr.Instance.FindPortByPortName(motionCfg.PortName) as Comport; _controller = M12Wrapper.CreateInstance(portCfg.Port, portCfg.BaudRate); _controller.OnUnitStateUpdated += OnIrixiAxisStateChanged; _controller.Open(); return(true); } catch { return(false); } }
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); } }
public override bool Init(LightCfg cfg, ICommunicationPortCfg communicationPort) { try { this.lightCfg = cfg; MAXCH = this.lightCfg.MaxChannelNo; MINCH = this.lightCfg.MinChannelNo; if (lightCfg.NeedInit) { ComportCfg portCfg = communicationPort as ComportCfg; LightController = new JKLightSource(int.Parse(portCfg.Port.ToUpper().Replace("COM", "")), 9600); LightController.Open(); return(true); } else { return(true); } } catch (Exception ex) { return(false); } }
public abstract bool Init(LightCfg cfg, ICommunicationPortCfg communicationPort);
public Comport(ICommunicationPortCfg portCfg) : base(portCfg) { this.portCfg = portCfg as ComportCfg; sp.ReceivedBytesThreshold = 1; sp.DataReceived += Sp_DataReceived; }
public CommunicationPortBase(ICommunicationPortCfg portCfg) { }