Пример #1
0
 //Auxiliar method that sends last frame report
 private void sendingReport(VRPNAnalog.AnalogReportNew lastReport)
 {
     VRPNAnalog.AnalogReport newReport  = new VRPNAnalog.AnalogReport();
     VRPNManager.TimeVal     newMsgTime = new VRPNManager.TimeVal();
     newMsgTime.tv_sec     = (UInt32)lastReport.msg_time.tv_sec;
     newMsgTime.tv_usec    = (UInt32)lastReport.msg_time.tv_usec;
     newReport.msg_time    = newMsgTime;
     newReport.num_channel = lastReport.num_channel;
     newReport.channel     = lastReport.channel;
     VRPNEventManager.TriggerEventAnalog(data.deviceType, data.deviceName, newReport);
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        // Ensure device is ready
        if (!initialized && !StartAnalog())
        {
            return;
        }

        // Check for new reports and process
        if (VRPNAnalogNumReports(AnalogName.ToString()) > 0)
        {
            // Get Reports
            int num = MaxReports;
            VRPNAnalogReports(AnalogName.ToString(), reportsPtr, ref num, LastReport, purgeReports);
            AnalogReport[] reports = new AnalogReport[num];

            // Process Reports
            int    i;
            string reportString = AnalogName.ToString();
            string messageString;
            for (i = 0; i < num; i++)
            {
                reports[i] = (AnalogReport)Marshal.PtrToStructure(reportsPtr[i], typeof(AnalogReport));
                if (i == num - 1)
                {
                    //Trigger analog sensor event in event manager
                    //Only the last one is send, one for frame
                    VRPNEventManager.TriggerEventAnalog(AnalogType.ToString(), AnalogName.ToString(), reports[i]);
                }
                messageString = "<";
                for (int j = 0; j < reports[i].num_channel; j++)
                {
                    messageString += " " + reports[i].channel[j] + ",";
                }
                messageString += ">" + " @ " + reports[i].msg_time.tv_sec + "." + reports[i].msg_time.tv_usec;
                if (ShowDebug)
                {
                    reportString += "/n" + messageString;
                }
            }

            if (ShowDebug)
            {
                debug_text = reportString;
            }

            // Only need time value of most recent report
            if (num > 0 && useLastReportTime)
            {
                LastReport.tv_sec  = reports[num - 1].msg_time.tv_sec;
                LastReport.tv_usec = reports[num - 1].msg_time.tv_usec;
            }
        }
    }