public void Evaluate(int SpreadMax) { if (FInputInit[0]) { if (m_NatNet != null) { m_NatNet.Disconnect(); } m_NatNet = new NatNetML.NatNetClientML(); NatNetClientML.ConnectParams _params = new NatNetClientML.ConnectParams(); _params.ServerAddress = FInputIPServer[0]; _params.LocalAddress = FInputIPClient[0]; _params.ConnectionType = ConnectionType.Multicast; returnCode = m_NatNet.Connect(_params); returnCode = m_NatNet.GetServerDescription(desc); FOutputStatus.SliceCount = 1; FOutputStatus[0] = ""; m_NatNet.OnFrameReady += new NatNetML.FrameReadyEventHandler(m_NatNet_OnFrameReady); //Version info int[] ver = new int[4]; ver = m_NatNet.NatNetVersion(); FOutputVersion.SliceCount = 1; FOutputVersion[0] = String.Format("{0}.{1}.{2}.{3}", ver[0], ver[1], ver[2], ver[3]); FOutputClient.SliceCount = 1; FOutputClient[0] = m_NatNet; } }
public void Disconnect() { /* [NatNet] Disabling data handling function */ //mNatNet.OnFrameReady -= fetchFrameData; /* Clearing Saved Descriptions */ mRigidBodies.Clear(); mSkeletons.Clear(); mHtSkelRBs.Clear(); mForcePlates.Clear(); mNatNet.Disconnect(); }
static void Main() { Console.WriteLine("SampleClientML managed client application starting...\n"); /* [NatNet] Initialize client object and connect to the server */ connectToServer(); // Initialize a NatNetClient object and connect to a server. Console.WriteLine("============================ SERVER DESCRIPTOR ================================\n"); /* [NatNet] Confirming Server Connection. Instantiate the server descriptor object and obtain the server description. */ bool connectionConfirmed = fetchServerDescriptor(); // To confirm connection, request server description data if (connectionConfirmed) // Once the connection is confirmed. { Console.WriteLine("============================= DATA DESCRIPTOR =================================\n"); Console.WriteLine("Now Fetching the Data Descriptor.\n"); fetchDataDescriptor(); //Fetch and parse data descriptor Console.WriteLine("============================= FRAME OF DATA ===================================\n"); Console.WriteLine("Now Fetching the Frame Data\n"); /* [NatNet] Assigning a event handler function for fetching frame data each time a frame is received */ mNatNet.OnFrameReady += new NatNetML.FrameReadyEventHandler(fetchFrameData); Console.WriteLine("Success: Data Port Connected \n"); Console.WriteLine("======================== STREAMING IN (PRESS ESC TO EXIT) =====================\n"); } while (!(Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Escape)) { // Continuously listening for Frame data // Enter ESC to exit // Exception handler for updated assets list. if (mAssetChanged == true) { Console.WriteLine("\n===============================================================================\n"); Console.WriteLine("Change in the list of the assets. Refetching the descriptions"); /* Clear out existing lists */ mDataDescriptor.Clear(); mHtSkelRBs.Clear(); mRigidBodies.Clear(); mSkeletons.Clear(); mForcePlates.Clear(); /* [NatNet] Re-fetch the updated list of descriptors */ fetchDataDescriptor(); Console.WriteLine("===============================================================================\n"); mAssetChanged = false; } } /* [NatNet] Disabling data handling function */ mNatNet.OnFrameReady -= fetchFrameData; /* Clearing Saved Descriptions */ mRigidBodies.Clear(); mSkeletons.Clear(); mHtSkelRBs.Clear(); mForcePlates.Clear(); mNatNet.Disconnect(); }
private static void Main(string[] args) { // Create a timer and set a two second interval. aTimer = new System.Timers.Timer(); aTimer.Interval = 2000; // Hook up the Elapsed event for the timer. aTimer.Elapsed += delegate { OnTimeEvent(client_); }; // Have the timer fire repeated events (true is the default) aTimer.AutoReset = true; // Start the timer aTimer.Enabled = true; Console.WriteLine("SampleClientML managed client application starting...\n"); /* [NatNet] Initialize client object and connect to the server */ connectToServer(); // Initialize a NatNetClient object and connect to a server. connectToHLServer(); Console.WriteLine("============================ SERVER DESCRIPTOR ================================\n"); /* [NatNet] Confirming Server Connection. Instantiate the server descriptor object and obtain the server description. */ bool connectionConfirmed = fetchServerDescriptor(); // To confirm connection, request server description data if (connectionConfirmed) // Once the connection is confirmed. { Console.WriteLine("============================= DATA DESCRIPTOR =================================\n"); Console.WriteLine("Now Fetching the Data Descriptor.\n"); fetchDataDescriptor(); //Fetch and parse data descriptor Console.WriteLine("============================= FRAME OF DATA ===================================\n"); Console.WriteLine("Now Fetching the Frame Data\n"); /* [NatNet] Assigning a event handler function for fetching frame data each time a frame is received */ mNatNet.OnFrameReady += new NatNetML.FrameReadyEventHandler(fetchFrameData); Console.WriteLine("Success: Data Port Connected \n"); } while (!(Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Escape)) { // Continuously listening for Frame data // Enter ESC to exit // Exception if (mAssetChanged == true) { Console.WriteLine("\n===============================================================================\n"); Console.WriteLine("Change in the list of the assets. Refetching the descriptions"); /* Clear out existing lists */ mDataDescriptor.Clear(); mRigidBodies.Clear(); /* [NatNet] Re-fetch the updated list of descriptors */ fetchDataDescriptor(); Console.WriteLine("===============================================================================\n"); mAssetChanged = false; } } /* [NatNet] Disabling data handling function */ mNatNet.OnFrameReady -= fetchFrameData; /* Clearing Saved Descriptions */ mRigidBodies.Clear(); mNatNet.Disconnect(); }
static void Main() { stopwatch = new Stopwatch(); stopwatch.Start(); drones.Add("micro_uwb", new DroneData("127.0.0.1", 20000, 0)); drones.Add("micro_uwb2", new DroneData("127.0.0.1", 20000, 1)); drones.Add("micro_uwb3", new DroneData("127.0.0.1", 20000, 2)); Console.WriteLine("SampleClientML managed client application starting...\n"); /* [NatNet] Initialize client object and connect to the server */ connectToServer(); // Initialize a NatNetClient object and connect to a server. Console.WriteLine("============================ SERVER DESCRIPTOR ================================\n"); /* [NatNet] Confirming Server Connection. Instantiate the server descriptor object and obtain the server description. */ bool connectionConfirmed = fetchServerDescriptor(); // To confirm connection, request server description data MAVLink.mavlink_system_time_t cmd = new MAVLink.mavlink_system_time_t(); cmd.time_boot_ms = 0; cmd.time_unix_usec = (ulong)((DateTime.UtcNow - unix_epoch).TotalMilliseconds * 1000); byte[] pkt = mavlinkParse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.SYSTEM_TIME, cmd); foreach (KeyValuePair <string, DroneData> drone in drones) { mavSock.SendTo(pkt, drone.Value.ep); } if (connectionConfirmed) // Once the connection is confirmed. { Console.WriteLine("============================= DATA DESCRIPTOR =================================\n"); Console.WriteLine("Now Fetching the Data Descriptor.\n"); fetchDataDescriptor(); //Fetch and parse data descriptor Console.WriteLine("============================= FRAME OF DATA ===================================\n"); Console.WriteLine("Now Fetching the Frame Data\n"); /* [NatNet] Assigning a event handler function for fetching frame data each time a frame is received */ mNatNet.OnFrameReady += new NatNetML.FrameReadyEventHandler(fetchFrameData); Console.WriteLine("Success: Data Port Connected \n"); Console.WriteLine("======================== STREAMING IN (PRESS ESC TO EXIT) =====================\n"); } while (!(Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Escape)) { // Continuously listening for Frame data // Enter ESC to exit // Exception handler for updated assets list. if (mAssetChanged == true) { Console.WriteLine("\n===============================================================================\n"); Console.WriteLine("Change in the list of the assets. Refetching the descriptions"); /* Clear out existing lists */ mDataDescriptor.Clear(); mHtSkelRBs.Clear(); mRigidBodies.Clear(); mSkeletons.Clear(); mForcePlates.Clear(); /* [NatNet] Re-fetch the updated list of descriptors */ fetchDataDescriptor(); Console.WriteLine("===============================================================================\n"); mAssetChanged = false; } } /* [NatNet] Disabling data handling function */ mNatNet.OnFrameReady -= fetchFrameData; mavSock.Close(); stopwatch.Stop(); /* Clearing Saved Descriptions */ mRigidBodies.Clear(); mSkeletons.Clear(); mHtSkelRBs.Clear(); mForcePlates.Clear(); mNatNet.Disconnect(); }