コード例 #1
0
        public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo)
        {
            // TODO work in progress

            switch (pltInfo.m_serviceType)
            {
            case PLTService.MOTION_TRACKING_SVC:
                PLTMotionTrackingData trackingdata = (PLTMotionTrackingData)pltInfo.m_data;
                //DebugPrint(MethodInfo.GetCurrentMethod().Name, "Motion Tracking Update received:\r\n" +
                //    "raw q0: " + trackingdata.m_rawquaternion[0] + "\r\n" +
                //    "raw q1: " + trackingdata.m_rawquaternion[1] + "\r\n" +
                //    "raw q2: " + trackingdata.m_rawquaternion[2] + "\r\n" +
                //    "raw q3: " + trackingdata.m_rawquaternion[3]);
                DebugPrint(MethodInfo.GetCurrentMethod().Name, "Motion Tracking Update received:\r\n" +
                           "heading: " + trackingdata.m_orientation[0] + "\r\n" +
                           "pitch: " + trackingdata.m_orientation[1] + "\r\n" +
                           "roll: " + trackingdata.m_orientation[2]);
                break;

            case PLTService.SENSOR_CAL_STATE_SVC:
                PLTSensorCal sensorcaldata = (PLTSensorCal)pltInfo.m_data;
                DebugPrint(MethodInfo.GetCurrentMethod().Name, "Sensor calibration update received:\r\n" +
                           "Gyros calibrated?: " + sensorcaldata.m_isgyrocal + "\r\n" +
                           "Magnetometer calibrated?: " + sensorcaldata.m_ismagnetometercal);
                break;
            }
        }
コード例 #2
0
        public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo)
        {
            if (pltInfo != null && pltInfo.m_data != null)
            {
                switch (pltInfo.m_serviceType)
                {
                case PLTService.SENSOR_CAL_STATE_SVC:
                    PLTSensorCal caldata = (PLTSensorCal)pltInfo.m_data;
                    m_calibrated = caldata.m_isgyrocal;
                    break;

                case PLTService.MOTION_TRACKING_SVC:
                    PLTMotionTrackingData motiondata = (PLTMotionTrackingData)pltInfo.m_data;
                    HeadsetTrackingUpdate(motiondata);
                    break;

                case PLTService.WEARING_STATE_SVC:
                    PLTWearingState weardata = (PLTWearingState)pltInfo.m_data;
                    m_worn = weardata.m_worn;
                    if (weardata.m_worn && !weardata.m_isInitialStateEvent)
                    {
                        // headset was put on
                        // lets auto calibrate
                        m_autoputoncalibratetimer.Start();
                    }
                    break;
                }
            }
        }
コード例 #3
0
        public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo)
        {
            switch (pltInfo.m_serviceType)
            {
            case PLTService.MOTION_TRACKING_SVC:
                PLTMotionTrackingData tracking = (PLTMotionTrackingData)pltInfo.m_data;
                PlantronicsMessage    msg      = new PlantronicsMessage(
                    pltInfo.m_serviceType.ToString(),
                    "heading"
                    );
                msg.Payload.Add("orientation",
                                (int)tracking.m_orientation[0] + "," +
                                (int)tracking.m_orientation[1] + "," +
                                (int)tracking.m_orientation[2]);
                BroadcastMessage(msg
                                 );
                break;

            case PLTService.SENSOR_CAL_STATE_SVC:
                PLTSensorCal calinfo = (PLTSensorCal)pltInfo.m_data;
                if (calinfo.m_isgyrocal != m_gyrocal)
                {
                    PlantronicsMessage msg2 = new PlantronicsMessage(pltInfo.m_serviceType.ToString(),
                                                                     "gyrocalibinfo"
                                                                     );
                    msg2.Payload.Add("gyrocalibrated",
                                     calinfo.m_isgyrocal.ToString());
                    BroadcastMessage(
                        msg2
                        );
                }
                m_gyrocal = calinfo.m_isgyrocal;
                break;
            }
        }
