示例#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
 static void Main(string[] args)
 {
     Pc900ProgramStep[] steps = {
         new Pc900ProgramStep(2, 3, 4),
         new Pc900ProgramStep(7, 8, 9)
     };
     Pc900Program program = new Pc900Program(Guid.NewGuid().ToString(), "Program1", 1, steps);
     var reworkStation = new ReworkStation();
     reworkStation.LoadRun(program);
     reworkStation.Start(program);
 }
示例#3
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 Pc900Command LoadCommand(Pc900Program program)
        {
            List<List<byte>> commandsList = new List<List<byte>>();

            for(byte stepIdx=1; stepIdx<program.steps.Length+1; stepIdx++)
            {
                var step = program.steps[stepIdx-1];
                commandsList.Add(GenerateCommandWithBcc(ADR_1, Ramp(stepIdx, step.ramp)));
                commandsList.Add(GenerateCommandWithBcc(ADR_1, Level(stepIdx, step.level)));
                commandsList.Add(GenerateCommandWithBcc(ADR_1, Dwell(stepIdx, step.dwell)));
            }

            return new Pc900Command(commandsList, LoadCommandResponseDelegate(program), 1);
        }
        public void ShouldUpdateProgram()
        {
            Pc900ProgramStep[] steps = new Pc900ProgramStep[1];
            steps[0] = new Pc900ProgramStep(10,20,40);
            Pc900Program pc900Program = new Pc900Program("iamaguid_2", "new name", 85, steps);
            Pc900Program[] programs = new Pc900Program[] {pc900Program};
            HttpResponseMessage response = _client.PostAsync("/programs", new StringContent(JArray.FromObject(programs).ToString(), Encoding.UTF8, "application/json")).Result;
            Assert.That(response.IsSuccessStatusCode, Is.True);

            response = _client.GetAsync("/programs").Result;
            String responseBody = response.Content.ReadAsStringAsync().Result;
            Assert.That(response.IsSuccessStatusCode, Is.True);
            Assert.IsFalse(responseBody.Contains(@"""loop_counter"": 35"));
            Assert.That(responseBody, Contains.Substring(@"""loop_counter"": 85"));
        }
        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 }));
        }
 private HttpResponseMessage LoadProgram()
 {
     Pc900ProgramStep[] steps = new Pc900ProgramStep[1];
     steps[0] = new Pc900ProgramStep(10, 20, 40);
     Pc900Program pc900Program = new Pc900Program("new_id", "new name", 85, steps);
     Pc900Program[] programs = { pc900Program };
     HttpResponseMessage response =
         _client.PostAsync("/programs",
             new StringContent(JArray.FromObject(programs).ToString(), Encoding.UTF8, "application/json")).Result;
     return response;
 }
 public Pc900ProgramRun Start(Pc900Program program)
 {
     _currentRunTemperature = 0;
     _currentRunCounter = 0;
     return new Pc900ProgramRun(program.id);
 }
 public static Func<List<byte>, CommandResponse> LoadCommandResponseDelegate(Pc900Program program)
 {
     Func<List<byte>, CommandResponse> handleResponse = commandResponse => new CommandResponse();
     return handleResponse;
 }