static void Main(string[] args) { bool loop = true; QMNetCoreFrame.Log.Log.InitLog(); //QMNetCoreFrame.MSSql.MSSql.ConnStr = "Server=127.0.0.1,1433;Database=EXLD;User ID=mes;Password=Fy861213"; QMNetCoreFrame.MSSql.MSSql.ConnStr = "Server=127.0.0.1,1433;Database=EXLD;User ID=mes;Password=Krones1itk"; //ReadPLC(); RowConfig.InitData(); Log.Info("Init Device IP Datapoint Finished"); RowConfig.InitDic(); Log.Info("Init Dic Finished"); RowConfig.InitTagDic(); Log.Info("Init TagDic Finished"); // //FuncAsyn.RunP0(JobGetPLCData.GetFirstDataFromPLC); EqpKPI.Init(); Log.Info("EqpKPI Dic Init Finished"); QMNCPLCS7.OEM.DBChange.Init(); QMNCPLCS7.OEM.DBChange.Run(); JobGetPLCData.GetFirstDataFromPLC(); Thread.Sleep(60000); FuncAsyn.RunP0(JobGetPLCData.Run); Thread.Sleep(180000); FuncAsyn.RunP0(JobDT.Run); while (loop) { Log.Info("[Program Main Thread][Loop]"); Thread.Sleep(1000000000); // JobGetPLCData.GetDataFromPLC(); } Console.ReadLine(); }
// int rv = 0; public static void Compare() { try { PLCHisData hisdata = null; foreach (var R in RealData.dic) { if (R.Value == uint.MaxValue) //判断是否断线 { hisdata = FrontData.dic[R.Key]; hisdata.refid = 0; hisdata.Time = DateTime.Now; hisdata.Value = uint.MaxValue; } else { Log.Info("[JobDT] TagID: " + R.Key + " Real Value " + R.Value + "===" + FrontData.dic[R.Key].Value + " HisData Value "); if (R.Value == FrontData.dic[R.Key].Value)//设备状态没有变化 { hisdata = FrontData.dic[R.Key]; TimeSpan span = DateTime.Now - hisdata.Time; double muni = span.TotalMinutes; if (muni > 2) { DTKAG.PlusDT(hisdata.refid, muni); hisdata.Time = DateTime.Now; if (R.Key == EqpName.FillerStatusTagID) { if (!string.IsNullOrEmpty(hisdata.formid)) { DTFiller.DTPlusDuration(hisdata.formid, muni); } } } // hisdata.Value = R.Value; } else //设备状态有变化 { QMNCPLCS7.TraceDT.TraceCL1.CloseLoop(); hisdata = FrontData.dic[R.Key]; TimeSpan span = DateTime.Now - hisdata.Time; double muni = span.TotalMinutes; DTKAG.PlusDTFinish(hisdata.refid, muni); //结束上一状态 hisdata.refid = DTKAG.KAGCreateNewDT(hisdata.TagID, hisdata.type, R.Value); //创建新的状态 hisdata.Time = DateTime.Now; //更新 FrontData hisdata.Value = R.Value; if (R.Key == EqpName.FillerStatusTagID) //如果是Filler 结束 FIller状态 { if (!string.IsNullOrEmpty(hisdata.formid)) { DTFiller.DTPlusDurationFinish(hisdata.formid, muni); if (R.Value == 8) { hisdata.formid = QMNCPLCS7.TraceDT.PersisDTFiller.CL1NewDTFiller(EqpName.DepackStatusTagID, EqpName.Depack, "", RealData.dic[EqpName.FillerStatusTagID]); } else if (R.Value == 16) { QMNCPLCS7.TraceDT.TraceCL1.SetLoop(); FuncAsyn.RunP1(QMNCPLCS7.TraceDT.TraceDownEqp.Run, hisdata.formid); } else if (R.Value == 128) { } else { hisdata.formid = QMNCPLCS7.TraceDT.PersisDTFiller.CL1NewDTFiller(EqpName.FillerStatusTagID, EqpName.Filler, "", RealData.dic[EqpName.FillerStatusTagID]); } } } } } } } catch (Exception ex) { Log.Error(ex.ToString()); } }
public static void Run() { FuncAsyn.RunP0(GetPLCDataLoop); Thread.Sleep(2000); FuncAsyn.RunP0(WritePLCLoop); }