Beispiel #1
0
 /// <summary>
 /// ProcessInfo
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 private Task ProcessInfoTimerCallback(ProcessInfoStatistics arg)
 {
     // memo: send metrics to datadog or any favor you like.
     DatadogTracing.ProcessInfoTimerGauge(arg);
     _logger.LogInformation($"ProcessInfo Cpu {arg.Cpu}; PrivateBytes {arg.PrivateBytes}; WorkingSet {arg.WorkingSet};");
     return(Task.CompletedTask);
 }
    public RealTimeHistoricDbService(
        IRtConnector connector,
        IHistoricRepository repository,
        ILoggerFactory loggerFactory,
        ProcessInfoStatistics processInfo,
        IOptions <RealTimeHistoricDBConfiguration> options)
    {
        this.logger           = loggerFactory.CreateLogger(nameof(WorkerService));
        this.connector        = connector;
        this.repository       = repository;
        this.processInfo      = processInfo;
        this.wsTags           = new Queue <List <TagChangeTracker> >();
        this.tagChangeManager = new TagChangeTrackerManager();
        this.lastCommit       = DateTime.Now;

        var intervalRefresh = options.Value.CheckTagChangeIntervalMilliseconds ?? 1000;
        var intervalCommit  = options.Value.SaveChangeIntervalSeconds ?? 5 * 60;

        this.checkTagChangeInterval = TimeSpan.FromMilliseconds(intervalRefresh > 100 ? intervalRefresh : 100);
        this.saveChangeInterval     = TimeSpan.FromSeconds(intervalCommit > 2 ? intervalCommit : 2);

        this.daysPresistence = options.Value.DaysPresistence ?? 30;

        logger.LogInformation("Initialize RealTimeHistoricDbWorker, checkTagChangeInterval time:{checkTagChangeInterval} " +
                              "saveChangeInterval time:{saveChangeInterval} daysPresistence:{daysPresistence}",
                              checkTagChangeInterval, saveChangeInterval, daysPresistence);
    }
Beispiel #3
0
 public ModbusTcpClientService(
     IRtConnector connector,
     ILoggerFactory loggerFactory,
     ProcessInfoStatistics processInfo,
     IOptions <RealTimeModbusTcpConfiguration> settings)
 {
     this.settings     = settings.Value;
     this.modbusClient = new ModbusClient(this.settings.IpAddress, this.settings.Port, this.settings.TimeoutSeconds * 1000);
     this.connector    = connector;
     this.processInfo  = processInfo;
     this.logger       = loggerFactory.CreateLogger(nameof(ModbusTcpClientService));
 }
Beispiel #4
0
 public TagRuleChangeExecutorService(
     IOptions <TagRuleExecutorConfiguration> settings,
     ILogger <TagRuleChangeExecutorService> logger,
     ProcessInfoStatistics statistics,
     IRtConnector connector)
 {
     this.settings               = settings.Value;
     this.logger                 = logger;
     this.processInfo            = statistics;
     this.connector              = connector;
     this.cacheTags              = new Dictionary <string, IRtTag>();
     this.tagRuleChangeEvaluator = new TagRuleChangeEvaluator <string>(ActionOnChange, this.settings.DefaultTolerance, this.settings.DefaultDiscardValue);
 }
 public TagRuleToDatabaseService(
     IOptions <TagRuleToDatabaseConfiguration> settings,
     IDatabaseManager database,
     ILogger <TagRuleToDatabaseService> logger,
     ProcessInfoStatistics processInfo,
     IRtConnector connector)
 {
     this.settings               = settings.Value;
     this.database               = database;
     this.logger                 = logger;
     this.processInfo            = processInfo;
     this.connector              = connector;
     this.cacheTags              = new Dictionary <string, IRtTag>();
     this.tagRuleChangeEvaluator = new TagRuleChangeEvaluator <string>(ActionOnChange, this.settings.DefaultTolerance, this.settings.DefaultDiscardValue);
 }