Exemplo n.º 1
0
        public void InteractWithControllerCommandTest()
        {
            IControllerTree controllerTree     = _testee.ImportControllerTree(null);
            var             cylinderController = controllerTree.TryGetController(CylinderCtrlId);

            cylinderController.SendParameter("udiSimExtendTime_ms", 10); // simulate faster to speed up unit test
            cylinderController.SendParameter("udiSimRetractTime_ms", 10);
            Thread.Sleep(700);

            // start cylinder controller
            var extendCommand = (from c in cylinderController.Commands
                                 where c.Name.Equals("Extend", StringComparison.InvariantCultureIgnoreCase)
                                 select c).First();

            extendCommand.Fire();
            Thread.Sleep(700);
            controllerTree     = _testee.ImportControllerTree(null);
            cylinderController = controllerTree.TryGetController(CylinderCtrlId);
            cylinderController.CurrentState.Should().Be("cSTA_EXTEND");

            // stop cylinder controller
            var retractCommand = (from c in cylinderController.Commands
                                  where c.Name.Equals("Retract", StringComparison.InvariantCultureIgnoreCase)
                                  select c).First();

            retractCommand.Fire();
            Thread.Sleep(500);
            controllerTree     = _testee.ImportControllerTree(null);
            cylinderController = controllerTree.TryGetController(CylinderCtrlId);
            cylinderController.CurrentState.Should().Be("cSTA_RETRACT");
        }
        private void RaiseAlarmAddedEvent(IEnumerable <Impl.Alarm> alarms)
        {
            var entityAlarms = from alarm in alarms
                               let controller = _controllerTree.TryGetController(alarm.SourceControllerId)
                                                let entitiesAlarm = this.CopyPlcAlarmToAlarm(alarm, controller != null ? controller.PlcControllerPath : string.Empty)
                                                                    select entitiesAlarm;

            foreach (var a in entityAlarms)
            {
                AlarmAdded(a);
            }
        }
Exemplo n.º 3
0
        public void WhenGetSpecificController_ShouldReturnInstance()
        {
            IControllerTree controllerTree = _testee.ImportControllerTree(null);

            var modController = controllerTree.TryGetController(1);

            modController.Should().NotBeNull("controller id 1 is fbMOD_2");
        }
Exemplo n.º 4
0
        public void WhenSendControllerParameter_ShouldWriteToPlc()
        {
            IControllerTree controllerTree = _testee.ImportControllerTree(null);
            var             modController  = controllerTree.TryGetController(RootCtrlId);
            var             parameterTag   = modController.Parameters.First(t => t.NestedName == "udiWaitPick_ms");

            modController.SendParameter(new Tag("udiWaitPick_ms", string.Empty, "UDINT")
            {
                Value = 1000
            });                                                                                             // long syntax
            Thread.Sleep(500);
            _tagListener.ReadTagSynchronously(parameterTag);
            parameterTag.Value.Should().Be((uint)1000);

            modController.SendParameter("udiWaitPick_ms", 3000); // short syntax
            Thread.Sleep(500);
            _tagListener.ReadTagSynchronously(parameterTag);
            parameterTag.Value.Should().Be((uint)3000);
        }