private void sendDataToClient(int pwm_value, double encoder_value, long time_stamp, int signal_id) { // Create string with sensor content string pwmValue = String.Format("x{0:F3}", pwm_value); string encoderValue = String.Format("y{0:F3}", encoder_value); string zText = String.Format("z{0:F3}", 1); string signal_Id = signal_id.ToString(); string timeStamp = time_stamp.ToString(); string message = pwmValue + "::" + encoderValue + "::" + zText + "::" + timeStamp; diagnose.sendToSocket(signal_Id, message); }
private void executeAqcuisition() { if (getProgramDuration) { timerArray[0] = timer_programExecution.ElapsedMilliseconds; } string xText, yText, zText, sensorId, timeStamp; byte rxStateIst = 0x00; byte rxStateSoll = 0x03; if (globalDataSet.DebugMode) { Debug.WriteLine("Wait until a message is received in buffer 0 or 1"); } // Wait until a message is received in buffer 0 or 1 while ((globalDataSet.MCP2515_PIN_INTE_RECEIVER.Read() == GpioPinValue.High)) { } if (getProgramDuration) { timerArray[1] = timer_programExecution.ElapsedMilliseconds; } if (globalDataSet.DebugMode) { Debug.WriteLine("Finished waiting, check which rx buffer."); } // Check in which rx buffer the message is rxStateIst = globalDataSet.LOGIC_MCP2515_RECEIVER.mcp2515_get_state_command(); if (globalDataSet.DebugMode) { Debug.WriteLine("Read sensor values from device "); } if (getProgramDuration) { timerArray[2] = timer_programExecution.ElapsedMilliseconds; } // Read the sensor data McpExecutorDataFrame mcpExecutorDataFrame = ReadAccel(rxStateIst, rxStateSoll); // Create string with sensor content xText = String.Format("x{0:F3}", mcpExecutorDataFrame.X); yText = String.Format("y{0:F3}", mcpExecutorDataFrame.Y); zText = String.Format("z{0:F3}", mcpExecutorDataFrame.Z); sensorId = mcpExecutorDataFrame.ident.ToString(); timeStamp = mcpExecutorDataFrame.timeStamp.ToString(); string message = xText + "::" + yText + "::" + zText + "::" + timeStamp; diagnose.sendToSocket(sensorId, message); if (globalDataSet.DebugMode) { Debug.WriteLine("sensorId: " + sensorId); } if (globalDataSet.DebugMode) { Debug.WriteLine("message: " + message); } if (getProgramDuration) { timerArray[5] = timer_programExecution.ElapsedMilliseconds; } // Reset interrupt for buffer 0 because message is read -> Reset all interrupts //globalDataSet.mcp2515_execute_write_command(new byte[] { mcp2515.CONTROL_REGISTER_CANINTF, mcp2515.CONTROL_REGISTER_CANINTF_VALUE.RESET_ALL_IF }, globalDataSet.MCP2515_PIN_CS_RECEIVER); if (getProgramDuration) { timerArray[6] = timer_programExecution.ElapsedMilliseconds; } if (getProgramDuration) { for (int i = 0; i < timerArray.Length; i++) { Debug.WriteLine(timerArray[i]); } } }