コード例 #4
0
        public void ConnectionOpen(PLTConnection pltConnection)
        {
            m_pltConnection = pltConnection;

            if (m_pltConnection != null)
            {
                pltlabsapi.subscribe(PLTService.MOTION_TRACKING_SVC, PLTMode.On_Change);
                pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Calibrated);
                pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Format_Orientation);
                pltlabsapi.subscribe(PLTService.SENSOR_CAL_STATE_SVC, PLTMode.On_Change);
            }
        }
コード例 #5
0
        public void ConnectionOpen(PLTConnection pltConnection)
        {
            m_pltConnection = pltConnection;

            if (pltConnection != null)
            {
                m_myMotionTrackingDevice = pltConnection.m_device.m_device;

                DebugPrint(MethodInfo.GetCurrentMethod().Name, "Success! Connection was opened!: " + pltConnection.m_device.m_ProductName);

                // lets register for headtracking service
                DebugPrint(MethodInfo.GetCurrentMethod().Name, "About to register for head tracking data.");
                //m_pltlabsapi.subscribe(PLTService.MOTION_TRACKING_SVC, PLTMode.On_Change);
                m_pltlabsapi.subscribe(PLTService.MOTION_TRACKING_SVC, PLTMode.Periodic, 200);

                //m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Raw);
                m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Calibrated);
                //m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Calibrated,
                //    new PLTQuaternion
                //    {
                //        m_quaternion = new double[4] { 1.0d, 0.0d, 0.0d, 0.0d }
                //    });
                //m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Format_Quaternion);
                m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Format_Orientation);

                m_pltlabsapi.subscribe(PLTService.SENSOR_CAL_STATE_SVC, PLTMode.Periodic, 500);

                // register for headset wearing state
                m_pltlabsapi.subscribe(PLTService.WEARING_STATE_SVC, PLTMode.Periodic, 500);

                // check we subcribed ok...
                DebugPrintSubscribedServices();

                ConnStatusLbl.Dispatcher.Invoke(new Action(delegate()
                {
                    if (pltConnection != null)
                    {
                        ConnStatusLbl.Content = "Yes";
                        DeviceLbl.Content     = m_pltConnection.DeviceName;
                    }
                    else
                    {
                        ConnStatusLbl.Content = "No";
                        DeviceLbl.Content     = "-";
                    }
                }));
            }
        }
