public override bool WriteConfiguration(ConfigurationProfile cfg) { return(false); }
public virtual bool WriteConfiguration(ConfigurationProfile cfg) { //DevicePDF device = new DevicePDF(); try { //device = this.Pdf; if (ObjectManage.DeviceNew != null) { ObjectManage.DeviceNew.Data.TripNo = cfg.Tn; ObjectManage.DeviceNew.Data.Description = cfg.Desc; //ObjectManage.DeviceNew.Data.AlarmType = cfg. ObjectManage.DeviceNew.Data.TemperatureUnit = cfg.TempUnit == "C" ? 1 : 2; ObjectManage.DeviceNew.Data.LogInterval = Convert.ToInt32(cfg.LogIntervalH) * 3600 + Convert.ToInt32(cfg.LogIntervalM) * 60 + Convert.ToInt32(cfg.LogIntervalS); string cycle = TempsenFormatHelper.GetSecondsFromFormatString(cfg.LogCycle); ObjectManage.DeviceNew.Data.LogCycle = Convert.ToInt32(cycle) / 3600;//log cycle //if (cycle.Count > 1) // ObjectManage.DeviceNew.Data.LogCycle += cycle[1]; if (cfg.StartMode == "Manual Start") { ObjectManage.DeviceNew.Data.StartDelay = (Convert.ToInt32(cfg.StartDelayD) * 1440 + Convert.ToInt32(cfg.StartDelayH) * 60 + Convert.ToInt32(cfg.StartDelayM)); ObjectManage.DeviceNew.Data.StartMode = "F8"; } else { ObjectManage.DeviceNew.Data.StartConditionTime = Convert.ToDateTime(cfg.StartDate).ToUniversalTime();//UTC时间写入 //ObjectManage.DeviceNew.Data.StartConditionTime = Convert.ToDateTime(cfg.StartDate); ObjectManage.DeviceNew.Data.StartMode = "8F"; } if (cfg.IsSingleAlarm) { ObjectManage.DeviceNew.Data.AlarmMode = 1; if (cfg.IsHighLimit) { ObjectManage.DeviceNew.Data.AlarmLimits2 = cfg.HighTemp; ObjectManage.DeviceNew.Data.AlarmType2 = cfg.HighAlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193); ObjectManage.DeviceNew.Data.AlarmDelay2 = cfg.HighDay * 24 * 3600 + cfg.HighH * 3600 + cfg.HighM * 60; } else { ObjectManage.DeviceNew.Data.AlarmType2 = Convert.ToByte(0); } if (cfg.IsLowLimit) { ObjectManage.DeviceNew.Data.AlarmLimits3 = cfg.LowTemp; ObjectManage.DeviceNew.Data.AlarmType3 = cfg.LowAlarmType == "Single" ? Convert.ToByte(128) : Convert.ToByte(129); ObjectManage.DeviceNew.Data.AlarmDelay3 = cfg.LowDay * 24 * 3600 + cfg.LowH * 3600 + cfg.LowM * 60; } else { ObjectManage.DeviceNew.Data.AlarmType3 = Convert.ToByte(0); } ObjectManage.DeviceNew.Data.AlarmType0 = Convert.ToByte(0); ObjectManage.DeviceNew.Data.AlarmType1 = Convert.ToByte(0); ObjectManage.DeviceNew.Data.AlarmType4 = Convert.ToByte(0); } else if (cfg.IsMultiAlarm) { ObjectManage.DeviceNew.Data.AlarmMode = 2; if (cfg.IsA6) { ObjectManage.DeviceNew.Data.AlarmLimits0 = cfg.A6Temp; ObjectManage.DeviceNew.Data.AlarmType0 = cfg.A6AlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193); ObjectManage.DeviceNew.Data.AlarmDelay0 = cfg.A6Day * 24 * 3600 + cfg.A6H * 3600 + cfg.A6M * 60; } else { ObjectManage.DeviceNew.Data.AlarmType0 = Convert.ToByte(0); } if (cfg.IsA5) { ObjectManage.DeviceNew.Data.AlarmLimits1 = cfg.A5Temp; ObjectManage.DeviceNew.Data.AlarmType1 = cfg.A5AlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193); ObjectManage.DeviceNew.Data.AlarmDelay1 = cfg.A5Day * 24 * 3600 + cfg.A5H * 3600 + cfg.A5M * 60; } else { ObjectManage.DeviceNew.Data.AlarmType1 = Convert.ToByte(0); } ObjectManage.DeviceNew.Data.AlarmLimits2 = cfg.A4Temp; ObjectManage.DeviceNew.Data.AlarmLimits3 = cfg.A3Temp; if (cfg.IsA1) { ObjectManage.DeviceNew.Data.AlarmLimits4 = cfg.A1Temp; ObjectManage.DeviceNew.Data.AlarmType4 = cfg.A1AlarmType == "Single" ? Convert.ToByte(128) : Convert.ToByte(129); ObjectManage.DeviceNew.Data.AlarmDelay4 = cfg.A1Day * 24 * 3600 + cfg.A1H * 3600 + cfg.A1M * 60; } else { ObjectManage.DeviceNew.Data.AlarmType4 = Convert.ToByte(0); } ObjectManage.DeviceNew.Data.AlarmType2 = cfg.A4AlarmType == "Single" ? Convert.ToByte(192) : Convert.ToByte(193); ObjectManage.DeviceNew.Data.AlarmType3 = cfg.A2AlarmType == "Single" ? Convert.ToByte(128) : Convert.ToByte(129); ObjectManage.DeviceNew.Data.AlarmDelay2 = cfg.A4Day * 24 * 3600 + cfg.A4H * 3600 + cfg.A4M * 60; ObjectManage.DeviceNew.Data.AlarmDelay3 = cfg.A2Day * 24 * 3600 + cfg.A2H * 3600 + cfg.A2M * 60; } else { ObjectManage.DeviceNew.Data.AlarmMode = 0; } return(ObjectManage.DeviceNew.DoWrite()); } return(false); } catch { //ObjectManage.DeviceNew.disconnectDevice(); return(false); } }