コード例 #1
0
        public LimitCalculation(CalculationPreference preference)
        {
            this.preference = preference;
            string afattributepath = preference.sensorPath;
            string eventQuery      = preference.eventFrameQuery;

            calculationsToPerform = preference.getTraitDictionary();

            foreach (KeyValuePair <AFAttributeTrait, string> pair in calculationsToPerform)
            {
                bounds[pair.Key] = new AFValues();
            }
            sensor    = AFAttribute.FindAttribute(afattributepath, null);
            pisystem  = sensor.PISystem;
            afdatabse = sensor.Database;
            foreach (KeyValuePair <AFAttributeTrait, string> pair in calculationsToPerform)
            {
                boundAttributes[pair.Key] = sensor.GetAttributeByTrait(pair.Key);
            }

            eventFrameQuery = new AFEventFrameSearch(afdatabse, "eventFrameSearch", eventQuery);
            List <AFSearchToken> tokens = eventFrameQuery.Tokens.ToList();

            tokens.RemoveAll(t => t.Filter == AFSearchFilter.InProgress || t.Filter == AFSearchFilter.Start || t.Filter == AFSearchFilter.End);
            timeLessQuery = new AFEventFrameSearch(afdatabse, "AllEventFrames", tokens);
            InitialRun();
        }
コード例 #2
0
 public LimitCalculation(CalculationPreference preference, string calculationName)
 {
     this.calculationName = calculationName;
     try {
         logger.Info($"Starting calculations for {calculationName}");
         string afattributepath = preference.sensorPath;
         string eventQuery      = preference.eventFrameQuery;
         calculationsToPerform = preference.getTraitDictionary();
         offset          = preference.offset;
         this.preference = preference;
         sensor          = AFAttribute.FindAttribute(afattributepath, null);
         pisystem        = sensor.PISystem;
         afdatabase      = sensor.Database;
         foreach (KeyValuePair <AFAttributeTrait, string> pair in calculationsToPerform)
         {
             bounds[pair.Key] = new AFValues();
             AFAttribute possibleAttribute = sensor.GetAttributeByTrait(pair.Key);
             boundAttributes[pair.Key] = possibleAttribute;
             logger.Info($"Will perform calculation for limit: {pair.Key}");
             if (possibleAttribute == null)
             {
                 logger.Error($"{calculationName}: The limit {pair.Key} is not defined yet is used.");
             }
         }
         eventFrameQuery = new AFEventFrameSearch(afdatabase, "eventFrameSearch", eventQuery);
     }
     catch (System.Exception e)
     {
         logger.Error($"{calculationName} the following error occured: {e.Message}");
     }
     logger.Info($"{calculationName}: Doing the initial run");
     InitialRun();
 }