protected override bool UserInit() { #region >>>>读取模块配置信息,初始化工序Enable信息 if (GetPresInfomation()) { ShowInfo("加载参数成功"); } else { ShowInfo("加载参数失败,请确认是否选择参数配方"); } #endregion #region >>>>初始化仪表信息 PLC = InstrumentMgr.Instance.FindInstrumentByName("PLC") as QSerisePlc; lds1 = InstrumentMgr.Instance.FindInstrumentByName("LDS[6]") as LDS; lds2 = InstrumentMgr.Instance.FindInstrumentByName("LDS[7]") as LDS; #endregion bool bRet = PLC != null && lds1 != null && lds2 != null && Prescription != null; bRet = true; //dddd if (!bRet) { ShowInfo("初始化失败"); } else { } return(bRet); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (taskMonitor == null || taskMonitor.IsCompleted || taskMonitor.IsCanceled) //实时显示部分 { DataTable dtError = ConfigMgr.PLCErrorDataTable; QSerisePlc PLC = InstrumentMgr.Instance.FindInstrumentByName("PLC") as QSerisePlc; cts = new CancellationTokenSource(); taskMonitor = new Task(() => { while (!cts.IsCancellationRequested) { #if TEST int[] errorCodes = new int[] { 0x00FF, 0xFF00, 0x000F }; #else if (PLC != null) { int[] errorCodes = new int[] { PLC.ReadInt("R5011"), PLC.ReadInt("R5012"), PLC.ReadInt("R5013"), PLC.ReadInt("R5014"), PLC.ReadInt("R5015"), PLC.ReadInt("R5016"), PLC.ReadInt("R5017"), PLC.ReadInt("R5018") }; ShowPLCError(errorCodes, dtError); Thread.Sleep(300); } #endif } }, cts.Token); } taskMonitor.Start(); }
protected override bool UserInit() { bool bRet = false; #region >>>>读取模块配置信息,初始化工序Enable信息 if (GetPresInfomation()) { ShowInfo("加载参数成功"); } else { ShowInfo("加载参数失败,请确认是否选择参数配方"); } #endregion #region >>>>初始化仪表信息 Pw1000USB_1 = InstrumentMgr.Instance.FindInstrumentByName("PowerMeter[0]") as PowerMeter; Pw1000USB_2 = InstrumentMgr.Instance.FindInstrumentByName("PowerMeter[1]") as PowerMeter; lds1 = InstrumentMgr.Instance.FindInstrumentByName("LDS[0]") as LDS; lds2 = InstrumentMgr.Instance.FindInstrumentByName("LDS[1]") as LDS; BarcodeScanner1 = InstrumentMgr.Instance.FindInstrumentByName("SR1000[0]") as Keyence_SR1000; BarcodeScanner2 = InstrumentMgr.Instance.FindInstrumentByName("SR1000[1]") as Keyence_SR1000; PLC = InstrumentMgr.Instance.FindInstrumentByName("PLC") as QSerisePlc; #endregion LogExcel Fake_Barcode_Excel = new LogExcel(FILE_FAKE_BARCODE_FILE); Fake_Barcode_Excel.ExcelToDataTable(ref Fake_Barcode_Dt, "Sheet1"); string str = Fake_Barcode_Dt.Rows[0]["Barcode"].ToString(); str = Fake_Barcode_Dt.Rows[1]["Barcode"].ToString(); bRet = true || Pw1000USB_1 != null && Pw1000USB_2 != null && lds1 != null && lds2 != null && BarcodeScanner1 != null && BarcodeScanner2 != null && PLC != null; if (!bRet) { ShowInfo("初始化失败"); } return(bRet); }