コード例 #6
0
        public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo)
        {
            // make sure we have some data...
            if (pltInfo != null && pltInfo.m_data != null)
            {
                switch (pltInfo.m_serviceType)
                {
                case PLTService.MOTION_TRACKING_SVC:
                    PLTMotionTrackingData trackingdata = (PLTMotionTrackingData)pltInfo.m_data;
                    //DebugPrint(MethodInfo.GetCurrentMethod().Name, "Motion Tracking Update received:\r\n" +
                    //"raw q0: " + trackingdata.m_rawquaternion[0] + "\r\n" +
                    //"raw q1: " + trackingdata.m_rawquaternion[1] + "\r\n" +
                    //"raw q2: " + trackingdata.m_rawquaternion[2] + "\r\n" +
                    //"raw q3: " + trackingdata.m_rawquaternion[3]);
                    // great we got some angles - lets update the GUI!
                    HeadsetTrackingUpdateGUI(trackingdata);
                    break;

                case PLTService.MOTION_STATE_SVC:
                    // NOTE: this service is not yet available, no data will come here
                    break;

                case PLTService.SENSOR_CAL_STATE_SVC:
                    PLTSensorCal caldata = (PLTSensorCal)pltInfo.m_data;
                    UpdateCalibrationGUI(caldata);
                    break;

                case PLTService.PEDOMETER_SVC:
                    PLTPedometerCount peddata = (PLTPedometerCount)pltInfo.m_data;
                    m_lastpedometercount = peddata.m_pedometercount;
                    if (m_lastpedometerreset == -1)
                    {
                        m_lastpedometerreset = m_lastpedometercount;
                    }
                    UpdatePedometerGUI();
                    break;

                case PLTService.TAP_SVC:
                    UpdateTapInfoGUI((PLTTapInfo)pltInfo.m_data);
                    break;

                case PLTService.WEARING_STATE_SVC:
                    PLTWearingState wearingstate = (PLTWearingState)pltInfo.m_data;
                    DebugPrint(MethodInfo.GetCurrentMethod().Name, "Wearing State Update received:\r\n" +
                               "Is Worn?: " + wearingstate.m_worn + "\r\n" +
                               "Initial State?: " + wearingstate.m_isInitialStateEvent);
                    if (wearingstate.m_worn && !wearingstate.m_isInitialStateEvent)
                    {
                        // they have put headset on, start the auto calibrate timer
                        // to zero angles in 2 seconds time
                        m_autoputoncalibratetimer.Start();
                    }
                    break;

                case PLTService.FREE_FALL_SVC:
                    UpdateFreeFallGUI((PLTFreeFall)pltInfo.m_data);
                    break;

                case PLTService.PROXIMITY_SVC:
                    PLTProximity proximitystate = (PLTProximity)pltInfo.m_data;
                    DebugPrint(MethodInfo.GetCurrentMethod().Name, "Proximity State Update received:\r\n" +
                               "Proximity State: " + proximitystate.m_proximity);
                    break;

                case PLTService.CALLERID_SVC:
                    PLTCallerId callerid = (PLTCallerId)pltInfo.m_data;
                    DebugPrint(MethodInfo.GetCurrentMethod().Name, "Caller Id Update received:\r\n" +
                               "Caller Id: " + callerid.m_callerid + "\r\n" +
                               "Line type: " + callerid.m_calltype);
                    break;

                case PLTService.CALLSTATE_SVC:
                    PLTCallStateInfo callinfo = (PLTCallStateInfo)pltInfo.m_data;
                    DebugPrint(MethodInfo.GetCurrentMethod().Name, "Call State Update received:\r\n" +
                               "Call State Event Type: " + callinfo.m_callstatetype + "\r\n" +
                               "Call Status: " + callinfo.m_callstate + "\r\n" +
                               "Internal Call Id: " + callinfo.m_callid + "\r\n" +
                               "Call Source: " + callinfo.m_callsource + "\r\n" +
                               "Was Incoming?: " + callinfo.m_incoming);
                    break;

                case PLTService.DOCKSTATE_SVC:
                    PLTDock dockedstate = (PLTDock)pltInfo.m_data;
                    DebugPrint(MethodInfo.GetCurrentMethod().Name, "Docked State Update received:\r\n" +
                               "Docked State: " + dockedstate.m_isdocked + "\r\n" +
                               "Is Initial State?: " + dockedstate.m_isinitialstatus);
                    break;

                case PLTService.CHARGESTATE_SVC:
                    UpdateBatteryLevelGUI((PLTBatteryState)pltInfo.m_data);
                    break;
                }
            }
            else
            {
                // no data...
                DebugPrint(MethodInfo.GetCurrentMethod().Name, "WARNING: no data for service subscription:\r\n" +
                           "SERVICE: " + (pltInfo != null ? pltInfo.m_serviceType.ToString() : "null"));
            }
        }
