コード例 #1
0
 //This is the listener that is called by the event manager
 //It transforms and adds the received report to the reports list
 void Record(string name, VRPNAnalog.AnalogReport report)
 {
     if (firstReport)
     {
         firstTime_sec  = report.msg_time.tv_sec;
         firstTime_usec = report.msg_time.tv_usec;
         firstReport    = false;
     }
     if (report.msg_time.tv_usec < firstTime_usec)
     {
         report.msg_time.tv_sec  = report.msg_time.tv_sec - (firstTime_sec + 1);
         report.msg_time.tv_usec = (report.msg_time.tv_usec + 1000000) - firstTime_usec;
     }
     else
     {
         report.msg_time.tv_sec  = report.msg_time.tv_sec - firstTime_sec;
         report.msg_time.tv_usec = report.msg_time.tv_usec - firstTime_usec;
     }
     VRPNAnalog.AnalogReportNew newReport  = new VRPNAnalog.AnalogReportNew();
     VRPNManager.TimeValNew     newMsgTime = new VRPNManager.TimeValNew();
     newMsgTime.tv_sec     = (int)report.msg_time.tv_sec;
     newMsgTime.tv_usec    = (int)report.msg_time.tv_usec;
     newReport.msg_time    = newMsgTime;
     newReport.num_channel = report.num_channel;
     newReport.channel     = report.channel;
     data.list.Add(newReport);
 }
コード例 #2
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);
 }
コード例 #3
0
ファイル: VRPNAnalogPlay.cs プロジェクト: Calvino85/VRPN-Tool
 //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);
 }
コード例 #4
0
    //To add a trigger for Analog sensors
    public static void TriggerEventAnalog(string deviceType, string deviceName, VRPNAnalog.AnalogReport report)
    {
        if (eventManager == null)
        {
            Debug.LogError("There needs to be one active EventManger script on a GameObject in your scene.");
            return;
        }
        VRPNAnalogEvent thisEvent = null;

        if (instance.eventDictionaryAnalog.TryGetValue(deviceType + " " + deviceName, out thisEvent))
        {
            thisEvent.Invoke(deviceType + " " + deviceName, report);
        }
    }