Exemplo n.º 1
0
        /// <summary>
        /// The MeasurerService calls Process method periodically as defined in plugin's config ExecuteInterval element. The time is seconds.
        /// Note that the same instance of this class is alive the whole time as the service is alive! So make this process as sleek and lean as possible.
        /// </summary>
        public void Process()
        {
            //library takes the config and a Logger instance
            PilotLib pl = new PilotLib(pc, Log);

            //librarys only public facing method return a MeasurementPackage
            MeasurementPackage mp = pl.GetMeasurementPackage();

            // When your plugin has something to save raise ProcessCompleted event. The Name property can be used as ProcessCompletedEventArgs source parameter.
            // If at some point your plugin has nothing to save, then don't raise the event.
            if (mp != null && mp.Measurements != null && mp.Measurements.Count > 0)
            {
                //Update and save the configuration files LastMeasurementTime for each file
                pc.UpdateLastMeasurementTime(pl.NewLastMeasurementTime);
                PilotConfig.SavePilotConfig(ConfigurationFile.GetPluginRootedPath(), pc);

                this.OnProcessCompleted(new ProcessCompletedEventArgs(this.Name, mp));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor which sets PilotLib's configuration parameters to be used in the process
 /// Also set the logger instance
 /// </summary>
 /// <param name="_config"></param>
 public PilotLib(PilotConfig _config, Logger _log)
 {
     Config = _config;
     Log    = _log;
 }
Exemplo n.º 3
0
 public static void SavePilotConfig(string configpath, PilotConfig pc)
 {
     File.WriteAllText(configpath, JsonConvert.SerializeObject(pc));
 }
Exemplo n.º 4
0
 /// <summary>
 /// The MeasurerService calls Dispose method when the service is closing.
 /// </summary>
 public void Dispose()
 {
     this.pc = null;
 }
Exemplo n.º 5
0
 /// <summary>
 /// The MeasurerService calls LoadConfig method after the properties are set.
 /// </summary>
 public void LoadConfig()
 {
     //pilotconfig returns itself
     pc = PilotConfig.GetPilotConfig(ConfigurationFile.GetPluginRootedPath());
 }