示例#1
0
        public void LoadRun(Pc900Program program)
        {
            var port = CreateAndOpenPort();
            var pc900Translator = new Pc900Translator();

            Console.WriteLine("Sending Load commands");
            var command = pc900Translator.LoadCommand(program);
            
            ExecuteCommand(command, port);
        }
示例#2
0
        public int GetCurrentValue()
        {
            var port = CreateAndOpenPort();
            var pc900Translator = new Pc900Translator();

            Console.WriteLine("Sending GetCurrentValue command");
            var command = pc900Translator.GetCurrentValueCommand();

            var responses = ExecuteCommand(command, port);

            return ((GetCurrentValueCommandResponse)responses[0]).Value;
        }
示例#3
0
        public bool ProgramRunning()
        {
            var port = CreateAndOpenPort();
            var pc900Translator = new Pc900Translator();

            Console.WriteLine("Sending Currently Running command");
            var command = pc900Translator.CurrentlyRunningCommand();

            var responses = ExecuteCommand(command, port);

            return ((CurrentlyRunningCommandResponse)responses[0]).Running;
        }
示例#4
0
        public Pc900ProgramRun Start(Pc900Program program)
        {
            LoadRun(program);
            var port = CreateAndOpenPort();
            var pc900Translator = new Pc900Translator();

            Console.WriteLine("Sending Start command");
            var command = pc900Translator.StartCommand(program.id);
            
            ExecuteCommand(command, port);

            return new Pc900ProgramRun("1234");
        }
        public void ShouldReturnListOfCommandsToLoadProgram()
        {
            Pc900ProgramStep[] steps = {
                new Pc900ProgramStep(0, 0, 360),
                new Pc900ProgramStep(1, 180, 45)
            };
            var program = new Pc900Program(Guid.NewGuid().ToString(), "Program1", 1, steps);
            var loadCommand = new Pc900Translator().LoadCommand(program);
            var commandsList = loadCommand.CommandsList;

            Assert.That(commandsList[0], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x72, 0x31, 0x30, 0x30, 0x2E, 0x30, 0x30, 0x03, 0x6E }));
            Assert.That(commandsList[1], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x6c, 0x31, 0x30, 0x30, 0x30, 0x30, 0x03, 0x5E }));
            Assert.That(commandsList[2], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x74, 0x31, 0x30, 0x33, 0x36, 0x30, 0x03, 0x43 }));
            Assert.That(commandsList[3], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x72, 0x32, 0x30, 0x31, 0x2E, 0x30, 0x30, 0x03, 0x6C }));
            Assert.That(commandsList[4], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x6c, 0x32, 0x30, 0x31, 0x38, 0x30, 0x03, 0x54 }));
            Assert.That(commandsList[5], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x74, 0x32, 0x30, 0x30, 0x34, 0x35, 0x03, 0x44 }));

            Assert.That(commandsList[6], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x72, 0x33, 0x30, 0x30, 0x2E, 0x30, 0x30, 0x03, 0x6C }));
            Assert.That(commandsList[7], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x6c, 0x33, 0x30, 0x30, 0x30, 0x30, 0x03, 0x5C }));
            Assert.That(commandsList[8], Is.EqualTo(new List<byte> { 0x04, 0x30, 0x30, 0x31, 0x31, 0x02, 0x74, 0x33, 0x30, 0x30, 0x30, 0x30, 0x03, 0x44 }));
        }