public void OnStageStarted(object set, StageInfoEventArgs sea) { lock (resLock) { BatterySet bat = (BatterySet)set; if (Results.Count == 0) { Results.Add(new ResultsPoint() { CycleNo = bat.CurrentCycle }); return; } ResultsPoint point = Results.Last(); if (point.CycleNo < bat.CurrentCycle) { Results.Add(new ResultsPoint() { CycleNo = bat.CurrentCycle }); } } }
public void OnStageCompleted(object set, StageInfoEventArgs sea) { BatterySet bat = (BatterySet)set; ResultsPoint point = Results[bat.CurrentCycle - 1]; ExperimentStageBase stage = sea.Stage; switch (bat.TypeOfBattery) { case BatteryType.SingleBattery: { if (stage is ChargeStage) { point.ChargeDurationSingle = stage.Duration; point.ChargeVolumeSingle = stage.TotalCharge; } if (stage is DischargeStage) { point.DischargeDurationSingle = stage.Duration; point.DischargeVolumeSingle = stage.TotalCharge; } } break; case BatteryType.BatteryUsingCNM: { if (stage is ChargeStage) { point.ChargeDurationCNM = stage.Duration; point.ChargeVolumeCNM = stage.TotalCharge; } if (stage is DischargeStage) { point.DischargeDurationCNM = stage.Duration; point.DischargeVolumeCNM = stage.TotalCharge; } } break; default: break; } Save("ToLoad2.csv"); }
public BanchModel() { A01 = new Adam6017("A01", "Battery parameters measure", 1000); A02 = new Adam6050("A02", "Switch relay for charge and discharge", 1000); SingleBatterySet = new BatterySet(BatteryType.SingleBattery, A01, A02, (int)ChannelsNumbers.SingleBatteryVoltageMeassure, (int)ChannelsNumbers.SingleBatteryCurrentMeassure, (int)ChannelsNumbers.SingleBatteryChargeRelay, (int)ChannelsNumbers.SingleBatteryDischargeRelay); SingleBatterySet.VoltageCoverter = new LinearConverter(2.99, 0.0, "VCONV", "Конвертирование входного напряжения в напряжение батареии"); SingleBatterySet.CurrentCoverter = new LinearConverter(0.605, 0.0, "CCONV", "Конвертирование входного напряжения в ток батареии"); BatteryWithCNMSet = new BatterySet(BatteryType.BatteryUsingCNM, A01, A02, (int)ChannelsNumbers.BatteryWithCMNVoltageMeassure, (int)ChannelsNumbers.BatteryWithCMNCurrentMeassure, (int)ChannelsNumbers.BatteryWithCMNChargeRelay, (int)ChannelsNumbers.BatteryWithCMNDischargeRelay); BatteryWithCNMSet.VoltageCoverter = new LinearConverter(3.0, 0.0, "VCONV", "Конвертирование входного напряжения в напряжение батареии"); BatteryWithCNMSet.CurrentCoverter = new LinearConverter(0.59, -0.0124, "CCONV", "Конвертирование входного напряжения в ток батареии"); SingleBatterySet.StageStart += ResultsModel.OnStageStarted; BatteryWithCNMSet.StageStart += ResultsModel.OnStageStarted; SingleBatterySet.StageComplete += ResultsModel.OnStageCompleted; BatteryWithCNMSet.StageComplete += ResultsModel.OnStageCompleted; SingleBatterySet.StageTick += ResultsModel.OnStageCompleted; BatteryWithCNMSet.StageTick += ResultsModel.OnStageCompleted; StopAnyWork = new ManualResetEvent(false); }