Пример #1
0
        public void SetReport(ICommandReport ReportTarget)
        {
            _ReportTarget = ReportTarget;


            switch (ConnectionType.ToUpper())
            {
            case "SOCKET":
                //conn = new SocketClient(Config, this);
                conn = new SocketClient(this, this);
                break;

            case "COMPORT":
                conn = new ComPortClient(this, this);
                break;
            }
            _Decoder = new CommandConvert.CommandDecoder(Vendor);

            Encoder = new CommandEncoder(Vendor);


            this.Name         = DeviceName;
            this.Status       = "";
            this._IsConnected = false;
            ThreadPool.QueueUserWorkItem(new WaitCallback(Start));
        }
Пример #2
0
 public RobotStatusFrm(IController Controller, ICommandReport Report)
 {
     InitializeComponent();
     _Controller = Controller;
     _Report     = Report;
     _Controller.SetReportTarget(this);
 }
Пример #3
0
        public void SetReport(ICommandReport ReportTarget)
        {
            _ReportTarget = ReportTarget;


            Encoder = new CommandEncoder(Vendor);

            this.Name         = DeviceName;
            this.Status       = "";
            this._IsConnected = false;
        }
Пример #4
0
        public void SetReport(ICommandReport ReportTarget)
        {
            _ReportTarget = ReportTarget;



            _Decoder = new CommandConvert.CommandDecoder(Vendor);

            Encoder = new CommandEncoder(Vendor);


            this.Name   = DeviceName;
            this.Status = "";

            ThreadPool.QueueUserWorkItem(new WaitCallback(Start), NodeManagement.Get("CSTROBOT"));
        }
Пример #5
0
        public DeviceController(DeviceConfig Config, ICommandReport ReportTarget)
        {
            _ReportTarget = ReportTarget;
            _Config       = Config;

            switch (Config.ConnectionType)
            {
            case "Socket":
                conn = new SocketClient(Config.IPAdress, Config.Port, this);
                break;

            case "ComPort":
                conn = new ComPortClient(this);
                break;
            }
            _Decoder = new SANWA.Utility.Decoder(Config.DeviceType);
        }
        public static void LoadConfig(ICommandReport Report)
        {
            //if (Controllers != null)
            //{
            //    foreach(DeviceController each in Controllers.Values)
            //    {
            //        each.Close();
            //    }
            //}
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            Controllers = new ConcurrentDictionary <string, DeviceController>();
            string Sql = @"SELECT UPPER(t.device_name) as DeviceName,t.device_type as DeviceType,
										UPPER(t.vendor) as vendor,
                            case when t.conn_type = 'Socket' then  t.conn_address else '' end as IPAdress ,
                            case when t.conn_type = 'Socket' then  CONVERT(t.conn_prot,SIGNED) else 0 end as Port ,
                            case when t.conn_type = 'Comport' then   CONVERT(t.conn_prot,SIGNED) else 0 end as BaudRate ,
                            case when t.conn_type = 'Comport' then  t.conn_address else '' end as PortName ,
                            t.com_parity_bit as ParityBit,
                            ifnull(CONVERT(t.com_data_bits,SIGNED),0) as DataBits,
                            t.com_stop_bit as StopBit,
                            t.conn_type as ConnectionType,
                            t.enable_flg as Enable
                            FROM config_controller_setting t
                            WHERE t.equipment_model_id = @equipment_model_id
                            AND t.device_type <> 'DIO'";

            keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
            DataTable dt       = dBUtil.GetDataTable(Sql, keyValues);
            string    str_json = JsonConvert.SerializeObject(dt, Formatting.Indented);

            List <DeviceConfig> ctrlList = JsonConvert.DeserializeObject <List <DeviceConfig> >(str_json);


            foreach (DeviceConfig each in ctrlList)
            {
                if (each.Enable)
                {
                    DeviceController tmp = new DeviceController(each, Report);
                    Controllers.TryAdd(each.DeviceName, tmp);
                }
            }
        }
Пример #7
0
        public RobotController(string _IP, int _Port, int _Timeout, string _ControllerName, ICommandReport _tObj)
        {
            IP             = _IP;
            Port           = _Port;
            ControllerName = _ControllerName;
            Timeout        = Convert.ToInt16(_Timeout);

            tObj = _tObj;
            timeOutTimer.Enabled = false;

            timeOutTimer.Interval = Timeout;

            timeOutTimer.Elapsed += new System.Timers.ElapsedEventHandler(TimeOutMonitor);

            actionTimeOutTimer.Enabled = false;

            actionTimeOutTimer.Interval = Timeout;

            actionTimeOutTimer.Elapsed += new System.Timers.ElapsedEventHandler(ActionTimeOutMonitor);

            cmdSck = new SocketClient(IP, Convert.ToInt16(Port), ControllerName, this);
        }
