Beispiel #1
0
        ///
        ///	 <summary> * fitsValueDurationList - tests, if the duration of the defined
        ///	 * <code>rangelist</code> value matchest the ValueDurationList, 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 the duration of the defined rangelist is in
        ///	 *         <code>valueList</code> or if ValueDurationList is not specified </returns>
        ///
        private bool fitsValueDurationList(JDFDateTimeRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFDurationRangeList list;

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

            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);
        }
Beispiel #2
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 <code>rangelist</code> matches the valuelist
        ///	 *         or if AllowedValueList is not specified </returns>
        ///
        private bool fitsValueList(JDFDateTimeRangeList rangelist, EnumFitsValue valuelist)
        {
            JDFDateTimeRangeList 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));
        }
///
///	 <summary> * fitsValueList - tests, if the defined <code>rangelist</code> matches the
///	 * ValueList specified for this Evaluation
///	 *  </summary>
///	 * <param name="rangelist">
///	 *            range list to test
///	 *  </param>
///	 * <returns> boolean - true, if <code>rangelist</code> matches the valuelist
///	 *         or if ValueList is not specified </returns>
///
        private bool fitsValueList(JDFDateTimeRangeList rangelist)
        {
            if (!hasAttribute(AttributeName.VALUELIST))
            {
                return(true);
            }
            return(getValueList().isPartOfRange(rangelist));
        }
        ///
        ///          <summary> * (20) get JDFDateTimeRangeList attribute ValueList </summary>
        ///          * <returns> JDFDateTimeRangeList the value of the attribute, null if a the
        ///          *         attribute value is not a valid to create a JDFDateTimeRangeList </returns>
        ///
        public virtual JDFDateTimeRangeList getValueList()
        {
            string strAttrName = "";
            JDFDateTimeRangeList nPlaceHolder = null;

            strAttrName = getAttribute(AttributeName.VALUELIST, null, JDFConstants.EMPTYSTRING);
            try
            {
                nPlaceHolder = new JDFDateTimeRangeList(strAttrName);
            }
            catch (FormatException)
            {
                return(null);
            }
            return(nPlaceHolder);
        }
Beispiel #5
0
        ///
        ///	 <summary> * fitsContainedList - tests for the case, when ListType=ContainedList, if
        ///	 * the defined <code>value</code> matches AllowedValueList or
        ///	 * PresentValueList, specified for this State
        ///	 *  </summary>
        ///	 * <param name="value">
        ///	 *            to test </param>
        ///	 * <param name="testlists">
        ///	 *            are either AllowedValueList or PresentValueList
        ///	 *  </param>
        ///	 * <returns> boolean - true, if <code>value</code> matches testlist </returns>
        ///
        private bool fitsContainedList(JDFDateTimeRangeList @value, JDFDateTimeRangeList 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);
        }
Beispiel #6
0
 ///
 ///	 <summary> * get attribute <code>PresentValueList</code>
 ///	 *  </summary>
 ///	 * <returns> the value of the attribute </returns>
 ///
 public virtual JDFDateTimeRangeList getPresentValueList()
 {
     if (hasAttribute(AttributeName.PRESENTVALUELIST))
     {
         JDFDateTimeRangeList r = null;
         try
         {
             r = new JDFDateTimeRangeList(getAttribute(AttributeName.PRESENTVALUELIST));
         }
         catch (FormatException)
         {
             return(null);
         }
         return(r);
     }
     return(getAllowedValueList());
 }
Beispiel #7
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">
        ///	 *            the test lists the value has to match. In this State the test
        ///	 *            lists are ValueList and ValueDurationList.<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 override bool fitsValue(string @value, EnumFitsValue testlists)
        {
            if (fitsListType(@value))
            {
                JDFDateTimeRangeList rangelist = null;
                try
                {
                    rangelist = new JDFDateTimeRangeList(@value);
                }
                catch (FormatException)
                {
                    return(false);
                }

                return(fitsValueList(rangelist, testlists) && fitsValueDurationList(rangelist, testlists));
            }
            return(false); // the value doesn't fit ListType attribute of this State
        }
//
//	 * // 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);
            }

            JDFDateTimeRangeList rangelist = null;

            try
            {
                rangelist = new JDFDateTimeRangeList(@value);
            }
            catch (FormatException)
            {
                return(false);
            }
            return(fitsValueList(rangelist) && fitsValueDurationList(rangelist));
        }
Beispiel #9
0
        ///
        ///	 <summary> * fitsCompleteList - tests for the case, when ListType=CompleteList, if
        ///	 * <code>value</code> 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 <code>value</code> matches testlist </returns>
        ///
        private bool fitsCompleteList(JDFDateTimeRangeList @value, JDFDateTimeRangeList list)
        {
            int v_size = @value.Count;
            int l_size = list.Count;

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

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

            JDFDateTimeRangeList valueList = new JDFDateTimeRangeList(@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);
        }
Beispiel #10
0
        //
        //	 * // Element getter / setter
        //
        //
        //	 * (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;
            }

            JDFDate date;

            try
            {
                date = new JDFDate(@value);
            }
            catch (FormatException)
            {
                return; // nop for bad values
            }
            if (testlists == null || EnumFitsValue.Allowed.Equals(testlists))
            {
                JDFDateTimeRangeList list = getAllowedValueList();
                if (list == null)
                {
                    list = new JDFDateTimeRangeList();
                }
                list.Append(date);
                setAllowedValueList(list);
            }
            if (testlists == null || EnumFitsValue.Present.Equals(testlists))
            {
                JDFDateTimeRangeList list = getPresentValueList();
                if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST))
                {
                    list = new JDFDateTimeRangeList();
                }
                list.Append(date);
                setPresentValueList(list);
            }
        }
Beispiel #11
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);
        }
Beispiel #12
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 <code>value</code> matches testlist </returns>
        ///
        private bool fitsCompleteOrderedList(JDFDateTimeRangeList @value, JDFDateTimeRangeList 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);
        }
Beispiel #13
0
///
///	 <summary> * fitsListType - tests, if the defined <code>value</code> matches the value
///	 * of the ListType attribute, specified for this Evaluation
///	 *  </summary>
///	 * <param name="value">
///	 *            value to test </param>
///	 * <returns> boolean - true, if <code>value</code> matches specified ListType </returns>
///
        private bool fitsListType(string @value)
        {
            EnumListType listType = getListType();

            JDFDateTimeRangeList rangelist;

            try
            {
                rangelist = new JDFDateTimeRangeList(@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 JDFDate(@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("JDFDateTimeEvaluation.fitsListType illegal ListType attribute");
            }
        }
Beispiel #14
0
//
//	 * // Attribute getter/ Setter
//

///
///	 <summary> * set attribute <code>ValueList</code>
///	 *  </summary>
///	 * <param name="value">
///	 *            the value to set the attribute to </param>
///
        public virtual void setValueList(JDFDateTimeRangeList @value)
        {
            setAttribute(AttributeName.VALUELIST, @value.ToString());
        }