//定时器刷新 private void timer_Tick_1(object sender, EventArgs e) { DeviceBll device = DeviceObj.GetDevice(); //通讯状态实在 if (device == null) { return; } if (device.Device.ComState == Model_Data.CommunicateEntity.DivCommStateEnum.Success) //通讯成功,则开始画图 { lbComState.Text = Model_Data.Language.EaSolar.Connected; //2 lbComState.ForeColor = Color.Green; btnPauseResume.Enabled = true; TimeDrawLine(); } else if (device.Device.ComState == Model_Data.CommunicateEntity.DivCommStateEnum.Failed) { lbComState.Text = Model_Data.Language.EaSolar.Disconnected;//3 btnPauseResume.Enabled = false; lbComState.ForeColor = Color.Red; } else//通讯失败,突出显示 { lbComState.Text = Model_Data.Language.EaSolar.UnConnect;//1 btnPauseResume.Enabled = false; lbComState.ForeColor = Color.Gray; } }
private void Form1_Load(object sender, EventArgs e) { string jxDB = ConfigurationManager.AppSettings["JXDataBase"]; string jxDBUserPwd = ConfigurationManager.AppSettings["JXDataBaseUserPwd"]; jxDBUserPwd = EncAndDec.Decode(jxDBUserPwd, "zwx", "xwz"); if (string.IsNullOrEmpty(jxDBUserPwd)) { MessageBox.Show("数据库连接信息错误"); return; } PubConstant.ConnectionString = jxDB + jxDBUserPwd; this.comboBoxPlcObjList.SelectedIndex = 0; // this.tabPage1.Enabled = false; devBll = new DeviceBll(); ctlTaskBll = new ControlTaskBll(); ctlTaskIFBll = new ControlInterfaceBll(); palletBll = new OCVPalletBll(); batteryBll = new OCVBatteryBll(); manTaskBll = new ManageTaskBll(); makeCardBll = new MakeCardRecordBll(); plcRwObj = new PLCRW(); plcRwObj.eventLinkLost += PlcLostConnectHandler; plcRwObj2 = new PLCRWNet(); plcRwObj2.eventLinkLost += PlcLostConnectHandler; if (this.comboBoxPlcObjList.Text == "PLC控件") { plcRwIF = plcRwObj; } else if (this.comboBoxPlcObjList.Text == "重新实现MC协议") { plcRwIF = plcRwObj2; } plcFx485 = new PlcRW485BD(); plcFx485.StationNumber = 1; HFReaderIF readerIF = new HFReaderIF(); rfidRW = new SgrfidRW(1); rfidRW.ReaderIF = readerIF; this.comboBoxComports.Items.Clear(); string[] ports = System.IO.Ports.SerialPort.GetPortNames(); foreach (string port in ports) { this.comboBoxComports.Items.Add(port); this.comboBoxFXComs.Items.Add(port); } if (ports != null && ports.Count() > 0) { this.comboBoxComports.Text = ports[0]; this.comboBoxFXComs.Text = ports[0]; } makeCardCount = makeCardBll.GetRecordCount(" "); this.labelMakeCardCount.Text = "计数:" + makeCardCount.ToString(); }
public ECAMSTransPort(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll, ControlInterfaceBll ctlInterfaceBll, ControlTaskBll ctlTaskBll, LogBll logBll) : base(devModel, plcRW, devBll, ctlInterfaceBll, ctlTaskBll, logBll) { switch (devModel.DeviceID) { case "2002": { devName = "A1库入库口"; break; } case "2003": { devName = "A1库分容出口"; break; } case "2004": { devName = "A1库分容入口"; break; } case "2005": { devName = "A1库出口"; break; } case "2006": { devName = "B1库入口"; break; } case "2007": { devName = "B1库二次检测出口"; break; } case "2008": { devName = "B1库的空筐入口"; break; } case "2009": { devName = "B1库的出口"; break; } default: break; } }
/// <summary> /// 下发用户指纹 /// </summary> /// <param name="sn">设备序列号</param> /// <param name="pin">用户工号</param> private void uploadUserFingerTemplate(string sn, string pin) { DeviceModel deviceModel = new DeviceBll().Get(sn); if (!deviceModel.IsBioDataSupport(BioType.FingerPrint)) { return; } List <TmpFPModel> templateList = _tmpFPBll.Get(pin); DeviceCmdModel cmd = new DeviceCmdModel { DevSN = sn }; string verTmp = deviceModel.GetBioVersion(BioType.FingerPrint).Split('.')[0]; //send upload FingerTmp commands foreach (TmpFPModel template in templateList) { cmd.CommitTime = DateTime.Now; if (template.MajorVer != verTmp) { continue; } if (template.MajorVer != "12") { cmd.Content = string.Format(Commands.Command_UpdateFingerTmp, template.Pin, template.Fid, template.Size, template.Valid, template.Tmp); } else { cmd.Content = string.Format(Commands.Command_UpdateBioData, template.Pin, template.Fid, "", template.Valid, template.Duress, "1", template.MajorVer, template.MinorVer, "", template.Tmp); } if (string.IsNullOrEmpty(cmd.Content)) { UserMessageShow(9, ""); return; } lblMsg.Visible = false; try { if (_cmdBll.Add(cmd) >= 0) { UserMessageShow(2, ""); } else { UserMessageShow(3, ""); } } catch { } } }
//加载端口 private static WrapperBll PortSetting(Model_Data.DeviceModel obj) { WrapperBll PS = new WrapperBll(); PS.Port = obj.Port; switch (obj.Port.PortType) { case Protocol.Modbus_SerialPort: PS.PortBll = AllPortBll.CreateInstance(Protocol.Modbus_SerialPort); PS.PortBll.SetParaMeter(CreatCommSerialEntity(obj)); break; case Protocol.Modbus_TCPIPPort: PS.PortBll = AllPortBll.CreateInstance(Protocol.Modbus_TCPIPPort); PS.PortBll.SetParaMeter(CreatCommTCPEntity(obj)); break; case Protocol.Modbus_USBPort: PS.PortBll = AllPortBll.CreateInstance(Protocol.Modbus_USBPort); break; default: return(null); } //Device DeviceBll deviceBLL = new DeviceBll(); deviceBLL.Device.DeviceName = obj.DeviceName; deviceBLL.Device.UnitId = obj.UnitId; deviceBLL.Device.write2DBInterval = obj.WriteDBTime; deviceBLL.Device.AnalogSignalValueTableName = obj.TableName; deviceBLL.Device.UIpath = obj.UIPath; // foreach (AnalogModel AnalogRow in obj.Analog) { AnalogBll analogSignalBLL = new AnalogBll(); analogSignalBLL.AnalogInfo = AnalogRow; deviceBLL.AnalogList.Add(analogSignalBLL); } // foreach (DigitalModel DigitalRow in obj.Digital) { DigitalBll digitalSignalBLL = new DigitalBll(); digitalSignalBLL.DigitalInfo = DigitalRow; deviceBLL.DigitalList.Add(digitalSignalBLL); } deviceBLL.SetSignalAlarmDelegate(); if (deviceBLL != null) { PS.DeviceList.Add(deviceBLL); } PS.SetDeviceDelegate(); return(PS); }
//autoMatic to add Device and copy Device to Database private void listenClient_OnNewMachine(string sn) { DeviceModel machine = new DeviceModel(); machine.DevSN = sn; machine.TimeZone = "34"; if (DeviceBll.Add(machine) > 0) { // add device } }
//定时器刷新 private void timer_RTValue_Tick(object sender, EventArgs e) { DeviceBll device = DeviceObj.GetDevice(); DeviceModel dm = DeviceObj.GetDeviceModel(); if (device == null) { return; } //视图界面更新 UIOffGrid.SetParaMeter(device, dm); }
public List <DeviceModel> getDeviceList(int userid) { try { List <DeviceModel> list = new List <DeviceModel>(); list = ModelConvertHelper <DeviceModel> .ConvertToModel(DeviceBll.select_Deviceinfo(userid)); return(list); } catch { return(null); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="devModel"></param> /// <param name="plcRW"></param> /// <param name="ctlInterfaceBll"></param> /// <param name="ctlTaskBll"></param> public DevBase(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll) { this.devModel = devModel; this.plcRW = plcRW; this.devBll = devBll; plcDataDb1 = new byte[devModel.BytesLenDB1]; plcDataDb2 = new byte[devModel.BytesLenDB2]; plcDataDb1Last = new byte[devModel.BytesLenDB1]; plcDataDb2Last = new byte[devModel.BytesLenDB2]; DebugSimModel = true; //模拟调试用 }
public override COMMUNICATERESULT GetData(DeviceBll Device, ref List <byte> AnalogDate, ref List <byte> DigitalData, ref List <string> CharacterData) { COMMUNICATERESULT ret = new COMMUNICATERESULT(); ret = COMMUNICATERESULT.OK; byte[] SendCommand = null; byte[] RecByte = null; byte[] RecData = null; int BytesToRec = 0; foreach (CommandClass AnalogCommand in Device.Device.AnalogCommandList) { SendCommand = SetBusinessId(AnalogCommand.Command); BytesToRec = AnalogCommand.RecLen; ret = socketWrapper.SendAndReceive(SendCommand, BytesToRec, out RecByte); if (ret != COMMUNICATERESULT.OK) { return(ret); } ret = CheckData(RecByte, SendCommand); if (ret != COMMUNICATERESULT.OK) { return(ret); } RecData = GetRecDataFromRecByte(RecByte); AnalogDate.AddRange(RecData); } foreach (CommandClass DigitalCommand in Device.Device.DigitalCommandList) { SendCommand = SetBusinessId(DigitalCommand.Command); BytesToRec = DigitalCommand.RecLen; ret = socketWrapper.SendAndReceive(SendCommand, BytesToRec, out RecByte); if (ret != COMMUNICATERESULT.OK) { return(ret); } ret = CheckData(RecByte, SendCommand); if (ret != COMMUNICATERESULT.OK) { return(ret); } RecData = GetRecDataFromRecByte(RecByte); DigitalData.AddRange(RecData); } return(ret); }
/// <summary> /// 获取所有机器的序列号 /// </summary> private void GetAllDevSNToCmbo() { cmb_DevSN.Items.Clear(); cmb_DevSN.Items.Add("");//第一行为空,表示全部 try { List <string> listSN = new DeviceBll().GetAllDevSN(); int i = 0; for (i = 0; i < listSN.Count; i++) { cmb_DevSN.Items.Add(listSN[i]); } return; } catch (Exception ex) { MessageBox.Show("GetAllDevSNToCmbo error:" + ex.ToString()); } }
/// <summary> /// 加载所有设备序列号 /// </summary> private void LoadDeviceSN() { cmbDevice.Items.Clear(); DeviceBll deviceBll = new DeviceBll(); try { List <string> listDevSN = deviceBll.GetAllDevSN(); for (int i = 0; i < listDevSN.Count; i++) { cmbDevice.Items.Add(listDevSN[i]); //添加在Device选择项中 } return; } catch (Exception ex) { MessageBox.Show("Load Device Message error:" + ex.ToString()); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="devModel"></param> /// <param name="plcRW"></param> /// <param name="ctlInterfaceBll"></param> /// <param name="ctlTaskBll"></param> public ECAMSDevBase(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll, ControlInterfaceBll ctlInterfaceBll, ControlTaskBll ctlTaskBll, LogBll logBll) { this.devModel = devModel; this.plcRW = plcRW; this.devBll = devBll; this.ctlInterfaceBll = ctlInterfaceBll; this.ctlTaskBll = ctlTaskBll; this.logBll = logBll; this.rfidRecordBll = new RfidRdRecordBll(); this.palletTraceBll = new PalletHistoryRecordBll(); //plcDataDb1 = new byte[devModel.BytesLenDB1]; //plcDataDb2 = new byte[devModel.BytesLenDB2]; //plcDataDb1Last = new byte[devModel.BytesLenDB1]; //plcDataDb2Last = new byte[devModel.BytesLenDB2]; this.dicCommuDataDB1 = new Dictionary <int, DevCommDatatype>(); this.dicCommuDataDB2 = new Dictionary <int, DevCommDatatype>(); dicDataDB1Last = new Dictionary <int, object>(); dicDataDB2Last = new Dictionary <int, object>(); dicDB1Read = new Dictionary <int, object>(); //DebugMode = true; //模拟调试用 }
//对外接口函数 public void SetParaMeter(DeviceBll device, DeviceModel dm) { //用来标志定时器在运行 lbFlag.ForeColor = lbFlag.ForeColor == Color.Red ? Color.Blue : Color.Red; if (EASolar_Info == null) { EASolar_Info = device.Device; } if (device.Device.ComState == DivCommStateEnum.Failed) { SystemStateInfo.Name = SysTemStateDescribe.Describe1; SystemStateInfo.Value = 1; } else if (device.Device.ComState == DivCommStateEnum.Success) { SystemStateInfo.Name = SysTemStateDescribe.Describe0; SystemStateInfo.Value = 0; } else { SystemStateInfo.Name = SysTemStateDescribe.Describe; SystemStateInfo.Value = 2; } if (device.Device.ComState == Model_Data.CommunicateEntity.DivCommStateEnum.Success) { if (device.AnalogList != null && device.DigitalList != null) { SetAnalogData(dm.Analog); SetDigitalData(dm.Digital); StartControlPage.LoadShowInfo(true); systemControlPage.LoadShowInfo(true); } } else { ArrayInt(false); } RefreshPagesShow(); }
private void Form1_Load(object sender, EventArgs e) { ctlManager = new ECAMWCS(); ctlManager.AttachErrorHandler(ErrorEventHandler); ctlManager.AttachLogHandler(LogEventHandler); this.buttonStart.Enabled = false; this.buttonStop.Enabled = false; // this.tabPage1.Enabled = false; devBll = new DeviceBll(); ctlTaskBll = new ControlTaskBll(); ctlTaskIFBll = new ControlInterfaceBll(); palletBll = new OCVPalletBll(); batteryBll = new OCVBatteryBll(); manTaskBll = new ManageTaskBll(); plcRwObj = new PLCRW(); plcRwObj.eventLinkLost += PlcLostConnectHandler; HFReaderIF readerIF = new HFReaderIF(); rfidRW = new SgrfidRW(1); this.comboBoxComports.Items.Clear(); int i = 0; string[] ports = System.IO.Ports.SerialPort.GetPortNames(); foreach (string port in ports) { this.comboBoxComports.Items.Add(port); i++; } if (ports != null && ports.Count() > 0) { this.comboBoxComports.Text = ports[0]; } rfidWorkingThread = new Thread(new ThreadStart(SysWorkingProc)); rfidWorkingThread.IsBackground = true; rfidWorkingThread.Name = "RFID读写卡测试线程"; }
/// <summary> /// 下发用户掌静脉数据 /// </summary> /// <param name="sn">设备序列号</param> /// <param name="pin">用户工号</param> private void uploadPalmTemplate(string sn, string pin) { DeviceModel deviceModel = new DeviceBll().Get(sn); DeviceCmdModel cmd = new DeviceCmdModel(); cmd.DevSN = sn; if (deviceModel.IsBioDataSupport(BioType.Palm)) { List <TmpBioDataModel> bioList = _tmpBioDataBll.Get(pin, BioType.Palm.ToString("D")); //send upload face commands foreach (TmpBioDataModel bioTmp in bioList) { cmd.CommitTime = DateTime.Now; cmd.Content = string.Format(Commands.Command_UpdateBioData, bioTmp.Pin, bioTmp.No, bioTmp.Index, bioTmp.Valid, bioTmp.Duress, bioTmp.Type, bioTmp.MajorVer, bioTmp.MinorVer, bioTmp.Format, bioTmp.Tmp); if (string.IsNullOrEmpty(cmd.Content)) { UserMessageShow(9, ""); return; } lblMsg.Visible = false; try { if (_cmdBll.Add(cmd) >= 0) { UserMessageShow(2, ""); } else { UserMessageShow(3, ""); } } catch { } } } }
// 初始化 信号 下拉框 只显示变化的数字量,过滤掉常量和字符量 private void LoadSignalNameCombobox() { cbSignalName.Properties.Items.Clear(); DeviceBll dbll = DeviceObj.GetDevice(); if (dbll == null) { return; } foreach (AnalogBll item in dbll.AnalogList) { if (item.AnalogInfo.AnalogReadFrequency != AnalogReadFrequency.EveryTime) { continue; } if (!item.AnalogInfo.SignalType.Contains("decimal") && item.AnalogInfo.SignalType != "long") { continue; } string SignalName = item.AnalogInfo.SignalName; cbSignalName.Properties.Items.Add(SignalName); } cbSignalName.SelectedIndex = 0; }
//public TestWarehouseOutBusiness WarehouseOutTest //{ // get // { // return warehouseOutTest; // } // private set { } //} public bool InitTestManager(ref string resultStr) { devDicList = new Dictionary <string, DevBase>(); devBll = new DeviceBll(); plcRW = new PlcRWSim(); //1 创建设备对象 IList <DeviceModel> devList = devBll.GetModelList(" "); foreach (DeviceModel devME in devList) { if (devME == null) { continue; } DevBase ecamsDev = null; if (devME.DeviceType == EnumDevType.堆垛机.ToString()) { ecamsDev = new Stacker(devME, plcRW, devBll); } else if (devME.DeviceType == EnumDevType.站台.ToString()) { if (devME.BytesLenDB1 <= 0 || devME.BytesLenDB2 <= 0) { continue; } ecamsDev = new TransPort(devME, plcRW, devBll); } else if (devME.DeviceType == EnumDevType.机械手.ToString()) { ecamsDev = new XYZGriper(devME, plcRW, devBll); } else { ecamsDev = null; continue; } if (!ecamsDev.Init()) { resultStr = ecamsDev.DevModel.DeviceType + " " + ecamsDev.DevModel.DeviceID + " " + "初始化失败"; return(false); } devDicList[devME.DeviceID] = ecamsDev; } //2 创建业务模拟对象 warehouseInOutTest = new TestWarehouseInOutBusiness(); // warehouseOutTest = new TestWarehouseOutBusiness(); warehouseInOutTest.Stacker1001 = devDicList["1001"] as Stacker; warehouseInOutTest.Stacker1002 = devDicList["1002"] as Stacker; warehouseInOutTest.TransPort2002 = devDicList["2002"] as TransPort; warehouseInOutTest.TransPort2004 = devDicList["2004"] as TransPort; warehouseInOutTest.TransPort2006 = devDicList["2006"] as TransPort; warehouseInOutTest.TransPort2008 = devDicList["2008"] as TransPort; warehouseInOutTest.TransPort2009 = devDicList["2009"] as TransPort; //warehouseInOutTest.TransPort2003 = devDicList["2003"] as TransPort; //warehouseInOutTest.TransPort2005 = devDicList["2005"] as TransPort; //warehouseInOutTest.TransPort2007 = devDicList["2007"] as TransPort; //warehouseInOutTest.TransPort2009 = devDicList["2009"] as TransPort; fillPalletTest = new TestBusinessFillPallet(); fillPalletTest.Grisper5001 = devDicList["5001"] as XYZGriper; grispTest1 = new TestBusinessGrisp(); grispTest1.Grisper = devDicList["5002"] as XYZGriper; grispTest2 = new TestBusinessGrisp(); grispTest2.Grisper = devDicList["5003"] as XYZGriper; //3 sysWorkingThread = new Thread(new ThreadStart(SysWorkingProc)); sysWorkingThread.IsBackground = true; sysWorkingThread.Name = "业务测试主线程"; return(true); }
public XYZGriper(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll) : base(devModel, plcRW, devBll) { }
//get vendor name private void listenClient_OnGetVendorName(string sn, string vendorName) { // update vendorName to gridview DeviceBll.UpdateVendorName(sn, vendorName); }
/// <summary> /// 下发用户面部数据 /// </summary> /// <param name="sn">设备序列号</param> /// <param name="pin">用户工号</param> private void uploadUserFaceTemplate(string sn, string pin) { DeviceModel deviceModel = new DeviceBll().Get(sn); DeviceCmdModel cmd = new DeviceCmdModel(); cmd.DevSN = sn; if (deviceModel.IsBioDataSupport(BioType.Face)) { List <TmpFaceModel> faceList = _faceBll.Get(pin); //send upload face commands foreach (TmpFaceModel faceTmp in faceList) { cmd.CommitTime = DateTime.Now; cmd.Content = string.Format(Commands.Command_UpdateFaceTmp, faceTmp.Pin, faceTmp.Fid, faceTmp.Valid, faceTmp.Size, faceTmp.Tmp); if (string.IsNullOrEmpty(cmd.Content)) { UserMessageShow(9, ""); return; } lblMsg.Visible = false; try { if (_cmdBll.Add(cmd) >= 0) { UserMessageShow(2, ""); } else { UserMessageShow(3, ""); } } catch { } } } if (deviceModel.IsBioDataSupport(BioType.VisilightFace)) { List <TmpBioPhotoModel> biophotoList = _tmpBioPhotoBll.Get(pin, BioType.Comm.ToString("D") + "," + BioType.VisilightFace.ToString("D")); //send upload biophoto commands foreach (TmpBioPhotoModel bioPhotoTmp in biophotoList) { cmd.CommitTime = DateTime.Now; cmd.Content = string.Format(Commands.Command_UpdateBioPhoto, bioPhotoTmp.Pin, bioPhotoTmp.Type, bioPhotoTmp.Size, bioPhotoTmp.Content, "0", "", "0"); if (string.IsNullOrEmpty(cmd.Content)) { UserMessageShow(9, ""); return; } lblMsg.Visible = false; try { if (_cmdBll.Add(cmd) >= 0) { UserMessageShow(2, ""); } else { UserMessageShow(3, ""); } } catch { } } } }
//创建设备查询命令列表 public static bool CreatDeviceCommandList(Protocol PortType, DeviceBll Device) { Device.Device.AnalogCommandList = CreatAnalogCommandList(PortType, Device.Device.UnitId, Device.AnalogList); Device.Device.DigitalCommandList = CreatDigitalCommandList(PortType, Device.Device.UnitId, Device.DigitalList); return(true); }
public TransPort(ECAMSDataAccess.DeviceModel devModel, IPlcRW plcRW, DeviceBll devBll) : base(devModel, plcRW, devBll) { }