/// <summary> /// 当前车号面板绘制 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void panCurrentCarNumber_Paint(object sender, PaintEventArgs e) { try { PanelEx panel = sender as PanelEx; int height = 12; // 绘制地感1 e.Graphics.DrawLine(this.InductorCoil1 ? redPen3 : greenPen3, 15, 1, 15, height); e.Graphics.DrawLine(this.InductorCoil1 ? redPen3 : greenPen3, 15, panel.Height - height, 15, panel.Height - 1); // 绘制地感2 e.Graphics.DrawLine(this.InductorCoil2 ? redPen3 : greenPen3, 25, 1, 25, height); e.Graphics.DrawLine(this.InductorCoil2 ? redPen3 : greenPen3, 25, panel.Height - height, 25, panel.Height - 1); // 绘制地感3 e.Graphics.DrawLine(this.InductorCoil3 ? redPen3 : greenPen3, 406, 1, 406, height); e.Graphics.DrawLine(this.InductorCoil3 ? redPen3 : greenPen3, 406, panel.Height - height, 406, panel.Height - 1); // 绘制地感4 e.Graphics.DrawLine(this.InductorCoil4 ? redPen3 : greenPen3, panel.Width - 15, 1, panel.Width - 15, height); e.Graphics.DrawLine(this.InductorCoil4 ? redPen3 : greenPen3, panel.Width - 15, panel.Height - height, panel.Width - 15, panel.Height - 1); } catch (Exception ex) { Log4Neter.Error("panCurrentCarNumber_Paint异常", ex); } }
private void timer2_Tick(object sender, EventArgs e) { // 界面不可见时,停止发送数据 if (!this.Visible) { return; } timer2.Stop(); // 2秒执行一次 timer2.Interval = 10000; try { BindGrid(); } catch (Exception ex) { Log4Neter.Error("timer2_Tick", ex); } finally { timer2.Start(); } }
/// <summary> /// 上传指纹数据到服务器共享文件夹 /// </summary> private void UploadCapturePicture() { string serverPath = commonDAO.GetCommonAppletConfigString("指纹识别数据存放路径"); if (string.IsNullOrEmpty(serverPath) || this.waitForUpload == null || this.waitForUpload.Count == 0) { return; } string fileName = string.Empty; do { fileName = this.waitForUpload.Dequeue(); if (!string.IsNullOrEmpty(fileName)) { try { if (File.Exists(serverPath)) { File.Copy(fileName, Path.Combine(serverPath, Path.GetFileName(fileName)), true); Log4Neter.Info(string.Format("上传指纹文件{0}", fileName)); } } catch (Exception ex) { Log4Neter.Error("上传指纹文件", ex); break; } } } while (fileName != null); }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; // 初始化-电子秤 if (IsUseWeight) { this.WbMinWeight = commonDAO.GetAppletConfigDecimal("电子秤最小重量"); // 电子秤 Hardwarer.Wber.OnStatusChange += new WB.XiangPing.Balance.XiangPing_Balance.StatusChangeHandler(Wber_OnStatusChange); Hardwarer.Wber.OnSteadyChange += new WB.XiangPing.Balance.XiangPing_Balance.SteadyChangeEventHandler(Wber_OnSteadyChange); Hardwarer.Wber.OnWeightChange += new WB.XiangPing.Balance.XiangPing_Balance.WeightChangeEventHandler(wber_OnWeightChange); if (!SelfVars.WeightOpen) { success = Hardwarer.Wber.OpenCom(commonDAO.GetAppletConfigInt32("电子秤串口"), commonDAO.GetAppletConfigInt32("电子秤波特率"), commonDAO.GetAppletConfigInt32("电子秤数据位"), commonDAO.GetAppletConfigInt32("电子秤停止位")); SelfVars.WeightOpen = success; } } timer1.Enabled = true; } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
void change() { if (newcmcstrainwatchs != null && newcmcstrainwatchs.Count != 0) { label1.Text = "车号:" + newcmcstrainwatchs[SelectedIndex].TheTrainWeightRecord.TrainNumber + " 位置:" + newcmcstrainwatchs[SelectedIndex].CatchType + " 时间:" + newcmcstrainwatchs[SelectedIndex].CatchTime.ToString("yyyy-MM-dd HH:mm:ss"); try { Image image = Image.FromStream(System.Net.WebRequest.Create(newcmcstrainwatchs[SelectedIndex].CatchDest).GetResponse().GetResponseStream()); Image newimage = pictureBox1.Image; Size _size = new Size(pictureBox1.Width, pictureBox1.Height); Bitmap _image = new Bitmap(image, _size); pictureBox1.Image = _image; } catch (Exception ex) { Log4Neter.Error("获取火车入厂抓拍照片", ex); } } else { CmcsTrainWeightRecord cmcstrainweightrecord = Dbers.GetInstance().SelfDber.Get <CmcsTrainWeightRecord>(Id); if (cmcstrainweightrecord != null) { label1.Text = "车号:" + cmcstrainweightrecord.TrainNumber + " 位置: 时间:-------------------"; } else { label1.Text = "车号:------- 位置: 时间:-------------------"; } } }
/// <summary> /// 写卡 /// </summary> /// <returns></returns> //private string WriteRf(string rf) //{ //byte SecNumber = 2;// Convert.ToByte(commonDAO.GetAppletConfigInt32("读卡器扇区")); //byte BlockNumber = 0;// Convert.ToByte(commonDAO.GetAppletConfigInt32("读卡器块区")); //if (ReadRwer.OpenRF()) //{ // ShowMessage("射频打开成功", eOutputType.Normal); //} //else //{ // ShowMessage("射频打开失败", eOutputType.Error); // return string.Empty; //} //if (ReadRwer.ChangeToISO14443A()) //{ // ShowMessage("切换到1443模式成功", eOutputType.Normal); //} //else //{ // ShowMessage("切换到1443模式失败", eOutputType.Error); // return string.Empty; //} //if (ReadRwer.Request14443A()) //{ // ShowMessage("获取卡类型成功", eOutputType.Normal); //} //else //{ // ShowMessage("获取卡类型失败", eOutputType.Error); // return string.Empty; //} //if (ReadRwer.Anticoll14443A()) //{ // ShowMessage("获取卡号成功", eOutputType.Normal); //} //else //{ // ShowMessage("获取卡号失败", eOutputType.Error); // return string.Empty; //} //if (ReadRwer.Select14443A()) //{ // ShowMessage("获取卡容量成功", eOutputType.Normal); //} //else //{ // ShowMessage("获取卡容量失败", eOutputType.Error); // return string.Empty; //} //if (ReadRwer.AuthKey14443A(SecNumber, BlockNumber)) //{ // ShowMessage("标签密钥验证成功", eOutputType.Normal); //} //else //{ // ShowMessage("标签密钥验证失败", eOutputType.Error); // return string.Empty; //} //if (ReadRwer.Write14443(rf, Convert.ToInt32(SecNumber), Convert.ToInt32(BlockNumber))) //{ // ShowMessage("编码:" + rf + "写卡成功", eOutputType.Normal); // string rf_new = ReadRwer.Byte16ToString(ReadRwer.RWRead14443A(SecNumber, BlockNumber)); // if (rf == rf_new) // { // ShowMessage("编码:" + rf + "读卡验证成功", eOutputType.Normal); // return rf_new; // } //} //return string.Empty; //} #endregion #region 设备初始化与卸载 /// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; // 初始化-电子秤 if (IsUseWeight) { this.WbMinWeight = commonDAO.GetAppletConfigDouble("电子秤最小重量"); // 电子秤 wber.OnStatusChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.StatusChangeHandler(Wber_OnStatusChange); wber.OnSteadyChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.SteadyChangeEventHandler(Wber_OnSteadyChange); success = wber.OpenCom(commonDAO.GetAppletConfigInt32("电子秤串口"), commonDAO.GetAppletConfigInt32("电子秤波特率"), commonDAO.GetAppletConfigInt32("电子秤数据位"), commonDAO.GetAppletConfigInt32("电子秤停止位")); } // IO控制器 ReadRwer.OnReceived += new RW.RF30WRQ80URS01.RF30WRQ80URS01Rwer.ReceivedEventHandler(Rwer_Received); ReadRwer.OnStatusChange += new RW.RF30WRQ80URS01.RF30WRQ80URS01Rwer.StatusChangeHandler(Rwer_OnStatusChange); success = ReadRwer.OpenCom(commonDAO.GetAppletConfigInt32("读卡器串口"), 115200, 8, (StopBits)1, (Parity)0); //if (!success) MessageBoxEx.Show("IO控制器连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); //this.iocControler = new IocControler(Hardwarer.Iocer); timer1.Enabled = true; } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
/// <summary> /// 执行远程命令 /// </summary> void ExecAppRemoteControlCmd() { // 获取最新的命令 CmcsAppRemoteControlCmd appRemoteControlCmd = commonDAO.GetNewestAppRemoteControlCmd(CommonAppConfig.GetInstance().AppIdentifier); if (appRemoteControlCmd != null) { if (appRemoteControlCmd.CmdCode == "控制道闸") { Log4Neter.Info("接收远程命令:" + appRemoteControlCmd.CmdCode + ",参数:" + appRemoteControlCmd.Param); if (appRemoteControlCmd.Param.Equals("Gate1Up", StringComparison.CurrentCultureIgnoreCase)) { this.iocControler.Gate1Up(); } else if (appRemoteControlCmd.Param.Equals("Gate1Down", StringComparison.CurrentCultureIgnoreCase)) { this.iocControler.Gate1Down(); } else if (appRemoteControlCmd.Param.Equals("Gate2Up", StringComparison.CurrentCultureIgnoreCase)) { this.iocControler.Gate2Up(); } else if (appRemoteControlCmd.Param.Equals("Gate2Down", StringComparison.CurrentCultureIgnoreCase)) { this.iocControler.Gate2Down(); } // 更新执行结果 commonDAO.SetAppRemoteControlCmdResultCode(appRemoteControlCmd, eEquInfCmdResultCode.成功); } } }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; success = Rwer.OpenNetPort(ThisAppConfig.GetInstance().HFReaderIP, ThisAppConfig.GetInstance().HFReaderPort); if (success) { ShowMessage("读卡器初始化成功", eOutputType.Important); } else { ShowMessage("读卡器初始化失败", eOutputType.Error); } timer1.Enabled = true; } catch (Exception ex) { ShowMessage("设备初始化失败" + ex.Message, eOutputType.Error); Log4Neter.Error("设备初始化", ex); } }
private void timer2_Tick(object sender, EventArgs e) { // 界面不可见时,停止发送数据 if (!this.Visible) { return; } timer2.Stop(); // 2秒执行一次 timer2.Interval = 10000; try { BindGD_WF(superGridControl1, "#2"); BindGD_WF(superGridControl2, "#4"); BindGD_YF(superGridControl3, "#1"); BindGD_YF(superGridControl4, "#5"); CountCH(); } catch (Exception ex) { Log4Neter.Error("timer2_Tick", ex); } finally { timer2.Start(); } }
/// <summary> /// 更新LED动态区域 /// </summary> /// <param name="value1">第一行内容</param> /// <param name="value2">第二行内容</param> private void UpdateLedShow(string value1 = "", string value2 = "") { FrmDebugConsole.GetInstance().Output("更新LED1:|" + value1 + "|" + value2 + "|"); if (!this.LED1ConnectStatus) { return; } if (this.LED1PrevLedFileContent == value1 + value2) { return; } if (LED1m_bSendBusy == false) { LED1m_bSendBusy = true; bool nResult = led.UpdateLED(value1 + " " + value2); if (!nResult) { Log4Neter.Error("更新LED动态区域", new Exception("更新LED动态区域")); } LED1m_bSendBusy = false; } this.LED1PrevLedFileContent = value1 + value2; }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; ReadRwer.OnStatusChange += new HFReaderRwer.StatusChangeHandler(Rwer_OnStatusChange); Rwer_OnStatusChange(ReadRwer.Status); // 初始化-读卡器 success = ReadRwer.OpenNetPort(commonDAO.GetAppletConfigString("读卡器网口"), 6000); //success = ReadRwer.OpenNetPort("192.168.70.30",6000); // 初始化-电子秤 if (IsUseWeight) { this.WbMinWeight = commonDAO.GetAppletConfigDouble("电子秤最小重量"); // 电子秤仪表1 wber.OnStatusChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.StatusChangeHandler(Wber_OnStatusChange); wber.OnSteadyChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.SteadyChangeEventHandler(Wber_OnSteadyChange); success = wber.OpenCom(commonDAO.GetAppletConfigInt32("电子秤串口"), commonDAO.GetAppletConfigInt32("电子秤波特率"), commonDAO.GetAppletConfigInt32("电子秤数据位"), commonDAO.GetAppletConfigInt32("电子秤停止位")); } timer1.Enabled = true; } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
/// <summary> /// 读卡、车号识别任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); timer1.Interval = 2000; try { switch (this.CurrentFlowFlag) { case eFlowFlag.等待执行: CurrentCmdResultCode = beltSamplerDAO.GetSampleCmdResult(CurrentSampleCMD.Id); if (CurrentCmdResultCode == eEquInfCmdResultCode.成功) { this.CurrentFlowFlag = eFlowFlag.执行完毕; } break; case eFlowFlag.执行完毕: ResetBuyFuel(); break; } } catch (Exception ex) { Log4Neter.Error("timer1_Tick", ex); } finally { timer1.Start(); } timer1.Start(); }
private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); try { switch (this.CurrentFlowFlag) { case eFlowFlag.等待扫码: break; case eFlowFlag.重量校验: #region if (Hardwarer.Wber.Status && Hardwarer.Wber.Weight > this.WbMinWeight && WbSteady) { this.CurrentFlowFlag = eFlowFlag.等待校验; } #endregion break; case eFlowFlag.等待校验: #region if (czyHandlerDAO.UpdateRCSampleBarrelHandWeight(this.rCSampleBarrel.Id, Hardwarer.Wber.Weight, SelfVars.LoginUser.UserName)) { ShowMessage("校验成功,重量:" + Hardwarer.Wber.Weight.ToString() + "KG", eOutputType.Normal); // 所有桶扫描完后进入下一流程 if (this.IsScanedRCSampleBarrelId.Count == this.brotherRCSampleBarrels.Count) { ShowMessage("该环节样桶已全部校验完毕!", eOutputType.Normal); txtInputSampleCode.ResetText(); } else { txtInputSampleCode.ResetText(); } this.CurrentFlowFlag = eFlowFlag.等待扫码; } else { ShowMessage("校验失败或者已校验,请联系管理员", eOutputType.Error); this.CurrentFlowFlag = eFlowFlag.等待校验; } #endregion break; } } catch (Exception ex) { ShowMessage("Timer1运行异常" + ex.Message, eOutputType.Error); Log4Neter.Error("Timer1运行异常", ex); } timer1.Start(); }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; Hardwarer.ReadRwer.OnStatusChange += new HFReaderRwer.StatusChangeHandler(Rwer_OnStatusChange); Rwer_OnStatusChange(Hardwarer.ReadRwer.Status); if (!SelfVars.RfReadOpen) { // 初始化-读卡器 success = Hardwarer.ReadRwer.OpenNetPort(commonDAO.GetAppletConfigString("读卡器IP"), commonDAO.GetAppletConfigInt32("读卡器端口")); SelfVars.RfReadOpen = success; } // 初始化-电子天平 if (IsUseWeight) { this.WbMinWeight = commonDAO.GetAppletConfigDecimal("电子天平最小重量"); Hardwarer.Wber_min.OnStatusChange += new WB.XiangPing.Balance.XiangPing_Balance.StatusChangeHandler(Wber_OnStatusChange); Hardwarer.Wber_min.OnSteadyChange += new WB.XiangPing.Balance.XiangPing_Balance.SteadyChangeEventHandler(Wber_OnSteadyChange); Hardwarer.Wber_min.OnWeightChange += new WB.XiangPing.Balance.XiangPing_Balance.WeightChangeEventHandler(wber_OnWeightChange); if (!SelfVars.WeightMinOpen) { success = Hardwarer.Wber_min.OpenCom(commonDAO.GetAppletConfigInt32("电子天平串口"), commonDAO.GetAppletConfigInt32("电子天平波特率"), commonDAO.GetAppletConfigInt32("电子天平数据位"), commonDAO.GetAppletConfigInt32("电子天平停止位")); SelfVars.WeightMinOpen = success; } } } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
/// <summary> /// 定时请求数据及页面刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); try { //10秒滚动一页,完成一次后刷新数据 if (DateTime.Now.Second % 3 == 0) { if (ScrollContent()) { LoadTotalInfo(); LoadContent(); } } } catch (Exception ex) { Log4Neter.Error("timer1_Tick", ex); } finally { timer1.Start(); } }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; // 初始化-读卡器 rwer.OnStatusChange += new HFReaderRwer.StatusChangeHandler(Rwer_OnStatusChange); success = rwer.OpenNetPort(commonDAO.GetAppletConfigString("读卡器IP"), commonDAO.GetAppletConfigInt32("读卡器端口")); if (success) { Rwer_OnStatusChange(true); } else { Rwer_OnStatusChange(false); } // 初始化-电子秤 if (IsUseWeight) { this.WbMinWeight = commonDAO.GetAppletConfigDouble("电子秤最小重量"); wber.OnStatusChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.StatusChangeHandler(Wber_OnStatusChange); wber.OnSteadyChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.SteadyChangeEventHandler(Wber_OnSteadyChange); success = wber.OpenCom(commonDAO.GetAppletConfigInt32("电子秤串口"), commonDAO.GetAppletConfigInt32("电子秤波特率"), commonDAO.GetAppletConfigInt32("电子秤数据位"), commonDAO.GetAppletConfigInt32("电子秤停止位")); } } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; // 初始化-电子秤 if (IsUseWeight) { this.WbMinWeight = commonDAO.GetAppletConfigDouble("电子秤最小重量"); this.BarrelWeight = commonDAO.GetAppletConfigDouble("人工样桶重量"); wber.OnStatusChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.StatusChangeHandler(wber_OnStatusChange); wber.OnSteadyChange += new WB.TOLEDO.IND231.TOLEDO_IND231Wber.SteadyChangeEventHandler(wber_OnSteadyChange); success = wber.OpenCom(commonDAO.GetAppletConfigInt32("电子秤串口"), commonDAO.GetAppletConfigInt32("电子秤波特率"), commonDAO.GetAppletConfigInt32("电子秤数据位"), commonDAO.GetAppletConfigInt32("电子秤停止位")); } timer1.Enabled = true; } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
/// <summary> /// 输出异常信息 /// </summary> /// <param name="text"></param> /// <param name="ex"></param> void OutputError(string text, Exception ex) { isExecuted = true; this.rTxtOutputer.Output(text + Environment.NewLine + ex.Message, eOutputType.Error); Log4Neter.Error(text, ex); }
/// </summary> /// <param name="text"></param> /// <param name="ex"></param> void OutputError(string text, Exception ex) { this.rTxtOutputer.Output(text + Environment.NewLine + ex.Message, eOutputType.Error); Log4Neter.Error(text, ex); /// <summary> /// 输出异常信息 }
/// <summary> /// 输出当前运行信息 /// </summary> /// <param name="output"></param> private void OutputRunInfo(string output) { this.InvokeEx(() => { lblRunInfo.Text = "> " + output; Log4Neter.Info(this.trainTipper.EquipmentName + " - 运行输出:" + output); }); }
private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); try { } catch (Exception ex) { Log4Neter.Error("定时处理timer_Tick", ex); } timer1.Start(); }
public void Output(string message) { try { Log4Neter.Info(message); rtxtOutput.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " - " + message + Environment.NewLine); rtxtOutput.ScrollToCaret(); } catch { } }
/// <summary> /// 保存运输记录 /// </summary> /// <returns></returns> bool SaveBuyFuelTransport() { CmcsAutotruck autoTruck = commonDAO.SelfDber.Entity <CmcsAutotruck>("where CarNumber=:CarNumber", new { CarNumber = this.txt_CarNumber.Text }); if (autoTruck == null) { autoTruck = new CmcsAutotruck() { CarNumber = this.txt_CarNumber.Text }; commonDAO.SelfDber.Insert(autoTruck); } this.CurrentAutotruck = autoTruck; try { if (this.CurrentBuyFuelTransport == null) { // 查找该车未完成的运输记录 CmcsUnFinishTransport unFinishTransport = carTransportDAO.GetUnFinishTransportByAutotruckId(this.CurrentAutotruck.Id, eCarType.入场煤.ToString()); if (unFinishTransport != null) { this.CurrentBuyFuelTransport = commonDAO.SelfDber.Get <CmcsBuyFuelTransport>(unFinishTransport.TransportId); } else { CmcsBuyFuelTransport transport = new CmcsBuyFuelTransport(); QueuerDAO.GetInstance().JoinQueueBuyFuelTransport(autoTruck, this.SelectedMine_BuyFuel, this.SelectedFuelKind_BuyFuel, Convert.ToDecimal(this.txtTicketWeight_BuyFuel.Value), DateTime.Now, "", ref transport); this.CurrentBuyFuelTransport = transport; } } this.CurrentBuyFuelTransport.KgWeight = (decimal)this.txtKgWeight_BuyFuel.Value; this.CurrentBuyFuelTransport.KsWeight = (decimal)this.txtKsWeight_BuyFuel.Value; this.CurrentBuyFuelTransport.DeductWeight = (decimal)this.txtKgWeight_BuyFuel.Value + (decimal)this.txtKsWeight_BuyFuel.Value; if (weighterDAO.SaveBuyFuelTransportHand(this.CurrentBuyFuelTransport, (decimal)Hardwarer.Wber.Weight, DateTime.Now, CommonAppConfig.GetInstance().AppIdentifier)) { this.CurrentBuyFuelTransport = commonDAO.SelfDber.Get <CmcsBuyFuelTransport>(this.CurrentBuyFuelTransport.Id); LoadTodayUnFinishBuyFuelTransport(); LoadTodayFinishBuyFuelTransport(); return(true); } } catch (Exception ex) { MessageBoxEx.Show("保存失败\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Log4Neter.Error("保存运输记录", ex); } return(false); }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; Hardwarer.Iocer.OnStatusChange += new CupCoard.DJ.CupCoard_DJ.StatusChangeHandler(OnReceiveStatus); success = Hardwarer.Iocer.OpenCom(commonDAO.GetAppletConfigInt32("存样柜串口"), commonDAO.GetAppletConfigInt32("存样柜波特率")); } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
public void Rwer1_OnReadSuccess(string carnumber) { InvokeEx(() => { if (carnumber != "无车牌" && this.CurrentFlowFlag == eFlowFlag.等待车辆) { passCarQueuer.Enqueue(carnumber); this.CurrentFlowFlag = eFlowFlag.验证车辆; timer1_Tick(null, null); //UpdateLedShow(carnumber); Log4Neter.Info(string.Format("车号识别1识别到车号:{0}", carnumber)); } }); }
/// <summary> /// 关闭串口 /// 成功返回True;失败返回False; /// </summary> /// <returns></returns> public void CloseCom() { try { timer1.Enabled = false; serialPort.DataReceived -= new SerialDataReceivedEventHandler(serialPort_DataReceived); serialPort.Close(); } catch (Exception ex) { Log4Neter.Error(this.FacilityNumber + "关闭串口", ex); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); timer1.Interval = 2000; try { switch (this.CurrentFlowFlag) { case eFlowFlag.等待执行: if (!IsResultSample) { CurrentCmdResultCode = beltSamplerDAO.GetSampleCmdResult(CurrentSampleCMD.Id); if (CurrentCmdResultCode == eEquInfCmdResultCode.成功) { this.rTxtOutputer.Output("采样命令执行成功", eOutputType.Success); this.CurrentFlowFlag = eFlowFlag.执行完毕; } else if (CurrentCmdResultCode == eEquInfCmdResultCode.失败) { this.rTxtOutputer.Output("采样命令执行失败", eOutputType.Warn); List <InfEquInfHitch> list_Hitch = commonDAO.GetEquInfHitch(DateTime.Now.AddMinutes(-1), DateTime.Now.AddMinutes(1), this.CurrentSampleMachine.EquipmentCode); foreach (InfEquInfHitch item in list_Hitch) { this.rTxtOutputer.Output("采样机:" + item.HitchDescribe, eOutputType.Error); } } IsResultSample = CurrentCmdResultCode != eEquInfCmdResultCode.默认; } break; case eFlowFlag.执行完毕: ResetBuyFuel(); break; } } catch (Exception ex) { Log4Neter.Error("timer1_Tick", ex); } finally { timer1.Start(); } timer1.Start(); }
/// <summary> /// 发送采样计划,若存在则更新 /// </summary> /// <param name="view_TrainTipperQueue"></param> /// <returns></returns> public bool SendSamplePlan(View_TrainTipperQueue view_TrainTipperQueue) { CmcsInFactoryBatch inFactoryBatch = Dbers.GetInstance().SelfDber.Get <CmcsInFactoryBatch>(view_TrainTipperQueue.InFactoryBatchId); if (inFactoryBatch == null) { throw new ArgumentNullException("inFactoryBatchId", "未找到Id=" + view_TrainTipperQueue.InFactoryBatchId + "的批次"); } CmcsFuelKind fuelKind = Dbers.GetInstance().SelfDber.Get <CmcsFuelKind>(inFactoryBatch.FuelKindId); List <View_TrainTipperQueue> list = trainTipperDAO.GetView_TrainTipperQueueBy(view_TrainTipperQueue.TrainSampleSchemeId); InfBeltSamplePlan oldBeltSamplePlan = Dbers.GetInstance().SelfDber.Entity <InfBeltSamplePlan>("where InFactoryBatchId=:InFactoryBatchId and SampleCode=:SampleCode", new { InFactoryBatchId = view_TrainTipperQueue.InFactoryBatchId, SampleCode = view_TrainTipperQueue.YuSampleCode }); if (oldBeltSamplePlan == null) { Log4Neter.Info(this.trainTipper.EquipmentName + " - 向[" + this.trainBeltSampler.EquipmentCode + "]发送采样计划,采样码:" + view_TrainTipperQueue.YuSampleCode); return(Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlan>(new InfBeltSamplePlan { DataFlag = 0, InterfaceType = this.trainBeltSampler.InterfaceType, InFactoryBatchId = view_TrainTipperQueue.InFactoryBatchId, SampleCode = view_TrainTipperQueue.YuSampleCode, FuelKindName = fuelKind != null ? fuelKind.Name : string.Empty, CarCount = list.Count, Mt = 0, TicketWeight = list.Sum(a => a.TicketQty), SampleType = eEquInfSampleType.到集样罐.ToString(), GatherType = commonDAO.GetCommonAppletConfigString(this.trainBeltSampler.EquipmentCode + "集样方式") }) > 0); } else { Log4Neter.Info(this.trainTipper.EquipmentName + " - 向[" + this.trainBeltSampler.EquipmentCode + "]更新采样计划,采样码:" + view_TrainTipperQueue.YuSampleCode); oldBeltSamplePlan.DataFlag = 0; oldBeltSamplePlan.FuelKindName = fuelKind != null ? fuelKind.Name : string.Empty; oldBeltSamplePlan.CarCount = list.Count; oldBeltSamplePlan.Mt = 0; oldBeltSamplePlan.TicketWeight = list.Sum(a => a.TicketQty); oldBeltSamplePlan.SampleType = eEquInfSampleType.到集样罐.ToString(); oldBeltSamplePlan.GatherType = commonDAO.GetCommonAppletConfigString(this.trainBeltSampler.EquipmentCode + "集样方式"); return(Dbers.GetInstance().SelfDber.Update(oldBeltSamplePlan) > 0); } }
/// <summary> /// 开始翻车 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStartTurnover_Click(object sender, EventArgs e) { Log4Neter.Info(this.trainTipper.EquipmentName + " - 开始翻车"); if (this.view_TrainTipperQueue_DF.Count == 0) { MessageBoxEx2Show("翻车队列为空,请查询出队列后再运行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } btnStartTurnover.Enabled = false; btnAddTrainCarriagePass.Enabled = true; dtiptStartArriveTime.Enabled = false; dtiptEndArriveTime.Enabled = false; CreateMainTask(); }
/// <summary> /// 初始化外接设备 /// </summary> private void InitHardware() { try { bool success = false; wber.OnStatusChange += new WB.Sartorius.Balance.Sartorius_Balance.StatusChangeHandler(wber_OnStatusChange); wber.OnWeightChange += new WB.Sartorius.Balance.Sartorius_Balance.WeightChangeEventHandler(wber_OnWeightChange); success = wber.OpenCom(commonDAO.GetAppletConfigInt32(string.Format("{0}串口", MachineCode)), commonDAO.GetAppletConfigInt32(string.Format("{0}波特率", MachineCode)), commonDAO.GetAppletConfigInt32(string.Format("{0}数据位", MachineCode)), commonDAO.GetAppletConfigInt32(string.Format("{0}校验位", MachineCode))); timer1.Enabled = true; } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }