public MainWindowViewModel(IDeviceValidator validator, INotificationService notificationService, IWindowManager manager)
        {
            this.validator           = validator;
            this.logger              = new TextLogger("../../../log.txt", true);
            this.notificationService = notificationService;
            Items             = new ObservableCollection <Device>();
            Connected         = false;
            this.manager      = manager;
            LogCommand        = new GUIICommand(ShowLogs);
            commandExecutor   = new CommandExecutor(logger);
            commandProcessor  = new CommandProcessor(notificationService, validator, commandExecutor, logger);
            alarmProcessor    = new AlarmProcessor(logger);
            automationManager = new AutomationManager(commandExecutor, Items, logger);


            try
            {
                LoadFromConfiguration();
                factory      = new ChannelFactory <IService>(new NetTcpBinding(), $"net.tcp://localhost:{servicePort}/WCFService");
                proxy        = factory.CreateChannel();
                Connected    = false;
                UpdateEvent += MainWindowViewModel_UpdateEvent;
                acquisitor   = new Acquisitor(Items, acquisitionInterval, factory, commandExecutor, logger, automationManager);
            }
            catch (Exception ex)
            {
                notificationService.ShowNotification("Server", $"Error: {ex.Message}, ST: {ex.StackTrace}", Notifications.Wpf.NotificationType.Error);
            }
        }
        public void Test_Add_1_And_2_Updates_Position_3_To_3()
        {
            int[] codes = { 1, 1, 2, 1 };

            var result = AlarmProcessor.Calculate((OpCode)codes[0], codes[1], codes[2]);

            Assert.Equal(3, result);
        }
        public void Test_Multiply_2_And_3_Updates_Position_3_To_6()
        {
            int[] codes = { 2, 2, 3, 3 };

            var result = AlarmProcessor.Calculate((OpCode)codes[0], codes[1], codes[2]);

            Assert.Equal(6, result);
        }
Beispiel #4
0
 private void ProcessAlarm(double eguValue)
 {
     alarm = AlarmProcessor.GetAlarmForAnalogPoint(eguValue, configItem);
     if (alarm != Common.AlarmType.NO_ALARM)
     {
         // string message = $" ima alarm";
         // this.stateUpdater.LogMessage(message);
     }
     OnPropertyChanged("Alarm");
 }
Beispiel #5
0
 protected override bool WriteCommand_CanExecute(object obj)
 {
     if (AlarmProcessor.GetAlarmForAnalogPoint(CommandedValue, configItem) == AlarmType.NO_ALARM)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #6
0
 protected override bool WriteCommand_CanExecute(object obj)
 {
     if (AlarmProcessor.CheckAlarmility(CommandedValue, configItem) == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #7
0
        public static int ProcessOpCodes(int[] codes, int noun, int verb)
        {
            codes[1] = noun;
            codes[2] = verb;

            for (var i = 0; i < codes.Length; i += 4)
            {
                if (!Enum.IsDefined(typeof(OpCode), codes[i]))
                {
                    break;
                }

                codes[codes[i + 3]] = AlarmProcessor.Calculate(
                    (OpCode)codes[i],
                    codes[codes[i + 1]],
                    codes[codes[i + 2]]
                    );
            }

            return(codes[0]);
        }
Beispiel #8
0
 private void ProcessAlarm(double eguValue)
 {
     alarm = AlarmProcessor.GetAlarmForAnalogPoint(eguValue, configItem);
     OnPropertyChanged("Alarm");
 }
Beispiel #9
0
 private void ProcessAlarm(ushort state)
 {
     alarm = AlarmProcessor.GetAlarmForDigitalPoint(RawValue, configItem);
     OnPropertyChanged("Alarm");
 }