/// <summary> /// 重新加载新的产线单元的计数区间 /// </summary> /// <returns></returns> public bool Initial() { try { startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Hour, Minute, Second); CLog.WriteSysLog(startTime.ToLongTimeString()); DateTime timeEnd = startTime; int hoursToAdd = 1; int minuteToAdd = 60; lists = new List <PDNumberUnit>(); //添加采集计算单元和范围 共计12个小时 for (int i = 0; i < Range; i++) { startTime = startTime.AddHours(hoursToAdd); timeEnd = startTime.AddMinutes(minuteToAdd); PDNumberUnit unit = new PDNumberUnit(); unit.dataCount = 0; unit.TagName = String.Format("{0:D2}", i); unit.rang.StartTime = startTime; unit.rang.EndTime = timeEnd; // unit.rang.SEQ = i; lists.Add(unit); } return(true); } catch (Exception ex) { CLog.WriteErrLog(ex.Message.ToString()); } return(false); }
/// <summary> /// 添加到产线实际生产列表 /// </summary> /// <param name="PDUnit"></param> private int AddProductList(PDNumberUnit PDUnit, DateTime acqTime) { try { for (int i = 0; i < lists.Count; i++) { //判断在时间范围内 if (lists[i].rang.IsInRange(acqTime)) { lists[i].dataCount = PDUnit.dataCount; return(i); } } return(-1); } catch (Exception ex) { CLog.WriteErrLog(ex.Message.ToString()); } return(-1); }
public void ReloadPlanUnits() { try { startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Hour, Minute, Second); CLog.WriteSysLog(startTime.ToLongTimeString()); DateTime timeEnd = startTime; int hoursToAdd = 1; int minuteToAdd = 60; lists = new List <PDNumberUnit>(); //添加采集计算单元和范围 共计24个小时 for (int i = 0; i < this.Range; i++) { timeEnd = startTime.AddMinutes(minuteToAdd); PDNumberUnit unit = new PDNumberUnit(); unit.dataCount = 0; unit.TagName = String.Format("{0:D2}", i); unit.rang.StartTime = startTime; unit.rang.EndTime = timeEnd; // unit.rang.SEQ = i; lists.Add(unit); startTime = startTime.AddHours(hoursToAdd); } } catch { throw; } }
/// <summary> /// /// </summary> /// <returns></returns> public bool InitailPlineUnits() { try { if (curPlan == null) { return(false); } if (curPlan.CREATE_TIME != null) { //string strDataTime=String.Format("{0}-{1}-{2} 23:59:59",curPlan.CREATE_TIME.Year, // curPlan.CREATE_TIME.Month, // curPlan.CREATE_TIME.Day); //DateTime loadDate=Convert.ToDateTime(strDataTime); /////超过加载时间后 //if (DateTime.Compare(DateTime.Now, loadDate)>0) //{ startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Hour, Minute, Second); CLog.WriteSysLog(startTime.ToLongTimeString()); DateTime timeEnd = startTime; int hoursToAdd = 1; int minuteToAdd = 60; lists = new List <PDNumberUnit>(); //添加采集计算单元和范围 共计24个小时 for (int i = 0; i < this.Range; i++) { // startTime = startTime.AddHours(hoursToAdd); timeEnd = startTime.AddMinutes(minuteToAdd); PDNumberUnit unit = new PDNumberUnit(); unit.dataCount = 0; unit.TagName = String.Format("{0:D2}", i); unit.rang.StartTime = startTime; unit.rang.EndTime = timeEnd; // unit.rang.SEQ = i; lists.Add(unit); startTime = startTime.AddHours(hoursToAdd); } return(true); // } } } catch (Exception ex) { CLog.WriteErrLog(ex.Message.ToString()); } return(false); }