private List <TimeProfileEntry> MakeTimeProfileEntryFromDeviceAction([NotNull] DeviceAction da, [NotNull] Affordance affordance, [NotNull] AffordanceDevice affdev, Random rnd) { var tpes = new List <TimeProfileEntry>(); foreach (var actionProfile in da.Profiles) { var lt = actionProfile.VLoadType; if (lt == null) { throw new LPGException("load type was null"); } var tp = actionProfile.Timeprofile; if (tp == null) { throw new LPGException("Time profile was null"); } var cp = CalcDeviceFactory.GetCalcProfile(tp, new TimeSpan(0, 1, 0)); var factor = GetMaxExpansionFactor((double)affordance.TimeStandardDeviation, rnd); var newlength = cp.GetNewLengthAfterCompressExpand(factor); if (da.Device == null) { throw new LPGException("Device was null"); } var tpe = new TimeProfileEntry(affdev, newlength, lt, (int)(affdev.TimeOffset + actionProfile.TimeOffset), affordance, factor, da.Device.Name); tpes.Add(tpe); } return(tpes); }
private TimeProfileEntry MakeTimeProfileEntryFromDevice([NotNull] AffordanceDevice affdev, [NotNull] Affordance affordance, Random rnd) { var lt = affdev.LoadType; if (lt == null) { throw new DataIntegrityException("LoadType was null"); } var tp = affdev.TimeProfile; if (tp == null) { throw new DataIntegrityException("Time profile was null"); } var cp = CalcDeviceFactory.GetCalcProfile(tp, new TimeSpan(0, 1, 0)); var factor = GetMaxExpansionFactor((double)affordance.TimeStandardDeviation, rnd); var newlength = cp.GetNewLengthAfterCompressExpand(factor); if (affdev.Device == null) { throw new DataIntegrityException("Device was null"); } string name = affdev.Device.Name; var tpe = new TimeProfileEntry(affdev, newlength, lt, (int)affdev.TimeOffset, affordance, factor, name); return(tpe); }
private static void SetBusyBits([NotNull] TimeProfileEntry tpe, [NotNull] Dictionary <string, BitArray> busySignals) { for (var i = tpe.OffSet; i < tpe.NewLength + tpe.OffSet; i++) { if (busySignals[tpe.Key][i]) { throw new DataIntegrityException("Overlapping time profiles in the affordance " + tpe.Affordance + " for the load type " + tpe.LoadType + " at the time step " + i + " minutes for the device " + tpe.AffDev + " with a time expansion factor of " + tpe.TimeFactor + ". To avoid this, either reduce the standard deviation of the affordance or increase the time offset between the device activations. The affordance has a standard deviation of " + tpe.Affordance.TimeStandardDeviation, tpe.Affordance); } busySignals[tpe.Key][i] = true; } }