Пример #1
0
        /*
         * un costruttore di macchine ci ha chiesto di rendere più solida
         * la comunicazione con un meccanismo di watch dog, cioè i dati di PowerDevice
         * sono considerati validi solo se lo stesso vari ain continuazione
         * un indirizzo specifico. Ne consegue che utilizziamo lo schedulatore
         * interno del servizio per variare in continuazione un valore
         * (intero incrementato di uno ogni secondo)
         */

        private void SetupWriteWatchDogActivity()
        {
            this._ServiceManager.AppendMessageToLog(MessageLevel.Diagnostics, LOGGERSOURCE,
                                                    "SetupWriteWatchDogActivity(): called");

            //prendo un riferimento al servizio di schedulazione
            var scheduler = this._ServiceManager.Services.GetServiceOfType <ISchedulerService>();

            var interval   = TimeSpan.FromSeconds(1);
            var firstStart = DateTimeOffset.Now.AddMinutes(1);

            //creo l'oggetto per lo schedulatore
            var recurringActivity = new RecurringActivity(Guid.NewGuid(),
                                                          this._ComponentId,
                                                          firstStart,
                                                          this.WriteWatchDogTaskTriggerAction,
                                                          this.WriteWatchDogTaskErrorAction,
                                                          interval);

            //creo il job nello schedulatore
            if (scheduler.SubmitRecurringActivity(recurringActivity))
            {
                this._WriteWatchDogActivityId = recurringActivity.ActivityId;
                this._ServiceManager.AppendMessageToLog(MessageLevel.Diagnostics, LOGGERSOURCE,
                                                        "SetupWriteWatchDogActivity(): activity submitted -> "
                                                        + "'{0}' starting from: {1} interval: {2}",
                                                        recurringActivity.ActivityId.ToString(),
                                                        firstStart.ToString(), interval.ToString());
            }
            else
            {
                this._ServiceManager.AppendMessageToLog(MessageLevel.Diagnostics, LOGGERSOURCE,
                                                        "SetupWriteWatchDogActivity(): failed to submit activity.");
            }
        }
Пример #2
0
        private void SetupActivity()
        {
            _MesManager.ApplicationMainLogger.WriteMessage(MessageLevel.Diagnostics, false, LOGGERSOURCE,
                                                           "SetupActivity(): called");

            //prendo un riferimento al servizio di schedulazione
            var scheduler = _MesManager.ServiceManager.GetService <IJobSchedulerService>();

            //una volta al giorno, di notte
            var interval = new TimeSpan(1, 0, 0, 0);


            var offsetNow    = DateTimeOffset.Now;
            var firstTrigger = offsetNow.AddMinutes(5);

            //creo l'oggetto per lo schedulatore
            var recurringActivity = new RecurringActivity(Guid.NewGuid(),
                                                          _ComponentId,
                                                          firstTrigger,
                                                          TaskTriggerAction,
                                                          TaskErrorAction,
                                                          interval);

            //creo il job nello schedulatore
            if (scheduler.SubmitRecurringActivity(recurringActivity))
            {
                _ActivityId = recurringActivity.ActivityId;
                _MesManager.ApplicationMainLogger.WriteMessage(MessageLevel.Diagnostics, false, LOGGERSOURCE,
                                                               "SetupActivity(): activity submitted -> "
                                                               + "'{0}' starting from: {1} interval: {2}",
                                                               recurringActivity.ActivityId.ToString(),
                                                               firstTrigger.ToString(), interval.ToString());
            }
            else
            {
                _MesManager.ApplicationMainLogger.WriteMessage(MessageLevel.Diagnostics, false, LOGGERSOURCE,
                                                               "SetupActivity(): failed to submit activity.");
            }
        }
Пример #3
0
        private void SetupDieCastingProductionActivity()
        {
            this._MesManager.ApplicationMainLogger.WriteMessage(MessageLevel.Diagnostics, false, LOGRSOURCE,
                                                                "SetupDieCastingProductionActivity(): called");

            this._DieCastingProdActivityRunningMres.Reset();

            //prendo un riferimento al servizio di schedulazione
            var scheduler = this._MesManager.ServiceManager.GetService <IJobSchedulerService>();

            var interval   = TimeSpan.FromSeconds(10);
            var firstStart = DateTimeOffset.Now.AddMinutes(1);

            //creo l'oggetto per lo schedulatore
            var recurringActivity = new RecurringActivity(Guid.NewGuid(),
                                                          this._ComponentId,
                                                          firstStart,
                                                          this.DieCastingProductionTaskTriggerAction,
                                                          this.DieCastingProductionTaskErrorAction,
                                                          interval);

            //creo il job nello schedulatore
            if (scheduler.SubmitRecurringActivity(recurringActivity))
            {
                this._DieCastingProductionActivityId = recurringActivity.ActivityId;
                this._MesManager.ApplicationMainLogger.WriteMessage(MessageLevel.Diagnostics, false, LOGRSOURCE,
                                                                    "SetupDieCastingProductionActivity(): activity submitted -> "
                                                                    + "'{0}' starting from: {1} interval: {2}",
                                                                    recurringActivity.ActivityId.ToString(),
                                                                    firstStart.ToString(), interval.ToString());
            }
            else
            {
                this._MesManager.ApplicationMainLogger.WriteMessage(MessageLevel.Diagnostics, false, LOGRSOURCE,
                                                                    "SetupDieCastingProductionActivity(): failed to submit activity.");
            }
        }