예제 #1
0
        ///
        ///	 <summary> * fitsValueList - tests, if the defined 'rangelist' matches the
        ///	 * AllowedValueList or in the PresentValueList, specified for this State
        ///	 *  </summary>
        ///	 * <param name="rangelist">
        ///	 *            range list to test </param>
        ///	 * <param name="valuelist">
        ///	 *            switches between AllowedValueList and PresentValueList.
        ///	 *  </param>
        ///	 * <returns> boolean - true, if 'rangelist' matches the valuelist or if
        ///	 *         AllowedValueList is not specified </returns>
        ///
        private bool fitsValueList(JDFDurationRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFDurationRangeList list;

            if (valuelist.Equals(EnumFitsValue.Allowed))
            {
                list = getAllowedValueList();
            }
            else
            {
                list = getPresentValueList();
            }
            if (list == null)
            {
                return(true);
            }

            EnumListType listType = getListType();

            if (listType.Equals(EnumListType.CompleteList))
            {
                return(fitsCompleteList(rangelist, list));
            }
            else if (listType.Equals(EnumListType.CompleteOrderedList))
            {
                return(fitsCompleteOrderedList(rangelist, list));
            }
            else if (listType.Equals(EnumListType.ContainedList))
            {
                return(fitsContainedList(rangelist, list));
            }

            return(list.isPartOfRange(rangelist));
        }
예제 #2
0
 ///
 ///	 <summary> * fitsValueList - tests, if the defined 'rangelist' matches ValueList
 ///	 * specified for this Evaluation
 ///	 *  </summary>
 ///	 * <param name="rangelist">
 ///	 *            range list to test
 ///	 *  </param>
 ///	 * <returns> boolean - true, if 'rangelist' matches the valuelist or if
 ///	 *         ValueList is not specified </returns>
 ///
 private bool fitsValueList(JDFDurationRangeList rangelist)
 {
     if (!hasAttribute(AttributeName.VALUELIST))
     {
         return(true);
     }
     return(getValueList().isPartOfRange(rangelist));
 }
예제 #3
0
        public void testIsValid()
        {
            iState.setDefaultValue(new JDFDuration("P4D"));
            Assert.IsTrue(iState.isValid(EnumValidationLevel.Complete));
            iState.setCurrentValue(new JDFDuration("PT30M"));
            iState.setListType(EnumListType.SingleValue);
            Assert.IsTrue(iState.isValid(EnumValidationLevel.Complete));
            JDFDurationRangeList integerRList = new JDFDurationRangeList("PT2S PT5S");

            iState.setAllowedValueList(integerRList);
            Assert.IsTrue(iState.isValid(EnumValidationLevel.Complete));
            Assert.IsTrue(iState.isValid(EnumValidationLevel.Complete));
        }
예제 #4
0
        ///
        ///          <summary> * (20) get JDFDurationRangeList attribute ValueRange </summary>
        ///          * <returns> JDFDurationRangeList the value of the attribute, null if a the
        ///          *         attribute value is not a valid to create a JDFDurationRangeList </returns>
        ///
        public virtual JDFDurationRangeList getValueRange()
        {
            string strAttrName = "";
            JDFDurationRangeList nPlaceHolder = null;

            strAttrName = getAttribute(AttributeName.VALUERANGE, null, JDFConstants.EMPTYSTRING);
            try
            {
                nPlaceHolder = new JDFDurationRangeList(strAttrName);
            }
            catch (FormatException)
            {
                return(null);
            }
            return(nPlaceHolder);
        }
예제 #5
0
 ///
 ///	 <summary> * fitsValue - tests, if the defined value matches Allowed test lists or
 ///	 * Present test lists, specified for this State
 ///	 *  </summary>
 ///	 * <param name="value">
 ///	 *            value to test </param>
 ///	 * <param name="testlists">
 ///	 *            test lists, that the value has to match. In this State the
 ///	 *            test list is ValueList.<br>
 ///	 *            Choose one of two values: FitsValue_Allowed or
 ///	 *            FitsValue_Present. (Defaults to Allowed)
 ///	 *  </param>
 ///	 * <returns> boolean - true, if the value matches test list or if
 ///	 *         AllowedValueList is not specified </returns>
 ///
 public sealed override bool fitsValue(string @value, EnumFitsValue testlists)
 {
     if (fitsListType(@value))
     {
         JDFDurationRangeList rangelist = null;
         try
         {
             rangelist = new JDFDurationRangeList(@value);
         }
         catch (FormatException)
         {
             return(false);
         }
         return(fitsValueList(rangelist, testlists));
     }
     return(false); // the value doesn't fit ListType attribute of this State
 }
