| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045 |
- using CarMeterSystem.OptionCls;
- using CarMeterSystem;
- using com.hnshituo.core.webapp.vo;
- using Common;
- using iCore.Rtdb.RtdbTable;
- using MeterConditionLibrary;
- using MeterModelLibrary;
- using MeterModuleLibrary.uc;
- using MeterPlugInLibrary;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- namespace CarMeterMonitor
- {
- public partial class fromContect : Form
- {
- public fromContect()
- {
- InitializeComponent();
- }
- private Log l = Log.GetInstance();
- private Print printClass = new Print();//打印
- //内存表
- private MemoryTableDataSocket MemoClass = new MemoryTableDataSocket("");
- //实时表数据采集
- private DataCollectionControl collection = new DataCollectionControl();
- //图片控制器含图片压缩及上传curl
- private ImageCurlControl imageCurlControl = new ImageCurlControl();
- //与监控界面对接的表
- private MeterWorkMonitorService meterWorkMonitor = new MeterWorkMonitorService();
- //零点报警表
- private meterworkzeroalarmservice zeroAlarmService = new meterworkzeroalarmservice();
- //车号修正
- private CarNoModfiy modfiy = new CarNoModfiy();
- /// <summary>
- /// 这个是保存前一次采集中的车号信息
- /// </summary>
- private string preCarNo = "";
- //验证对射
- private validParkStatus valid = new validParkStatus();
- //语音播报
- private VoicePlay vicPlayClass = new VoicePlay();
- //扫码枪
- private SweepCode sweepCodeClass = new SweepCode();
- private LED_Control led_controler = null;
- //监控表操作
- private MeterMonitorWeightService monitorWeightService = new MeterMonitorWeightService();
- //历史皮操作
- private MeterBaseHisTareDataService hisTareDataService = new MeterBaseHisTareDataService();
- /// <summary>
- /// 欢迎界面
- /// </summary>
- private frmWelcome_Jisco frmWelcome = new frmWelcome_Jisco();//欢迎
- private int startCar = 0;
- private int startWeight = 0;
- private DateTime startTime;
- private DateTime endTime;
- /// <summary>
- /// 基础数据载入
- /// </summary>
- private BaseDbCls bd = new BaseDbCls();
- //扫码修正车号标识
- private bool codeFlag = false;
- private List<ucBusinessType> lu = new List<ucBusinessType>();
- private bool isVoiceDownCar = false;//车上人员请下车播放一次
- private bool isShowFrmWelcome = false; //是否显示欢迎界面
- private bool isOpened = false;//是否已经打开了扫码计量界面
- private void fromContect_Load(object sender, EventArgs e)
- {
- //*
- try
- {
- //this.Hide();
- LoginCls lg = new LoginCls();
- timer1.Start();
- //2021年6月21日 杨秀东添加
- if (isShowFrmWelcome)
- {
- frmWelcome.Show();
- frmWelcome.Visible = true;
- }
- if (lg.LoginIn())
- {
- if (bd.setBaseDb() && bd.getBaseDb())
- {
- if (!string.IsNullOrEmpty(PbCache.sportInfo.ledIp))
- {
- led_controler = new LED_Control(PbCache.sportInfo.ledIp);
- }
- //调用该方法时已赋值 test git 测试git推送代码123;456
- RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
- if (!rm.Succeed)
- {
- l.WriteLog(1, "载入监控表数据异常");
- return;
- }
- else if (rm.Data != null && rm.Data.Count > 0)
- {
- if (string.IsNullOrEmpty(PbCache.collect_no))
- {
- PbCache.collect_no = rm.Data[0].collectionCode;
- MemoClass = new MemoryTableDataSocket(PbCache.collect_no);
- }
- }
- else
- {
- l.WriteLog(1, "为配置监控数据");
- return;
- }
- //若未校秤的话,也不允许计量
- //载入界面业务按钮
- if (PbCache.businessType != null && PbCache.businessType.Count > 0)
- {
- foreach (ComBaseInfo info in PbCache.businessType)
- {
- ucBusinessType uc = new ucBusinessType();
- switch (info.baseCode)
- {
- case "001006003":
- uc.setControl(info.baseName, info.memo, info.baseCode);
- break;
- case "001006001":
- case "001006002":
- uc.setControl(info.baseName, info.memo, info.baseCode);
- break;
- default:
- uc.setControl(info.baseName, info.memo, info.baseCode);
- break;
- }
- uc.Dock = DockStyle.Top;
- //uc.setControl("","","",);
- uc.ucEvent += new EventHandler(ucEvents);
- lu.Add(uc);
- //panel7.Controls.Add(uc);
- }
- }
- //开启基础进程
- l.WriteLog(0, "系统登录成功");
- collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集及扫码信息
- collection.Start(PbCache.sportInfo.baseSpotNo, PbCache.sportInfo.baseSpotName);
- imageCurlControl.Start(); //图片上传线程
- sweepCodeClass.StartThreadSweep(); //扫码线程
- }
- else
- {
- l.WriteLog(0, "系统登录失败");
- }
- }
- else
- {
- l.WriteLog(0, "按IP地址找不到计量点信息,系统登录失败");
- }
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "系统加载失败:" + ex.Message);
- }
- //*/
- }
- /// <summary>
- /// 直接打开扫码计量界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (!isOpened && PbCache.collect?.weight > 500)
- {
- isOpened = true;
- PbCache.bussinessTypeName = "";
- PbCache.bussinessTypeCode = "";
- //frmOneYardToEnd fcc = new frmOneYardToEnd();
- //fcc.ShowDialog();
- }
- }
- #region
- //*
- /// <summary>
- /// 委托的方式调用控件的点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ucEvents(object sender, EventArgs e)
- {
- Control control = (Control)sender;
- ucBusinessType um = control.Parent.Parent as ucBusinessType;
- try
- {
- switch (control.Name)
- {
- case "btnContext":
- case "btnPurchase":
- {
- PbCache.bussinessTypeName = um._bussiness == null ? "" : um._bussiness;
- PbCache.bussinessTypeCode = um._code;
- switch (um._code)
- {
- case "001006003":
- frmInternalTransport frm = new frmInternalTransport();
- frm.ShowDialog();
- break;
- /*
- case "001006001":
- case "001006002":
- frmCarSalePurchase frmCar = new frmCarSalePurchase();
- frmCar.ShowDialog();
- break;
- //*/
- default:
- frmCarSalePurchase frmCar = new frmCarSalePurchase();
- frmCar.ShowDialog();
- break;
- }
- };
- break;
- default: break;
- }
- }
- catch (Exception ex)
- {
- //MessageBox.Show("操作异常:" + ex.Message);
- }
- }
- //*/
- #endregion
- #region
- private void setThisVis(bool visb)
- {
- if (this.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(setThisVis);
- Invoke(action, new object[] { visb });
- }
- else
- {
- if (this.Visible != visb)
- {
- this.Visible = visb;
- }
- }
- }
- #endregion
- #region
- private void setWelecomeVis(bool visb)
- {
- if (!isShowFrmWelcome) return;//2021年6月21日 杨秀东添加
- if (frmWelcome.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(setWelecomeVis);
- Invoke(action, new object[] { visb });
- }
- else
- {
- if (frmWelcome.Visible != visb)
- {
- frmWelcome.Visible = visb;
- frmWelcome.setLogin();
- }
- }
- //*/
- }
- #endregion
- private int iCount = 0, iHodeTime = 0;
- private bool flagCarMonit = false;//车号修正
- private bool bEditCar = false; //手动修正车号
- private bool isOpenMeter = false; //是否已打开计量界面,若已经打开则这里关于超量程及红外的语音将停止播报
- private string firstCode = "";//上次扫码的信息
- private string ledTxt = "";
- private bool isLedWrite = false;//是否写入一次LED
- private string sPreNo = ""; //记录重量曲线变化
- private int preWgt = 0;//前一次重量,用于重量曲线
- private string sCarNo = "";
- private int iCountPark = 0;
- private string editCarNo = "";
- /// <summary>
- /// 数据采集
- /// </summary>
- /// <param name="o"></param>
- /// <param name="e"></param>
- private void EventData(object o, DataCollectionArgs e)
- {
- //这里每隔0.5秒执行一次
- try
- {
- #region 扫码信息
- sweepCodeClass.StrState = e.weightStatus + ""; //重量状态信息;当StrState= 0时,获取扫码信息,StrState= 2时将扫码信息置位“”空;其他状态不处理
- if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
- {
- codeFlag = false;
- if (string.IsNullOrEmpty(PbCache.strCode))
- {
- firstCode = "";
- PbCache.strCode = "";
- l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
- }
- }
- else
- {
- ////日期2021年12月22日:重复扫码,取前面12位
- //if (sweepCodeClass.StrCode.Length > 15)
- //{
- // // todo: 加入车号截取逻辑
- // sweepCodeClass.StrCode = sweepCodeClass.StrCode.Substring(0,12);
- //}
- //if (firstCode != sweepCodeClass.StrCode || string.IsNullOrEmpty(PbCache.strCode))
- //{
- // l.WriteLog(12, "主线程扫码值赋值;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode前值为:" + PbCache.strCode);
- // PbCache.strCode = sweepCodeClass.StrCode;
- // firstCode = PbCache.strCode;
- //}
- l.WriteLog(12, "测试扫码值" + PbCache.strCode);
- PbCache.collect.carno = sweepCodeClass.StrCode;
- codeFlag = true;
- }
- #endregion 扫码信息
- #region 秤上无车10分钟获取一次基础数据
- if (iCount < 1200)
- {
- iCount++;
- }
- else
- {
- try
- {
- //秤上没有车时,每隔10分钟获取一次基础数据
- if (e.weight < 500)
- {
- if (bd.setBaseDb())
- {
- l.WriteLog(0, "十分钟获取基础数据成功");
- }
- else
- {
- l.WriteLog(0, "十分钟获取基础数据失败");
- }
- iCount = 0;
- }
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
- iCount = 0;
- }
- }
- #endregion
- #region 每10秒写入一次当前时间
- if (iCount % 20 == 0)
- {
- //更新在线时间
- RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo, lastTime = DateTime.Now });
- if (!rms.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常:写入时间异常");
- }
- }
- #endregion
- #region
- //一旦界面锁定则不采集数据
- if (!PbCache.isLockFrm)
- {
- PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
- PbCache.collect.weight = e.weight;
- PbCache.collect.weightStatus = e.weightStatus;
- PbCache.collect.parkStatus = e.parkStatus;
- PbCache.collect.datetime = e.datetime;
- PbCache.collect.licType = e.licType;
- }
- //*/
- // 更新监控表
- doLive();
- //重量大于500的情况下
- if (e.weight > 500)
- {
- if (startWeight == 0)
- {
- startTime = DateTime.Now;
- startWeight = 1;
- }
- if (startCar == 0 && e.vdioCarNos != "")
- {
- WriteText(0, "当前采集车号:" + e.vdioCarNos);
- startCar = 1;
- }
- if (startWeight == 1 && PbCache.collect.weightStatus == 0)
- {
- endTime = DateTime.Now;
- startWeight = 2;
- TimeSpan secondSpan = new TimeSpan(endTime.Ticks - startTime.Ticks);
- WriteText(1, "开始时间:" + startTime.ToString("yyyy-MM-dd HH:mm:ss:fff") + ",结束时间:" + endTime.ToString("yyyy-MM-dd HH:mm:ss:fff") + ",时间差:" + secondSpan.TotalSeconds + "秒" + ",重量:" + e.weight);
- }
- if (PbCache.dtStartTime == null)
- PbCache.dtStartTime = DateTime.Now;
- isLedWrite = true;
- #region 车上人员请下车
- try
- {
- //界面未锁定的情况下,有车号,如果重量稳定了,停车线验证通过,未超量程的情况下,则按钮可用
- if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno) && PbCache.collect.weightStatus == 0 && PbCache.monitorResult.valid_park_status && PbCache.collect.weight < PbCache.range.upperRange)
- {
- if (!isVoiceDownCar)
- {
- isVoiceDownCar = true;
- vicPlayClass.GetVoicePlay("车上人员请下车", PbCache.collect.carno);
- }
- }
- }
- catch { }
- #endregion
- setWelecomeVis(false);
- //每隔1秒刷一次计量实时监控表数据值
- if (iCount % 2 == 0)
- {
- //调用该方法时已赋值
- RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
- if (!rm.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常419:" + rm.ResultMessage);
- }
- else
- {
- if (rm.Data != null && rm.Data.Count > 0)
- {
- PbCache.monitor = rm.Data[0];
- if (string.IsNullOrEmpty(PbCache.collect_no))
- {
- PbCache.collect_no = rm.Data[0].collectionCode;
- }
- if (ledTxt != rm.Data[0].ledWriter && rm.Data[0].ledWriter != "")
- {
- //调用LED信息写入******************************
- ledTxt = rm.Data[0].ledWriter;
- }
- if (string.IsNullOrEmpty(ledTxt))
- {
- ledTxt = "欢迎使用酒钢汽车衡智能计量系统!";
- }
- }
- }
- #region 2021-03-29
- #region 摄像头当前采集的车号与上次采集的不一样且当前未勾选不验证,且当前车号未进行手动修正的情况下
- if (preCarNo != e.carno && PbCache.monitor != null && PbCache.monitor.validCarno != "0" && !bEditCar)
- {
- flagCarMonit = false;
- }
- preCarNo = e.carno;
- #endregion
- if (!flagCarMonit)
- {
- sCarNo = e.carno;
- }
- //*
- //有车号,且重量稳定的情况下,只修正一次车号
- if (!string.IsNullOrEmpty(e.carno) && e.weightStatus == 0 && !flagCarMonit && PbCache.monitor != null && PbCache.monitor.carMonitor == "1" && PbCache.monitor.carMonitorLvl > 0)
- {
- flagCarMonit = true;
- string methods = "";
- for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
- {
- methods += "CarNoTrustCorrect" + i + ",";
- }
- editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
- sCarNo = editCarNo;
- //mwUpdate
- }
- //勾选了不验证车号的情况
- if (PbCache.monitor.validCarno == "0")
- {
- flagCarMonit = true;
- }
- #endregion
- #region 每隔1秒写入一次重量曲线
- try
- {
- if (preWgt != e.weight)
- {
- preWgt = e.weight;
- sPreNo = PbCache.sportInfo.baseSpotNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
- monitorWeightService.doAddWf(new MeterMonitorWeight
- {
- weightNo = sPreNo,
- baseSpotNo = PbCache.sportInfo.baseSpotNo,
- baseSpotName = PbCache.sportInfo.baseSpotName,
- collectWeight = e.weight + "",
- collectStartTime = PbCache.dtStartTime.Value,
- collectEndTime = DateTime.Now,
- spotTypeNo = "001002001",
- spotTypeName = "汽车衡",
- actualFirstNo = PbCache.actualFirstNo
- });
- }
- else
- {
- if (!string.IsNullOrEmpty(sPreNo))
- {
- monitorWeightService.doUpdateWf(new MeterMonitorWeight
- {
- weightNo = sPreNo,
- collectEndTime = DateTime.Now
- });
- }
- }
- }
- catch { }
- #endregion
- #region 停留超时
- iHodeTime++;
- MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
- mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
- mwUpdate.editCar = editCarNo;
- if (PbCache.holdTime != null && PbCache.holdTime.Count > 0)
- {
- if (PbCache.holdTime[0].retentionTime != null)
- {
- if (PbCache.holdTime[0].retentionTime.Value < iHodeTime)
- {
- PbCache.isOvertimeAlarm = true; //是否超时报警
- mwUpdate.stopOverTime = "1"; //写入一次停留超时
- //mwUpdate.isHelp = "1";//派位
- //mwUpdate.isTakeOver = "1";
- iHodeTime = 99999;//不再增长避免超出
- }
- }
- }
- #endregion
- #region RFID识别车号信息
- mwUpdate.rfidCar = "";
- mwUpdate.photoCar = e.vdioCarNos;
- //mwUpdate.photoCar = PbCache.collect.carno;
- if (!string.IsNullOrEmpty(e.RfidNos))
- {
- string sqls = @"SELECT RFID_ID id,CAR_NO text FROM METER_BASE_RFID_INFO where RFID_CODE = '" + e.RfidNos + "'";
- PbModelDbService<List<PbModelDb>> pbp = new PbModelDbService<List<PbModelDb>>();
- RESTfulResult<List<PbModelDb>> rmT = pbp.executeSqlDataWf(sqls);
- if (rmT.Data == null || rmT.Data.Count == 0)
- { }
- else
- {
- mwUpdate.rfidCar = rmT.Data[0].text;
- sCarNo = rmT.Data[0].text;
- }
- }
- #endregion
- #region 计量员修改的车号信息
- if (PbCache.monitor != null && !string.IsNullOrEmpty(PbCache.monitor.setCar))
- {
- sCarNo = PbCache.monitor.setCar;
- bEditCar = true;
- flagCarMonit = true;
- codeFlag = false;
- sweepCodeClass.StrCode = "";
- }
- #endregion
- #region 重量信息
- if (!PbCache.isLockFrm)
- {
- mwUpdate.wgt = e.weight;
- }
- else
- {
- mwUpdate.wgt = Convert.ToInt32(PbCache.lockWgt);
- }
- #endregion
- #region 写入一次监控表,将重量/车号停留超时等信息写入
- mwUpdate.msgInfo = PbCache.ResultMessage;
- mwUpdate.weightStatus = PbCache.collect.weightStatus;
- //另外初始化一次监控数据
- RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwUpdate);
- if (!rms.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常583:写入信息异常");
- }
- #endregion
- //验证对射
- valid.ValidMethod();
- if (!isOpenMeter)
- {
- //if (PbCache.range != null && PbCache.range.upperRange < e.weight)
- if (PbCache.range != null && PbCache.range.upperRange < e.weight)
- {
- //超量程
- vicPlayClass.GetVoicePlay("已超量程", e.carno);
- //return;
- }
- else if (e.weightStatus == 0)
- {
- if (!PbCache.monitorResult.valid_park_status)
- {
- iCountPark++;
- if (iCountPark > 9)
- {
- //重量稳定,且对射验证不合格
- vicPlayClass.GetVoicePlay("您的车辆未停到位", e.carno);
- //return;
- iCountPark = 0; //2021年7月27日5s播一次,然后重新在播
- }
- }
- else
- {
- iCountPark = 0;
- }
- }
- }
- if (!lu[0].bcEnable)
- {
- foreach (ucBusinessType uc in lu)
- {
- uc.setControlEnable(true);
- }
- }
- if (sweepCodeClass.StrCode == "" && !codeFlag)
- {
- PbCache.collect.carno = sCarNo;
- }
- }
- //写入LED信息
- if (PbCache.sportInfo != null && PbCache.ledInfo != PbCache.OldLedInfo)
- {
- PbCache.OldLedInfo = PbCache.ledInfo;
- if (PbCache.monitor != null && PbCache.monitor.ledKeep == "0")
- {
- //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
- }
- }
- }
- else
- {
- startCar = 0;
- startWeight = 0;
- if (e.weight > 10 && e.weight < 500)
- {
- //重量小于500,大于10
- MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
- mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
- mwUpdate.wgt = e.weight;
- RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwUpdate);
- }
- if (e.weight > 0 && e.weight < 200)
- {
- doOperateLive();
- }
- if (e.weight == 0)
- {
- PbCache.isZeroAlarm = false;
- }
- isOpened = false; //下次上秤直接打开主界面
- editCarNo = "";
- firstCode = ""; //历史的扫码枪的值
- preCarNo = "";
- sCarNo = "";
- sPreNo = "";
- preWgt = 0;
- PbCache.isOvertimeAlarm = false; //是否超时报警
- PbCache.strCode = "";
- PbCache.ResultMessage = "";
- bEditCar = false;
- isVoiceDownCar = false;
- flagCarMonit = false;
- iHodeTime = 0;
- isOpenMeter = false;
- PbCache.isLockFrm = false;
- PbCache.dtStartTime = null;
- PbCache.voiceOver = true;
- if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno))
- {
- PbCache.collect.carno = "";
- }
- setWelecomeVis(true);
- if (lu[0].bcEnable)
- {
- foreach (ucBusinessType uc in lu)
- {
- uc.setControlEnable(false);
- }
- }
- //LED写入
- if (isLedWrite)
- {
- if (PbCache.monitor == null || string.IsNullOrEmpty(PbCache.monitor.ledWriter))
- {
- PbCache.ledInfo = "欢迎使用九钢汽车衡智能计量系统";
- }
- else
- {
- PbCache.ledInfo = PbCache.monitor == null ? "" : PbCache.monitor.ledWriter;
- }
- //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
- isLedWrite = false;
- //*
- //另外初始化一次监控数据
- RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(new MeterWorkMonitor
- {
- pointNo = PbCache.sportInfo.baseSpotNo,
- validWgt = "1",
- validCarno = "1",
- validTareTime = "1",
- validMatTime = "1",
- validTimeInterval = "1",
- validParkStatus = "1",
- validExceedWgt = "1",
- validPredictionDiff = "1",
- validLianda = "1",
- validMatClick = "1",
- setCar = "",
- rfidCar = "",
- photoCar = "",
- scanCar = "",
- editCar = "",
- carErr = "0",
- wgtErr = "0",
- stopOverTime = "0",
- msgInfo = "",
- ledWriter = "",
- isOverWgt = "",
- isHelp = "0",
- wgt = 0
- });
- if (!rms.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常754:写入信息异常");
- isLedWrite = true;
- }
- //*/
- }
- }
- #endregion
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "frmMain.EventData异常:" + ex.Message);
- }
- }
- private delegate void ShowBtnTare(bool flag);//定义委托 期限皮重按钮
- /// <summary>
- /// 操作Live表的数据:零点报警
- /// </summary>
- private void doOperateLive()
- {
- if (PbCache.collect_no == null)
- {
- return;
- }
- List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
- if (ll != null)
- {
- foreach (LiveData lv in ll)
- {
- switch (lv.Tagname.Replace(PbCache.collect_no, ""))
- {
- case "StaticStatus"://车辆检测 "0、东西方向激光均无报警;否则报警
- break;
- case "SwitchLight"://PLC红绿灯控制模式状态 "PLC有三种控制模式:1、自动、2、远控;3、检修
- break;
- case "LightWest"://红绿灯:1、为绿灯;2、为红灯;"
- break;
- case "ZeroWeightStatus": //0、其它,1、零点报警,红绿灯变红,
- if (((lv.Value ?? "0") + "").Equals("1"))
- {
- doInsertZeroAlarm();
- PbCache.isZeroAlarm = true;
- }
- else
- {
- PbCache.isZeroAlarm = false;
- }
- break;
- }
- }
- }
- }
- /// <summary>
- /// 操作Live表的数据:零点报警
- /// </summary>
- private void doLive()
- {
- if (PbCache.collect_no == null)
- {
- return;
- }
- List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
- MeterWorkMonitor mwm = new MeterWorkMonitor();
- mwm.pointNo = PbCache.sportInfo.baseSpotNo;
- mwm.redGreenLightState = "0";
- if (ll != null)
- {
- foreach (LiveData lv in ll)
- {
- switch (lv.Tagname.Replace(PbCache.collect_no, ""))
- {
- case "PowerStatus":
- mwm.powerState = lv.Value.ToString();
- break;
- case "PlcWatchDog":
- if (int.Parse(lv.Value.ToString()) >= 0 && int.Parse(lv.Value.ToString()) <= 0)
- {
- mwm.plcState = 0.ToString();
- }
- break;
- case "InfraredWest":
- if (lv.Value.ToString() == "2")
- {
- mwm.leftInfraredRayState = "0";
- }
- else
- {
- mwm.leftInfraredRayState = lv.Value.ToString();
- }
- break;
- case "InfraredEast":
- if (lv.Value.ToString() == "2")
- {
- mwm.rightInfraredRayState = "0";
- }
- else
- {
- mwm.rightInfraredRayState = lv.Value.ToString();
- }
- break;
- case "AmplifierState":
- mwm.amplifierState = lv.Value.ToString();
- break;
- case "LampState":
- mwm.lampState = lv.Value.ToString();
- break;
- case "InfraredLeft":
- if (lv.Value.ToString() == "2")
- {
- mwm.frontInfraredRayState = "0";
- }
- else
- {
- mwm.frontInfraredRayState = lv.Value.ToString();
- }
- break;
- case "InfraredRight":
- if (lv.Value.ToString() == "2")
- {
- mwm.rearInfraredRayState = "0";
- }
- else
- {
- mwm.rearInfraredRayState = lv.Value.ToString();
- }
- break;
- case "RfidState":
- mwm.rfidState = lv.Value.ToString();
- break;
- }
- }
- }
- RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwm);
- }
- /// <summary>
- /// 新增零点报警的数据
- /// </summary>
- private void doInsertZeroAlarm()
- {
- if (!PbCache.isZeroAlarm)
- {
- PbCache.isZeroAlarm = true;
- MeterWorkZeroAlarm workZeroAlarm = new MeterWorkZeroAlarm();
- workZeroAlarm.zeroWeight = PbCache.collect.weight;
- workZeroAlarm.spotTypeNo = PbCache.sportInfo.spotTypeNo;
- workZeroAlarm.spotTypeName = PbCache.sportInfo.spotTypeName;
- workZeroAlarm.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- workZeroAlarm.baseSpotName = PbCache.sportInfo.baseSpotName;
- workZeroAlarm.scalePointNo = PbCache.collect_no;
- workZeroAlarm.createManNo = PbCache.sportInfo.baseSpotNo;
- workZeroAlarm.createManName = PbCache.sportInfo.baseSpotName;
- RESTfulResult<String> rms = zeroAlarmService.doInsertZeroAlarm(workZeroAlarm);
- if (rms.Succeed)
- {
- l.WriteLog(20, "新增成功:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight);
- }
- else
- {
- l.WriteLog(20, "操作失败:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight + rms.Data + rms.Message);
- }
- }
- }
- /// <summary>
- /// 关闭程序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
- {
- collection.Stop();
- imageCurlControl.Stop();
- sweepCodeClass.CloseThread();
- timer1.Stop();
- timer1.Dispose();
- }
- public void WriteText(int iType, string str)
- {
- try
- {
- string strLogName = "";
- switch (iType)
- {
- case 0:
- strLogName = "车号采集_";
- break;
- case 1:
- strLogName = "判稳时间_";
- break;
- }
- string m_szRunPath;
- m_szRunPath = System.Environment.CurrentDirectory;
- if (System.IO.Directory.Exists(m_szRunPath + "\\log") == false)
- {
- System.IO.Directory.CreateDirectory(m_szRunPath + "\\log");
- }
- string strDate = System.DateTime.Now.ToString("yyyyMMdd");
- string strPathFile = m_szRunPath + "\\log\\" + strDate;
- if (!Directory.Exists(strPathFile))//如果不存在就创建file文件夹
- {
- Directory.CreateDirectory(strPathFile);
- }
- System.IO.TextWriter tw = new System.IO.StreamWriter(strPathFile + "\\" + strLogName + strDate + ".log", true);
- tw.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- tw.WriteLine(str);
- tw.WriteLine("\r\n");
- tw.Close();
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
|