Exemple #1
0
 //连接
 private void buttonConnect_Click(object sender, EventArgs e)
 {
     if (buttonConnect.Text == "Conncect")
     {
         //light = new Light(0, new LightingOPT(1, textBoxIP.Text.Trim()));
         light         = new LightingOPT(1, textBoxIP.Text.Trim());
         this.lightCom = light as LightingCom;
         var ret = this.lightCom.Connect(new TimeSpan(0, 0, 0, 0, 40));
         if (ret)
         {
             this.richTextBoxState.AppendText($"connect:{ret.ToString()}" + Environment.NewLine);
             if (light.GetChannelState(LightChn.Red) == 1 && light.GetChannelState(LightChn.Green) == 1 && light.GetChannelState(LightChn.Blue) == 1)
             {
                 StringBuilder sn      = new StringBuilder();
                 StringBuilder ip      = new StringBuilder();
                 StringBuilder mask    = new StringBuilder();
                 StringBuilder gateWay = new StringBuilder();
                 this.richTextBoxState.AppendText($"all RGB light connected!" + Environment.NewLine);
                 this.light.ReadSN(sn);                      //读取设备序列号
                 this.txtSN.Text = sn.ToString();
                 this.light.ReadIPConfig(ip, mask, gateWay); //读取IP配置
                 this.txtIP.Text         = ip.ToString();
                 this.txtSubnetMask.Text = mask.ToString();
                 this.txtGateway.Text    = gateWay.ToString();
                 labelConnectState.Text  = "connected";
                 buttonConnect.Text      = "Disconnect";
             }
             else
             {
                 this.richTextBoxState.AppendText($"one or more RGB light disconnected!" + Environment.NewLine);
             }
         }
         else
         {
             this.richTextBoxState.AppendText($"connect:{ret.ToString()}" + Environment.NewLine);
         }
     }
     else
     {
         this.lightCom.Disconnect();
         buttonConnect.Text     = "Connect";
         labelConnectState.Text = "disconnected";
     }
 }
Exemple #2
0
 private void selectSensor(string sensorType)
 {
     this.gbxSensor.Controls.Clear();
     if (sensorType == HEIGHT)
     {
         LaserableCom laserable = Machine.Instance.Laser.Laserable as LaserableCom;
         this.setupEasySerialPort(laserable.EasySerialPort);
         this.gbxSensor.Controls.Add(this.settingLaser.Setup());
     }
     else if (sensorType == SCALE)
     {
         ScalableCom scalable = Machine.Instance.Scale.Scalable as ScalableCom;
         this.setupEasySerialPort(scalable.EasySerialPort);
         this.gbxSensor.Controls.Add(this.settingScale.Setup());
     }
     else if (sensorType == HEATER)
     {
         if (SensorMgr.Instance.Heater.Vendor == HeaterControllerMgr.Vendor.Aika)
         {
             AiKaThermostat heaterable = Machine.Instance.HeaterController1.HeaterControllable as AiKaThermostat;
             this.setupEasySerialPort(heaterable.EasySerialPort);
         }
         else if (SensorMgr.Instance.Heater.Vendor == HeaterControllerMgr.Vendor.Omron)
         {
             ThermostatOmron heaterable = Machine.Instance.HeaterController1.HeaterControllable as ThermostatOmron;
             this.setupEasySerialPort(heaterable.EasySerialPort);
         }
         else
         {
             InvalidThermostat heaterable = Machine.Instance.HeaterController1.HeaterControllable as InvalidThermostat;
             this.setupEasySerialPort(heaterable.EasySerialPort);
         }
         this.gbxSensor.Controls.Add(this.settingHeater.Setup());
     }
     else if (sensorType == PROPORS)
     {
         ProportionorCom propor = Machine.Instance.Valve1.Proportioner.Proportional as ProportionorCom;
         if (propor.EasySerialPort != null)
         {
             this.setupEasySerialPort(propor.EasySerialPort);
         }
         this.gbxSensor.Controls.Add(this.settingPropors.Setup());
     }
     else if (sensorType == GAGE)
     {
         DigitalGagableCom gagable = Machine.Instance.DigitalGage.DigitalGagable as DigitalGagableCom;
         this.setupEasySerialPort(gagable.EasySerialPort);
     }
     else if (sensorType == SCANNER1)
     {
         BarcodeScannableCom scanner = Machine.Instance.BarcodeSanncer1.BarcodeScannable as BarcodeScannableCom;
         this.setupEasySerialPort(scanner.EasySerialPort);
         this.gbxSensor.Controls.Add(this.settingScanner.ChangeConveyorNo(0).Setup());
     }
     else if (sensorType == SCANNER2)
     {
         BarcodeScannableCom scanner = Machine.Instance.BarcodeSanncer2.BarcodeScannable as BarcodeScannableCom;
         this.setupEasySerialPort(scanner.EasySerialPort);
         this.gbxSensor.Controls.Add(this.settingScanner.ChangeConveyorNo(1).Setup());
     }
     else if (sensorType == LIGHT)
     {
         LightingCom light = Machine.Instance.Light.Lighting as LightingCom;
         if (SensorMgr.Instance.Light.EasySerialPort != null)
         {
             this.setupEasySerialPort(SensorMgr.Instance.Light.EasySerialPort);
         }
         this.gbxSensor.Controls.Add(this.settingLight.Setup());
     }
 }