/// <summary> /// validates currency type units. assumes three valid signals: price and priceRelative with units of curencyType, and /// priceMultiplier with no units /// </summary> /// <param name="signalType"></param> /// <param name="units"></param> /// <param name="currencyDescriptonType"></param> public static void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units, currencyItemDescriptionType currencyDescriptonType) { if (signalType == SignalTypeEnumeratedType.price || signalType == SignalTypeEnumeratedType.priceRelative) { // the class could be currencyType, or a sub class currencyPerKWh, currencyPerKW type if (units.GetType().BaseType != typeof(currencyType) && units.GetType() != typeof(currencyType)) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } currencyType c = (currencyType)units; if (c.itemDescription != currencyDescriptonType) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } return; } if (signalType == SignalTypeEnumeratedType.priceMultiplier) { if (units != null) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } return; } throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE); }
/**********************************************************/ public override void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units) { if (signalType == SignalTypeEnumeratedType.setpoint) { if (units.GetType().BaseType != typeof(EnergyItemType)) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } return; } throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE); }
/**********************************************************/ public override void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units) { if (signalType == SignalTypeEnumeratedType.price) { if (units.GetType() != typeof(currencyType)) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } currencyType c = (currencyType)units; if (c.itemDescription != currencyItemDescriptionType.currency) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } return; } throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE); }
/**********************************************************/ public override void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units) { if (signalType == SignalTypeEnumeratedType.setpoint || signalType == SignalTypeEnumeratedType.delta || signalType == SignalTypeEnumeratedType.level) { if (units.GetType().BaseType != typeof(PowerItemType)) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } return; } if (signalType == SignalTypeEnumeratedType.multiplier) { if (units != null) { throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS); } return; } throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE); }