コード例 #7
0
        public void ConnectionOpen(PLTConnection pltConnection)
        {
            m_pltConnection = pltConnection;

            if (pltConnection != null)
            {
                DebugPrint(MethodInfo.GetCurrentMethod().Name, "Success! Connection was opened!: " + pltConnection.m_device.m_ProductName);

                UpdateVersionInfoGUI();

                DebugPrint(MethodInfo.GetCurrentMethod().Name, "About to register for headset services.");

                // 1. MOTION_TRACKING_SVC Lets register for headtracking service:
                //m_pltlabsapi.subscribe(PLTService.MOTION_TRACKING_SVC, PLTMode.On_Change);
                m_pltlabsapi.subscribe(PLTService.MOTION_TRACKING_SVC, PLTMode.Periodic, 200);

                // Example: configure motion tracking to utilise uncalibrated (raw) quaternions:
                //m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Raw);

                // Example: configure motion tracking to utilise calibrated quaternions (based on current quaternion):
                m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Calibrated);

                // Example: configure motion tracking to utilise calibrated quaternions (based on user-specified quaternion):
                //m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Offset_Calibrated,
                //    new PLTQuaternion
                //    {
                //        m_quaternion = new double[4] { 1.0d, 0.0d, 0.0d, 0.0d }
                //    });

                // Example: configure motion tracking to provide angles in quaternion format:
                //m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Format_Quaternion);

                // Example: configure motion tracking to provide angles in orientation format (heading,pitch,roll):
                m_pltlabsapi.configureService(PLTService.MOTION_TRACKING_SVC, PLTConfiguration.MotionSvc_Format_Orientation);

                // 2. MOTION_STATE_SVC Lets register for motion state service
                // (NOTE: not currently implemented, so commenting out)
                //m_pltlabsapi.subscribe(PLTService.MOTION_STATE_SVC, PLTMode.Periodic, 500);

                // 3. SENSOR_CAL_STATE_SVC
                m_pltlabsapi.subscribe(PLTService.SENSOR_CAL_STATE_SVC, PLTMode.Periodic, 500);
                //m_pltlabsapi.subscribe(PLTService.SENSOR_CAL_STATE_SVC, PLTMode.On_Change);

                // 4. PEDOMETER_SVC
                m_pltlabsapi.subscribe(PLTService.PEDOMETER_SVC, PLTMode.On_Change);

                // 5. TAP_SVC
                m_pltlabsapi.subscribe(PLTService.TAP_SVC, PLTMode.On_Change);

                // 6. WEARING_STATE_SVC Lets register for wearing state service
                //m_pltlabsapi.subscribe(PLTService.WEARING_STATE_SVC, PLTMode.Periodic, 1000);
                m_pltlabsapi.subscribe(PLTService.WEARING_STATE_SVC, PLTMode.On_Change);

                // 7. FREE_FALL_SVC
                m_pltlabsapi.subscribe(PLTService.FREE_FALL_SVC, PLTMode.Periodic, 500);
                //m_pltlabsapi.subscribe(PLTService.FREE_FALL_SVC, PLTMode.On_Change);

                // 8. PROXIMITY_SVC
                m_pltlabsapi.subscribe(PLTService.PROXIMITY_SVC, PLTMode.On_Change);

                // 9. CALLERID_SVC
                m_pltlabsapi.subscribe(PLTService.CALLERID_SVC, PLTMode.On_Change);

                // 10. CALLSTATE_SVC
                m_pltlabsapi.subscribe(PLTService.CALLSTATE_SVC, PLTMode.On_Change);

                // 11. DOCKSTATE_SVC
                m_pltlabsapi.subscribe(PLTService.DOCKSTATE_SVC, PLTMode.On_Change);

                // 12. CHARGESTATE_SVC Lets register for battery level service
                m_pltlabsapi.subscribe(PLTService.CHARGESTATE_SVC, PLTMode.Periodic, 2000);

                // check we subcribed ok...
                DebugPrintSubscribedServices();

                DebugPrint(MethodInfo.GetCurrentMethod().Name, "Connected ok? "
                           + (pltConnection != null ? "Yes" : "No"));
            }
        }
コード例 #8
0
 public void ConnectionFailed(PLTDevice pltDevice)
 {
     m_pltConnection = null;
     UpdateVersionInfoGUI();
 }
コード例 #9
0
 public void ConnectionFailed(PLTDevice pltDevice)
 {
     m_pltConnection = null;
     m_activeDevice  = null;
 }
コード例 #10
0
 public void ConnectionFailed(PLTDevice pltDevice)
 {
     m_pltConnection = null;
     m_calibrated    = false;
 }
コード例 #11
0
 public void ConnectionClosed(PLTDevice pltDevice)
 {
     m_pltConnection = null;
 }