Esempio n. 1
0
        private AFValues filterValues(AFValues baseReturnVals)
        {
            AFValues filteredReturnVals = new AFValues();

            if (ConfigString.Split(';')[2] == "convertRadio")
            {
                filteredReturnVals = baseReturnVals;
            }
            else //formatRadio
            {
                //filter out values where the next value is within 1 second
                //this eliminates the problem where the date and time PLC addresses change at slightly different times within 1 second
                //e.g. the date changes to 10/10 right before the time changes to 11:15 from 12:00, then you have an extra filldate of 10/10 12:00 am that is not valid
                for (int i = 0; i < baseReturnVals.Count - 1; i++)
                {
                    if ((baseReturnVals[i + 1].Timestamp - baseReturnVals[i].Timestamp) > new TimeSpan(0, 0, 1))
                    {
                        filteredReturnVals.Add(baseReturnVals[i]);
                    }
                }
                //always add the last value since there is nothing to compare it to
                filteredReturnVals.Add(baseReturnVals[baseReturnVals.Count - 1]);
            }
            return(filteredReturnVals);
        }
Esempio n. 2
0
        //calculate value of attribute
        public override AFValue GetValue(object context, object timeContext, AFAttributeList inputAttributes, AFValues inputValues)
        {
            string[] splitConfig    = ConfigString.Split(';');
            string   selectedOption = splitConfig[2];

            if (selectedOption == "convertRadio")
            {
                return(PLCTimeConvert(inputValues[0], splitConfig[0]));
            }
            else //selectedOption == "formatRadio"
            {
                AFValue dateVal = inputValues[0];
                AFValue timeVal = inputValues[1];
                return(PLCTimeFormatExecution(dateVal, timeVal));
            }
        }
Esempio n. 3
0
        //bring in PIPoint attributes
        public override AFAttributeList GetInputs(object context)
        {
            AFAttributeList returnList = new AFAttributeList();

            string[] splitConfig    = ConfigString.Split(';');
            string   selectedOption = splitConfig[2];

            if (selectedOption == "convertRadio")
            {
                //config string is "initial date;name of attribute"
                AFAttribute minSinceAttributeObj = GetAttribute(splitConfig[1]);
                returnList.Add(minSinceAttributeObj);
            }
            else //selectedOption == "formatRadio"
            {
                //config string is "name of date attribute;name of time attribute"
                AFAttribute dateAttributeObj = GetAttribute(splitConfig[0]);
                AFAttribute timeAttributeObj = GetAttribute(splitConfig[1]);
                returnList.Add(dateAttributeObj);
                returnList.Add(timeAttributeObj);
            }

            return(returnList);
        }