private void DoPushing() { if (Pushing) { PushCurCount++; //推焦电流 ((TjcDataRead)DataRead).PushCur; //推焦杆长度 ((TjcDataRead)DataRead).PushPoleLength; //需要知道电流计数次数,以便计算平均电流? byte cur = ((TjcDataRead)DataRead).PushCur >= 255 ? (byte)255 : (byte)((TjcDataRead)DataRead).PushCur; //6000为推焦杆长的最大值;(把推焦杆长映射为 (1-255)) byte len = ((TjcDataRead)DataRead).PushPoleLength * 255 / 6500 > 255 ? (byte)255 : Convert.ToByte(((TjcDataRead)DataRead).PushPoleLength * 255 / 6500); PushCurLst.Add(cur); PushPoleLst.Add(len); PushLenPoint = new Point(PushCurCount, len); PushCurPoint = new Point(PushCurCount, cur); //开始记录推焦电流和杆长的条件 //数字1000单位为ms,即1s,数字200为计时器的Interval,单位为ms if (PushCurCount > PushStartTime * 1500 / 200 && cur > 0 && ((TjcTogetherInfo)DataRead.TogetherInfo).PushPoleForward) { ValidPushCurCount++; PushCurMax = PushCurMax < cur ? cur : PushCurMax; PushCurSum += cur; //计算平均电流值,是否考虑电流值为0的情况? PushCurAvg = (byte)(PushCurSum / ValidPushCurCount); } } }
private void PreparePlotterPushCur() { PushCurMax = 0; PushCurSum = 0; PushCurAvg = 0; PushCurCount = 0; ValidPushCurCount = 0; PushCurLst.Clear(); PushPoleLst.Clear(); PushCurPoint = new Point(); PushLenPoint = new Point(); }
/// <summary> /// 推焦结束信号到达后记录的数据ToPushInfoDB /// </summary> private void PushDataPart2() { if (psInfo == null) { PushDataPart1(); } psInfo.MaxCur = PushCurMax; psInfo.AvgCur = PushCurAvg; psInfo.CurArr = Convert.ToBase64String(PushCurLst.ToArray()); psInfo.PoleArr = Convert.ToBase64String(PushPoleLst.ToArray()); psInfo.EndTime = DateTime.Now; //记录到数据库:需注意工作车或非工作推焦车的Info PushInfoHelper push = new PushInfoHelper(new DbAppDataContext(Setting.ConnectionStr), psInfo, false); push.RecToDB(); psInfo = null; }