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(); }
private void buttonWriteRfid_Click(object sender, EventArgs e) { byte[] bytesSnd = SgrfidRW.String2Bytes(this.textBoxRfidWrite.Text, 0); if (bytesSnd != null) { if (rfidRW.WriteSBlock(bytesSnd)) { AddLog("rfid 数据写入成功"); } else { AddLog("rfid 数据写入失败"); } } else { AddLog("rfid 数据写入失败"); } }
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读写卡测试线程"; }
private void buttonReadRfid_Click(object sender, EventArgs e) { try { byte blockStart = byte.Parse(this.textBoxRfidBlockStart.Text); // byte blockNum = byte.Parse(this.textBoxRfidBlockNum.Text); byte[] bytesData = rfidRW.ReadSBlock(blockStart); if (bytesData == null || bytesData.Count() < 4) { MessageBox.Show("读卡失败"); return; } string strData = SgrfidRW.bytes2hexString(bytesData, bytesData.Count(), 1); if (strData != null) { this.textBoxRfidread.Text = strData; } } catch (System.Exception ex) { AddLog(ex.Message + "," + ex.StackTrace); } }
private void Form1_Load(object sender, EventArgs e) { Console.SetOut(new TextBoxWriter(this.richTextBoxLog)); plcForm2.MdiParent = this; this.panelPlc2.Controls.Clear(); this.panelPlc2.Controls.Add(plcForm2); plcForm2.Dock = DockStyle.Fill; plcForm2.Show(); rfidWQForm.MdiParent = this; this.panelWqrfid.Controls.Clear(); this.panelWqrfid.Controls.Add(rfidWQForm); rfidWQForm.Dock = DockStyle.Fill; rfidWQForm.Show(); rfidSgUrb3Form.MdiParent = this; this.panelSgUrb3.Controls.Clear(); this.panelSgUrb3.Controls.Add(rfidSgUrb3Form); rfidSgUrb3Form.Dock = DockStyle.Fill; rfidSgUrb3Form.Show(); // 隐藏不用 的tabpage //this.tabControl1.TabPages.Remove(this.tabPage1); // this.tabControl1.TabPages.Remove(this.tabPage3); this.tabControl1.TabPages.Remove(this.tabPage5); // this.comboBoxPlcObjList.SelectedIndex = 0; // this.tabPage1.Enabled = false; this.comboBoxDatabitSel.Items.AddRange(new string[] { "32位整数", "64位整数" }); this.comboBoxDatabitSel.SelectedIndex = 0; #region PLC相关 this.cbxPlcCata.Items.AddRange(new string[] { "FX5U", "Q系列", "Fx3uNET模块" }); this.cbxPlcCata.SelectedIndex = 0; plcRwObj2 = new PLCRwMCPro(EnumPlcCata.FX5U, 1000, 1000); plcRwObj2.eventLinkLost += PlcLostConnectHandler; plcRwIF = plcRwObj2; plcFx485 = new PlcRW485BD(); plcFx485.StationNumber = 1; #endregion HFReaderIF readerIF = new HFReaderIF(); rfidRW = new SgrfidRW(1); rfidRW.ReaderIF = readerIF; this.comboBoxComports.Items.Clear(); barcodeReader = new BarcodeRWHonevor(1); string[] ports = System.IO.Ports.SerialPort.GetPortNames(); foreach (string port in ports) { this.comboBoxComports.Items.Add(port); this.comboBoxFXComs.Items.Add(port); this.comboBoxBarcode.Items.Add(port); this.comboBoxAirdetect.Items.Add(port); } if (ports != null && ports.Count() > 0) { this.comboBoxComports.Text = ports[0]; this.comboBoxFXComs.Text = ports[0]; } rfidWorkingThread = new Thread(new ThreadStart(SysWorkingProc)); rfidWorkingThread.IsBackground = true; this.printer = new PrinterRW(1, "", 8000); string dbConn = string.Format("Data Source ={0}\\SQLEXPRESS;Initial Catalog=FangTAIZaojuA;User ID=sa;Password=123456;", this.textBoxPrinterIP.Text); this.printerDB = new PrinterRWdb(dbConn); //MES 测试初始化 this.textBoxMESwsAddr.Text = "http://192.168.100.90:8188/soap/EventService?wsdl"; this.comboBoxInterfaces.Items.AddRange(new string[] { "assembleDown", "assembleRepair" }); this.comboBoxInterfaces.SelectedIndex = 0; this.comboBoxDTs.Items.AddRange(new string[] { "FT_MES_STEP_INFO", "FT_MES_STEP_INFO_DETAIL" }); this.comboBoxDTs.SelectedIndex = 0; this.textBoxMesParams.Text = "1002002100086L451607280194,L45"; this.richTextBoxMesDBConn.Text = @"Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.94)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRQMESDB) ) ) ;User Id=prqminda1;Password=prqminda1;Connection Timeout=5;"; // this.richTextBoxMesDBConn.Text = @"Data Source=(DESCRIPTION = // (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.94)(PORT = 1521)) // (CONNECT_DATA = // (SERVER = DEDICATED) // (SERVICE_NAME = PRQMESDB) // ) // ) //;User Id=prqminda1;Password=prqminda1;"; //这个也可以放到Web.Config中。 //气密 airDetecter = new AirDetectFL295CRW(1, ""); }
private bool ParseCommDevCfg(XElement commDevRoot, ref string reStr) { try { //1 PLC XElement plcXE = commDevRoot.Element("PLCCfg"); string addr = plcXE.Element("PLCAddr").Value.ToString(); plcRWList = new List <IPlcRW>(); if (plcXE.Element("PLCVendor").Value.ToString() == "三菱Q") { PLCRwMCPro plcObj = new PLCRwMCPro(EnumPlcCata.Qn, SysCfgModel.DB1Len, SysCfgModel.DB2Len); plcObj.NetProto = EnumNetProto.TCP;// EnumNetProto.UDP; plcObj.PlcID = 1; plcObj.ConnStr = addr; plcObj.StationNumber = 1; this.plcRWList.Add(plcObj); } else { reStr = "不可识别的PLC型号"; return(false); } //2 rfid XElement rfidRootXE = commDevRoot.Element("SgRfidCfg"); IEnumerable <XElement> rfidXES = rfidRootXE.Elements("RFID"); rfidList = new List <IrfidRW>(); bool tcpComm = false; if (rfidRootXE.Attribute("CommType").Value.ToString() == "TCPIP") { tcpComm = true; } foreach (XElement rfidXE in rfidXES) { byte id = byte.Parse(rfidXE.Attribute("id").Value.ToString()); string commAddr = rfidXE.Attribute("CommAddr").Value.ToString(); SygoleHFReaderIF.HFReaderIF readerIF = new SygoleHFReaderIF.HFReaderIF(); SgrfidRW rfidRW = new SgrfidRW(id); rfidRW.ReaderIF = readerIF; if (tcpComm) { rfidRW.ReaderIF.commType = SygoleHFReaderIF.EnumCommType.TCPNET; rfidRW.ReaderIF.readerIP = commAddr; rfidRW.ReaderIF.readerPort = 3001; } else { rfidRW.ReaderIF.ComPort = commAddr; } rfidList.Add(rfidRW); } //3 条码枪 XElement barcoderRootXE = commDevRoot.Element("BarScannerCfg"); IEnumerable <XElement> barcodes = barcoderRootXE.Elements("BarScanner"); foreach (XElement barcodeXE in barcodes) { byte id = byte.Parse(barcodeXE.Attribute("id").Value.ToString()); string commPort = barcodeXE.Attribute("CommAddr").Value.ToString(); BarcodeRWHonevor barcodeReader = new BarcodeRWHonevor(id); SerialPort comPort = new SerialPort(commPort); comPort.BaudRate = 115200; comPort.DataBits = 8; comPort.StopBits = StopBits.One; comPort.Parity = Parity.None; barcodeReader.ComPortObj = comPort; barcodeRWList.Add(barcodeReader); } //4 气密仪 XElement airdetectRootXE = commDevRoot.Element("AircheckMachineCfg"); IEnumerable <XElement> airdetects = airdetectRootXE.Elements("AircheckMachine"); airDetectList = new List <IAirlossDetectDev>(); foreach (XElement airdetectXE in airdetects) { byte id = byte.Parse(airdetectXE.Attribute("id").Value.ToString()); string commPort = airdetectXE.Attribute("CommAddr").Value.ToString(); AirDetectFL295CRW airdetectRW = new AirDetectFL295CRW(id, commPort); airDetectList.Add(airdetectRW); } //5 打标机 XElement printerRootXE = commDevRoot.Element("LabelPrinterCfg"); IEnumerable <XElement> printers = printerRootXE.Elements("LabelPrinter"); this.printerList = new List <IPrinterInfoDev>(); foreach (XElement printerXE in printers) { byte id = byte.Parse(printerXE.Attribute("id").Value.ToString()); string ip = printerXE.Attribute("ip").Value.ToString(); string db = printerXE.Attribute("dbName").Value.ToString(); short port = short.Parse(printerXE.Attribute("port").Value.ToString()); string userName = printerXE.Attribute("user").Value.ToString(); string pswd = printerXE.Attribute("pswd").Value.ToString(); PrinterRW printerRW = new PrinterRW(id, ip, port); string printerDBStr = string.Format("Data Source ={0};Initial Catalog={1};User ID={2};Password={3};", ip, db, userName, pswd); PrinterRWdb printerRWDb = new PrinterRWdb(printerDBStr); this.printerList.Add(printerRWDb); //this.printerList.Add(printerRW); } return(true); } catch (Exception ex) { reStr = ex.ToString(); return(false); } }