Пример #1
0
        private void InitializeProtocols()
        {
            var protocol1 = new CommProtocol();
            var request   = new RequestItem(new byte[2] {
                0x20, 0x58
            }, true);

            protocol1.AddRequestWithDefaultOperation(request);

            _communicationProtocols.Add(InstructionType.PowerOff, protocol1);

            var protocol2 = new CommProtocol();

            request = new RequestItem(new byte[2] {
                0x20, 0x59
            }, true);

            protocol2.AddRequestWithDefaultOperation(request);

            _communicationProtocols.Add(InstructionType.Query, protocol2);


            var protocol3 = new CommProtocol();

            request = new RequestItem(new byte[2] {
                0x20, 0x5B
            }, true);
            protocol3.AddRequestWithDefaultOperation(request);
            _communicationProtocols.Add(InstructionType.MarkerStimulate, protocol3);
        }
Пример #2
0
 public CommProtocol BuildProtocol(byte[] detail)
 {
     if (IsValidDetail(detail))
     {
         var protocol4 = new CommProtocol();
         var request   = new RequestItem(detail, true);
         protocol4.AddRequestWithDefaultOperation(request);
         _communicationProtocols.Add(InstructionType.Setting, protocol4);
         return(protocol4);
     }
     return(null);
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            commProtocol = new CommProtocol(UGVStationNodeID);
            commProtocol.initializeConnection(commPort, 57600);
            // Add UGV destination node and MAC address
            commProtocol.addAddress(7, "0013A20040A54318");

            //link call backs
            commProtocol.LinkCallback(new NGCP.VehicleWaypointCommand(), new Comnet.CallBack(VehicleWaypointCommandCallback));
            commProtocol.LinkCallback(new NGCP.VehicleModeCommand(), new Comnet.CallBack(VehicleModeCommandCallback));
            commProtocol.LinkCallback(new NGCP.ArmCommand(), new Comnet.CallBack(ArmCommandCallback));
            commProtocol.LinkCallback(new NGCP.VehicleSystemStatus(), new Comnet.CallBack(VehicleSystemStatusCallback));
            commProtocol.LinkCallback(new NGCP.VehicleGlobalPosition(), new Comnet.CallBack(VehicleGlobalPositionCallback));
            commProtocol.LinkCallback(new NGCP.SpeedSteeringCommand(), new Comnet.CallBack(SpeedSteeringCommandCallback));

            commProtocol.start();
        }
Пример #4
0
        static void Main(string[] args)
        {
            if (Settings.UseCommProtocol)
            {
                commProtocol = new CommProtocol(Settings.CommNode);
                commProtocol.initializeConnection(Settings.CommPort, Settings.CommBaud);
                //parse address to add
                //this is a bad way to do this should be changed michael wallace 5/12/2017
                string[] words       = Settings.CommAddresses.Split(null);
                int[]    destNode    = Array.ConvertAll(words.Where((str, ix) => ix % 2 == 0).ToArray(), int.Parse); //even
                string[] destAddress = words.Where((str, ix) => ix % 2 == 1).ToArray();                              //odd
                if (destNode.Length == destAddress.Length)
                {
                    for (int x = 0; x < destNode.Length; x++)
                    {
                        commProtocol.addAddress(destNode[x], destAddress[x]);
                    }
                }
                //link call backs
                commProtocol.LinkCallback(new NGCP.VehicleWaypointCommand(), new Comnet.CallBack(VehicleWaypointCommandCallback));
                commProtocol.LinkCallback(new NGCP.VehicleModeCommand(), new Comnet.CallBack(VehicleModeCommandCallback));
                commProtocol.LinkCallback(new NGCP.ArmCommand(), new Comnet.CallBack(ArmCommandCallback));
                commProtocol.LinkCallback(new NGCP.VehicleSystemStatus(), new Comnet.CallBack(VehicleSystemStatusCallback));

                commProtocol.start();
            }

            State = NGCP.UGV.UGV.DriveState.DriveAwayFromTarget;

            while (true)
            {
                Console.ReadLine();
                Console.WriteLine("test package sent\n");
                commProtocol.SendState(new UGVState(), 100);
            }
        }
Пример #5
0
 public override void initProtocol(CommProtocol protocol)
 {
     this.protocol = (SnakeProtocol)protocol;
 }
 public override void initProtocol(CommProtocol protocol)
 {
     this.protocol = (SoldiersProtocol)protocol;
 }
Пример #7
0
 public override void initProtocol(CommProtocol protocol)
 {
     this.protocol = (BrakethroughProtocol)protocol;
 }
Пример #8
0
 public void init(CommProtocol prot, GameMaster controller)
 {
     currentProtocol        = prot;
     this.currentController = controller;
 }
 public override void initProtocol(CommProtocol protocol)
 {
     this.protocol = (BombermanProtocol)protocol;
 }
 public override void initProtocol(CommProtocol protocol)
 {
     this.protocol = (SpeedRunnerProtocol)protocol;
 }