Пример #8
0
        public DeviceController(DeviceConfig Config, ICommandReport ReportTarget)
        {
            _ReportTarget = ReportTarget;
            _Config       = Config;

            switch (Config.ConnectionType)
            {
            case "Socket":
                conn = new SocketClient(Config, this);
                break;

            case "ComPort":
                conn = new ComPortClient(Config, this);
                break;
            }
            _Decoder = new SANWA.Utility.Decoder(Config.Vendor);

            Encoder = new SANWA.Utility.Encoder(Config.Vendor);


            this.Name         = _Config.DeviceName;
            this.Status       = "";
            this._IsConnected = false;
        }
Пример #9
0
 void IController.SetReportTarget(ICommandReport target)
 {
     tObj = target;
 }
        public static void LoadConfig(ICommandReport Report)
        {
            //if (Controllers != null)
            //{
            //    foreach(DeviceController each in Controllers.Values)
            //    {
            //        each.Close();
            //    }
            //}
            //  Dictionary<string, object> keyValues = new Dictionary<string, object>();
            Controllers = new ConcurrentDictionary <string, IController>();
            //  string Sql = @"SELECT UPPER(t.device_name) as DeviceName,t.device_type as DeviceType,
            //UPPER(t.vendor) as vendor,
            //                  case when t.conn_type = 'Socket' then  t.conn_address else '' end as IPAdress ,
            //                  case when t.conn_type = 'Socket' then  CONVERT(t.conn_port,SIGNED) else 0 end as Port ,
            //                  case when t.conn_type = 'Comport' then   CONVERT(t.conn_port,SIGNED) else 0 end as BaudRate ,
            //                  case when t.conn_type = 'Comport' then  t.conn_address else '' end as PortName ,
            //                  t.conn_type as ConnectionType,
            //                  t.enable_flg as Enable,
            //                  t.controller_type as ControllerType
            //                  FROM config_controller_setting t
            //                  WHERE t.equipment_model_id = @equipment_model_id
            //                  AND t.device_type <> 'DIO'";
            //  keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
            //  DataTable dt = dBUtil.GetDataTable(Sql, keyValues);

            List <DeviceController> controllerList = new ConfigTool <List <DeviceController> >().ReadFile("config/Controller.json");

            foreach (DeviceController each in controllerList)
            {
                if (!each.DeviceType.Equals("DIO"))
                {
                    IController ctrl = null;
                    if (each.ControllerType.Equals("ASCII"))
                    {
                        DeviceController d = new DeviceController();
                        d.DeviceName     = each.DeviceName;
                        d.DeviceType     = each.DeviceType;
                        d.Vendor         = each.Vendor;
                        d.IPAdress       = each.IPAdress;
                        d.Port           = each.Port;
                        d.BaudRate       = each.BaudRate;
                        d.PortName       = each.PortName;
                        d.ConnectionType = each.ConnectionType;
                        d.Enable         = each.Enable;
                        d.ControllerType = each.ControllerType;

                        ctrl = d;
                    }
                    else if (each.ControllerType.Equals("MODBUS"))
                    {
                        ModbusController m = new ModbusController();
                        m.DeviceName     = each.DeviceName;
                        m.DeviceType     = each.DeviceType;
                        m.Vendor         = each.Vendor;
                        m.IPAdress       = each.IPAdress;
                        m.Port           = each.Port;
                        m.BaudRate       = each.BaudRate;
                        m.PortName       = each.PortName;
                        m.ConnectionType = each.ConnectionType;
                        m.Enable         = each.Enable;
                        m.ControllerType = each.ControllerType;
                        ctrl             = m;
                    }
                    else if (each.ControllerType.Equals("PLC"))
                    {
                        PLCController m = new PLCController();
                        m.DeviceName     = each.DeviceName;
                        m.DeviceType     = each.DeviceType;
                        m.Vendor         = each.Vendor;
                        m.IPAdress       = each.IPAdress;
                        m.Port           = each.Port;
                        m.BaudRate       = each.BaudRate;
                        m.PortName       = each.PortName;
                        m.ConnectionType = each.ConnectionType;
                        m.Enable         = each.Enable;
                        m.ControllerType = each.ControllerType;
                        ctrl             = m;
                    }

                    if (ctrl.GetEnable())
                    {
                        //each.ConnectionType = "Socket";
                        //each.IPAdress = "127.0.0.1";
                        //each.Port = 9527;
                        ctrl.SetReport(Report);
                        Controllers.TryAdd(ctrl.GetDeviceName(), ctrl);
                    }
                }
            }
        }