private void ReceiveResourceFile(ServiceReceiver <file_server.GetBinaryFileRequest, file_server.GetBinaryFileResponse> serviceReceiver, file_server.GetBinaryFileResponse serviceResponse) { byte[] fileContents = serviceResponse.value; Uri resourceFileUri = new Uri((serviceReceiver.ServiceParameter).name); bool updateFileRequestStatusAtEnd = true; if (IsColladaFile(resourceFileUri)) { Thread importResourceFilesThread = new Thread(() => { try { ImportColladaTextureFiles(resourceFileUri, System.Text.Encoding.UTF8.GetString(fileContents)); } finally { UpdateFileRequestStatus(resourceFileUri); } }); importResourceFilesThread.Start(); updateFileRequestStatusAtEnd = false; } Thread writeTextFileThread = new Thread(() => WriteBinaryResponseToFile((string)serviceReceiver.HandlerParameter, fileContents)); writeTextFileThread.Start(); if (updateFileRequestStatusAtEnd) { UpdateFileRequestStatus(resourceFileUri); } }
public bool Import(int maxTimeOut = int.MaxValue) { rosSocket.CallService("/rosapi/get_param", typeof(ParamValueString), receiveRobotName, new ParamName("/robot/name")); ServiceReceiver robotDescriptionReceiver = new ServiceReceiver(rosSocket, "/rosapi/get_param", new ParamName("/robot_description"), "\\robot_description.urdf", typeof(ParamValueString)); robotDescriptionReceiver.ReceiveEventHandler += receiveRobotDescription; return(WaitHandle.WaitAll(Status.Values.ToArray(), maxTimeOut)); }
private void receiveRobotDescription(ServiceReceiver serviceReciever, object serviceResponse) { string robotDescription = formatTextFileContents(((ParamValueString)serviceResponse).value); Thread importResourceFilesThread = new Thread(() => importResourceFiles(robotDescription)); importResourceFilesThread.Start(); Thread writeTextFileThread = new Thread(() => writeTextFile((string)serviceReciever.HandlerParameter, robotDescription)); writeTextFileThread.Start(); Status["robotDescriptionReceived"].Set(); }
public bool Import(int maxTimeOut = int.MaxValue) { rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ReceiveRobotName, new rosapi.GetParamRequest("/robot/name", "default")); var robotDescriptionReceiver = new ServiceReceiver <rosapi.GetParamRequest, rosapi.GetParamResponse>(rosSocket, "/rosapi/get_param", new rosapi.GetParamRequest("/robot_description", "default"), Path.DirectorySeparatorChar + "robot_description.urdf"); robotDescriptionReceiver.ReceiveEventHandler += ReceiveRobotDescription; return(WaitHandle.WaitAll(Status.Values.ToArray(), maxTimeOut)); }
private void ReceiveRobotDescription(ServiceReceiver <rosapi.GetParamRequest, rosapi.GetParamResponse> serviceReciever, rosapi.GetParamResponse serviceResponse) { string robotDescription = FormatTextFileContents(serviceResponse.value); Thread importResourceFilesThread = new Thread(() => ImportResourceFiles(robotDescription)); importResourceFilesThread.Start(); Thread writeTextFileThread = new Thread(() => WriteTextFile((string)serviceReciever.HandlerParameter, robotDescription)); writeTextFileThread.Start(); Status["robotDescriptionReceived"].Set(); }
private void receiveResourceFile(ServiceReceiver serviceReceiver, object serviceResponse) { string fileContents = System.Text.Encoding.UTF8.GetString(((ParamValueByte)serviceResponse).value); Uri resourceFileUri = new Uri(((ParamName)serviceReceiver.ServiceParameter).name); if (isColladaFile(resourceFileUri)) { Thread importResourceFilesThread = new Thread(() => importDaeTextureFiles(resourceFileUri, fileContents)); importResourceFilesThread.Start(); } Thread writeTextFileThread = new Thread(() => writeTextFile((string)serviceReceiver.HandlerParameter, fileContents)); writeTextFileThread.Start(); updateFileRequestStatus(resourceFileUri); }
private void receiveResourceFile(ServiceReceiver serviceReceiver, object serviceResponse) { #if NETFX_CORE //TODO imprementation #else byte[] fileContents = ((ParamValueByte)serviceResponse).value; Uri resourceFileUri = new Uri(((ParamName)serviceReceiver.ServiceParameter).name); if (isColladaFile(resourceFileUri)) { Thread importResourceFilesThread = new Thread(() => importDaeTextureFiles(resourceFileUri, System.Text.Encoding.UTF8.GetString(fileContents))); importResourceFilesThread.Start(); } Thread writeTextFileThread = new Thread(() => writeBinaryResponseToFile((string)serviceReceiver.HandlerParameter, fileContents)); writeTextFileThread.Start(); updateFileRequestStatus(resourceFileUri); #endif }
private void receiveTextureFiles(ServiceReceiver serviceReceiver, object serviceResponse) { writeBinaryResponseToFile((string)serviceReceiver.HandlerParameter, ((ParamValueByte)serviceResponse).value); updateFileRequestStatus(new Uri(((ParamName)serviceReceiver.ServiceParameter).name)); }
private void ReceiveTextureFiles(ServiceReceiver <file_server.GetBinaryFileRequest, file_server.GetBinaryFileResponse> serviceReceiver, file_server.GetBinaryFileResponse serviceResponse) { WriteBinaryResponseToFile((string)serviceReceiver.HandlerParameter, serviceResponse.value); UpdateFileRequestStatus(new Uri(serviceReceiver.ServiceParameter.name)); }