public AsyncInputFrameArgs(int servo1target, int servo2target, int ping1value, int ping2value, bool fpss, SensorsState sensState)
        {
            timestamp = DateTime.Now.Ticks;

            fromPingScanStop = fpss;

            dPos1Mks = ProximityBoard.servoTargetToMks(servo1target);
            dPos2Mks = ProximityBoard.servoTargetToMks(servo2target);

            dPing1DistanceM = ProximityBoard.pingValueToDistanceM(ping1value);
            dPing2DistanceM = ProximityBoard.pingValueToDistanceM(ping2value);

            sensorsState = sensState;
        }
示例#2
0
        public double ServoPositionGet(int servoNumber)
        {
            double dPosMks = 0;

            try
            {
                Tracer.Trace("PM Command::ServoPositionGet(" + servoNumber + ")");

                if (!myDeviceDetected)
                {
                    myDeviceDetected = FindTheHid(vendorId, productId);
                }

                if (myDeviceDetected)
                {
                    //  Set the size of the Output report buffer.

                    byte[] outputReportBuffer = new byte[MyHid.Capabilities.OutputReportByteLength];

                    //  Store the report ID (command) in the first byte of the buffer:

                    outputReportBuffer[0] = OUTPUT_REPORT_ID;                             // will turn out on the board as Output Report ID

                    outputReportBuffer[1] = (byte)ProximityBoardCommand.ServoPositionGet; // will be analyzed in a switch

                    outputReportBuffer[2] = (byte)servoNumber;                            // which servo

                    byte[] inputReportBuffer = ReadAndWriteToDevice(outputReportBuffer, INPUT_REPORT_ID);

                    // data bytes 1 and 2 of the Input Report contain servo position:

                    int servotarget = intFromBuffer(inputReportBuffer, 1);

                    dPosMks = ProximityBoard.servoTargetToMks(servotarget);
                }
                else
                {
                    Tracer.Error("FindTheHid() unsuccessful, skipped the ServoPositionGet command");
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex);
                throw;
            }

            return(dPosMks);
        }