Beispiel #1
0
        public void Should_serialize_and_deserialize_status()
        {
            StatusSerializer.Register();

            var source = new TestObject
            {
                Status = Status.Published
            };

            var document = new BsonDocument();

            using (var writer = new BsonDocumentWriter(document))
            {
                BsonSerializer.Serialize(writer, source);

                writer.Flush();
            }

            using (var reader = new BsonDocumentReader(document))
            {
                var result = BsonSerializer.Deserialize <TestObject>(reader);

                Assert.Equal(source.Status, result.Status);
            }
        }
        protected override void Set_L_motorDIR(bool value)
        {
            preinfo_L_motorDIR = value;
            string msg = StatusSerializer.SerializeSingleMotorSpeed('i', value);

            btCore.GetComponent <PingPongManager>().CommandEnqueue(msg);
        }
Beispiel #3
0
            public StatusSerializerTest()
            {
                Container = new Mock <IContainerWrapper>();

                Serializer = new StatusSerializer(
                    Container.Object,
                    Mock.Of <ILogger <StatusSerializer> >());
            }
        protected override void Set_L_motorpower(byte value)
        {
            if (HalfManualMode == true)
            {
                if (preinfo_L_motorDIR == true)//front
                {
                    if (rh_sonardist > 10 || lh_sonardist > 10)
                    {
                        return;
                    }
                }
            }

            string msg = StatusSerializer.SerializeSingleMotorSpeed('g', value);

            btCore.GetComponent <PingPongManager>().CommandEnqueue(msg);
        }
Beispiel #5
0
    void SendMovePacketByKey()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(255, 255, true, true));
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(255, 255, false, true));
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(255, 255, false, false));
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(255, 255, true, false));
        }

        if (Input.GetKeyUp(KeyCode.W))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(0, 0, true, true));
        }
        else if (Input.GetKeyUp(KeyCode.A))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(0, 0, true, true));
        }
        else if (Input.GetKeyUp(KeyCode.S))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(0, 0, true, true));
        }
        else if (Input.GetKeyUp(KeyCode.D))
        {
            ppManager.CommandEnqueue(StatusSerializer.SerializeMotorSpeed(0, 0, true, true));
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            carDivice.lf_LED = !carDivice.lf_LED;
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            carDivice.rf_LED = !carDivice.rf_LED;
        }
        if (Input.GetKeyDown(KeyCode.Z))
        {
            carDivice.lb_LED = !carDivice.lb_LED;
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            carDivice.rb_LED = !carDivice.rb_LED;
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            if (carDivice.lf_LED || carDivice.rf_LED)
            {
                carDivice.lf_LED = false;
                carDivice.rf_LED = false;
            }
            else
            {
                carDivice.lf_LED = true;
                carDivice.rf_LED = true;
            }
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            if (carDivice.lb_LED || carDivice.rb_LED)
            {
                carDivice.lb_LED = false;
                carDivice.rb_LED = false;
            }
            else
            {
                carDivice.lb_LED = true;
                carDivice.rb_LED = true;
            }
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            if (carDivice.lf_LED || carDivice.rf_LED || carDivice.lb_LED || carDivice.rb_LED)
            {
                carDivice.lf_LED = false;
                carDivice.rf_LED = false;
                carDivice.lb_LED = false;
                carDivice.rb_LED = false;
            }
            else
            {
                carDivice.lb_LED = true;
                carDivice.rb_LED = true;
                carDivice.lf_LED = true;
                carDivice.rf_LED = true;
            }
        }
    }
        protected override void Set_LB_LED(bool value)
        {
            string msg = StatusSerializer.SerializeLEDPower('m', value);

            btCore.GetComponent <PingPongManager>().CommandEnqueue(msg);
        }