Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /******************************************************************************/

        private void validateSignal(SignalNameEnumeratedType signalName, SignalTypeEnumeratedType signalType, ItemBaseType units, bool shouldBeValid, string exceptionMessage = null)
        {
            eiEventSignalType signal = new eiEventSignalType();

            signal.signalName = signalName.ToString();
            signal.signalType = signalType;

            signal.itemBase = units;

            validateSignal(signal, shouldBeValid, exceptionMessage);
        }
Exemplo n.º 3
0
        /******************************************************************************/

        public override void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units)
        {
            if (signalType != SignalTypeEnumeratedType.level)
            {
                throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE);
            }

            if (units != null)
            {
                throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS);
            }
        }
Exemplo n.º 4
0
        /**********************************************************/

        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);
        }
Exemplo n.º 5
0
        /**********************************************************/

        public override void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units)
        {
            if (signalType == SignalTypeEnumeratedType.xloadControlCapacity || signalType == SignalTypeEnumeratedType.xloadControlLevelOffset ||
                signalType == SignalTypeEnumeratedType.xloadControlPercentOffset || signalType == SignalTypeEnumeratedType.xloadControlSetpoint)
            {
                if (units != null)
                {
                    throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_UNITS);
                }

                return;
            }

            throw new ExceptionInvalidSignal(ExceptionInvalidSignal.INVALID_TYPE);
        }
Exemplo n.º 6
0
        /**********************************************************/

        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);
        }
Exemplo n.º 7
0
        /**********************************************************/

        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);
        }
        /******************************************************************************/

        public override void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units)
        {
            ValidateUnits.validateUnits(signalType, units, currencyItemDescriptionType.currencyPerKWh);
        }
Exemplo n.º 9
0
        /**********************************************************/

        public abstract void validateUnits(SignalTypeEnumeratedType signalType, ItemBaseType units);