예제 #6
0
        ///
        ///	 <summary> * fitsContainedList - tests for the case, when ListType=ContainedList, if
        ///	 * the defined 'value' matches AllowedValueList or PresentValueList,
        ///	 * specified for this State
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <param name="list">
        ///	 *            testlists are either AllowedValueList or PresentValueList.
        ///	 *  </param>
        ///	 * <returns> boolean - true, if 'value' matches testlist </returns>
        ///
        private bool fitsContainedList(JDFDurationRangeList @value, JDFDurationRangeList list)
        {
            int v_size = @value.Count;
            int l_size = list.Count;

            for (int i = 0; i < v_size; i++)
            {
                for (int j = 0; j < l_size; j++)
                {
                    if (@value[i].Equals(list[j]))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #7
0
 ///
 ///	 <summary> * get attribute <code>PresentValueDurationList</code>
 ///	 *  </summary>
 ///	 * <returns> the value of the attribute </returns>
 ///
 public virtual JDFDurationRangeList getPresentValueDurationList()
 {
     if (hasAttribute(AttributeName.PRESENTVALUEDURATIONLIST))
     {
         JDFDurationRangeList r = null;
         try
         {
             r = new JDFDurationRangeList(getAttribute(AttributeName.PRESENTVALUEDURATIONLIST));
         }
         catch (FormatException)
         {
             return(null);
         }
         return(r);
     }
     return(getAllowedValueDurationList());
 }
예제 #8
0
        ///
        ///	 <summary> * get attribute <code>AllowedValueDurationList</code>
        ///	 *  </summary>
        ///	 * <returns> the value of the attribute </returns>
        ///
        public virtual JDFDurationRangeList getAllowedValueDurationList()
        {
            JDFDurationRangeList r = null;

            string allowedValueDurList = getAttribute(AttributeName.ALLOWEDVALUEDURATIONLIST, null, null);

            if (allowedValueDurList != null)
            {
                try
                {
                    r = new JDFDurationRangeList(allowedValueDurList);
                }
                catch (FormatException)
                {
                    return(null);
                }
            }
            return(r);
        }
예제 #9
0
        //
        //	 * // FitsValue Methods
        //

        ///
        ///	 <summary> * fitsValue - tests, if the defined value matches ValueList, specified for
        ///	 * this Evaluation
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <returns> boolean - true, if the value matches ValueList or if ValueList is
        ///	 *         not specified </returns>
        ///
        public sealed override bool fitsValue(string @value)
        {
            if (!fitsListType(@value))
            {
                return(false);
            }

            JDFDurationRangeList rangelist = null;

            try
            {
                rangelist = new JDFDurationRangeList(@value);
            }
            catch (FormatException)
            {
                return(false);
            }
            return(fitsValueList(rangelist));
        }
예제 #10
0
        ///
        ///	 <summary> * fitsCompleteList - tests for the case, when ListType=CompleteList, if the
        ///	 * defined 'value' matches AllowedValueList or PresentValueList, specified
        ///	 * for this State
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <param name="list">
        ///	 *            testlists are either AllowedValueList or PresentValueList.
        ///	 *  </param>
        ///	 * <returns> boolean - true, if 'value' matches testlist </returns>
        ///
        private bool fitsCompleteList(JDFDurationRangeList @value, JDFDurationRangeList list)
        {
            int v_size = @value.Count;
            int l_size = list.Count;

            if (v_size != l_size)
            {
                return(false);
            }

            if ([email protected]())
            {
                return(false);
            }

            JDFDurationRangeList valueList = new JDFDurationRangeList(@value);

            bool bFound;

            for (int i = l_size - 1; i >= 0; i--)
            {
                bFound = false;
                for (int j = valueList.Count - 1; j >= 0; j--)
                {
                    if (list[i].Equals(valueList[j]))
                    {
                        valueList.erase(j);
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #11
0
        //
        //	 * // Element getter / Setter
        //

        //
        //	 * // FitsValue Methods
        //

        //
        //	 * (non-Javadoc)
        //	 *
        //	 * @see
        //	 * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java
        //	 * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue)
        //
        public override void addValue(string @value, EnumFitsValue testlists)
        {
            if (fitsValue(@value, testlists))
            {
                return;
            }

            JDFDuration duration;

            try
            {
                duration = new JDFDuration(@value);
            }
            catch (FormatException)
            {
                return; // nop for bad values
            }
            if (testlists == null || EnumFitsValue.Allowed.Equals(testlists))
            {
                JDFDurationRangeList list = getAllowedValueList();
                if (list == null)
                {
                    list = new JDFDurationRangeList();
                }
                list.Append(duration);
                setAllowedValueList(list);
            }
            if (testlists == null || EnumFitsValue.Present.Equals(testlists))
            {
                JDFDurationRangeList list = getPresentValueList();
                if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST))
                {
                    list = new JDFDurationRangeList();
                }
                list.Append(duration);
                setPresentValueList(list);
            }
        }
예제 #12
0
///
///	 <summary> * fitsValueDurationList - tests, if the duration of the defined 'rangelist'
///	 * value matches ValueDurationList, specified for this State
///	 *  </summary>
///	 * <param name="rangelist">
///	 *            range list to test </param>
///	 * <returns> boolean - true, if the duration of the defined
///	 *         <code>rangelist</code> is in the ValueList or if
///	 *         ValueDurationList is not specified </returns>
///
        private bool fitsValueDurationList(JDFDateTimeRangeList rangelist)
        {
            if (hasAttribute(AttributeName.VALUEDURATIONLIST))
            {
                JDFDurationRangeList list = getValueDurationList();

                int siz = rangelist.Count;
                for (int i = 0; i < siz; i++)
                {
                    JDFDateTimeRange range = (JDFDateTimeRange)rangelist[i];

                    int         duration = (int)((range.Right.TimeInMillis - range.Left.TimeInMillis) / 1000);
                    JDFDuration d        = new JDFDuration();
                    d.setDuration(duration);
                    if (!list.inRange(d))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(true);
        }
예제 #13
0
        ///
        ///	 <summary> * fitsCompleteOrderedList - tests for the case, when
        ///	 * ListType=CompleteOrderedList, if the defined 'value' matches
        ///	 * AllowedValueList or PresentValueList, specified for this State
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <param name="list">
        ///	 *            testlists are either AllowedValueList or PresentValueList.
        ///	 *  </param>
        ///	 * <returns> boolean - true, if 'value' matches testlist </returns>
        ///
        private bool fitsCompleteOrderedList(JDFDurationRangeList @value, JDFDurationRangeList list)
        {
            int v_size = @value.Count;
            int l_size = list.Count;

            if (v_size != l_size)
            {
                return(false);
            }

            if ([email protected]())
            {
                return(false);
            }

            for (int i = 0; i < l_size; i++)
            {
                if (!list[i].Equals(@value[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #14
0
        // ************************************************************************
        // * Attribute getter / setter
        // * ************************************************************************
        //

        //         ---------------------------------------------------------------------
        //        Methods for Attribute ValueRange
        //        ---------------------------------------------------------------------
        ///
        ///          <summary> * (36) set attribute ValueRange </summary>
        ///          * <param name="value">: the value to set the attribute to </param>
        ///
        public virtual void setValueRange(JDFDurationRangeList @value)
        {
            setAttribute(AttributeName.VALUERANGE, @value, null);
        }
예제 #15
0
///
///	 <summary> * set attribute <code>ValueDurationList</code>
///	 *  </summary>
///	 * <param name="value">
///	 *            the value to set the attribute to </param>
///
        public virtual void setValueDurationList(JDFDurationRangeList @value)
        {
            setAttribute(AttributeName.VALUEDURATIONLIST, @value.ToString());
        }
예제 #16
0
 public virtual void setPresentValueList(JDFDurationRangeList @value)
 {
     setAttribute(AttributeName.PRESENTVALUELIST, @value.ToString());
 }
예제 #17
0
 public virtual void setAllowedValueList(JDFDurationRangeList @value)
 {
     setAttribute(AttributeName.ALLOWEDVALUELIST, @value.ToString());
 }
예제 #18
0
        ///
        ///	 <summary> * fitsListType - tests, if the defined 'value' matches value of ListType
        ///	 * attribute, specified for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            value to test </param>
        ///	 * <returns> boolean - true, if 'value' matches specified ListType </returns>
        ///
        private bool fitsListType(string @value)
        {
            EnumListType listType = getListType();

            JDFDurationRangeList rangelist;

            try
            {
                rangelist = new JDFDurationRangeList(@value);
            }
            catch (FormatException)
            {
                return(false);
            }
            catch (JDFException)
            {
                return(false);
            }

            if (listType.Equals(EnumListType.SingleValue) || listType.Equals(EnumListType.getEnum(0)))
            { // default ListType = SingleValue
                if (@value.IndexOf("P") != 0)
                {
                    return(false);
                }

                try
                {
                    new JDFDuration(@value);
                }
                catch (JDFException)
                {
                    return(false);
                }
                catch (FormatException)
                {
                    return(false);
                }

                return(true);
            }
            else if (listType.Equals(EnumListType.RangeList) || listType.Equals(EnumListType.Span))
            {
                return(true);
            }
            else if (listType.Equals(EnumListType.List))
            {
                return(rangelist.isList());
            }
            else if (listType.Equals(EnumListType.OrderedList))
            {
                return(rangelist.isList() && rangelist.isOrdered());
            }
            else if (listType.Equals(EnumListType.UniqueList))
            {
                return(rangelist.isList() && rangelist.isUnique());
            }
            else if (listType.Equals(EnumListType.UniqueOrderedList))
            {
                return(rangelist.isList() && rangelist.isUniqueOrdered());
            }
            else if (listType.Equals(EnumListType.OrderedRangeList))
            {
                return(rangelist.isOrdered());
            }
            else if (listType.Equals(EnumListType.UniqueRangeList))
            {
                return(rangelist.isUnique());
            }
            else if (listType.Equals(EnumListType.UniqueOrderedRangeList))
            {
                return(rangelist.isUniqueOrdered());
            }
            else
            {
                throw new JDFException("JDFDurationEvaluation.fitsListType illegal ListType attribute");
            }
        }