/// <summary> /// Apply command received client to vy446 /// </summary> /// <param name="_harvester_command"></param> private void ApplyCmdReceivedClientToVy446(Communication.File.CmdFromClient _harvester_command) { if (_harvester_command.flag == 0) { this.ServerControlFlagTxtBox.Text = "Initialize"; } else if (_harvester_command.flag == 1) { this.ServerControlFlagTxtBox.Text = "Receiving"; } if (this.BodyAvailableCheckBox.Checked == true && this.BodyReadCheckBox.Checked == false) { this.CombineVy446DefaultCommand(); this.vy446_usCmdHst = Convert.ToUInt16(_harvester_command.hst); this.vy446_usCmdSteer = Convert.ToUInt16(_harvester_command.steer); // karitori on this.vy446_KaritoriRadio = true; // karitakasa on this.vy446_m_ucFgKaritakaPosCtrl = true; this.vy446_usCmdKaritaka = Convert.ToUInt16(_harvester_command.header); if (_harvester_command.buzzer == 1) { this.vy446_m_ucFgBuzzer = true; } else { this.vy446_m_ucFgBuzzer = false; } if (_harvester_command.red_lamp == 1) { this.vy446_RedLampChk = true; } else { this.vy446_RedLampChk = false; } this.CombineVy446CmdSend(); } this.ServerHstDebugTxtBox.Text = Convert.ToString(_harvester_command.hst); this.ServerSteerDebugTxtBox.Text = Convert.ToString(_harvester_command.steer); this.ServerHeaderDebugTxtBox.Text = Convert.ToString(_harvester_command.header); if (_harvester_command.buzzer == 1) { this.ServerBuzzerTxtBox.Text = "on"; } else { this.ServerBuzzerTxtBox.Text = "off"; } if (_harvester_command.red_lamp == 1) { this.ServerRedLampTxtBox.Text = "on"; } else { this.ServerRedLampTxtBox.Text = "off"; } }
/// <summary> /// Communication Play /// </summary> private void CommunicationPlay() { if (this.TcpIpServerCheckBox.Checked == true) { if (this.connect.client.Connected == true) { // Server - send command data to client. this.MergeSensorsDataOfServer(); string send_time = this.MillisecondDisplay(); this.connect.ServerSendDataToClient(this.tcpFile.sendCmdToClient); // Server - received data from client. this.connect.ServerReceivedDataFromClient(); string received_time = this.MillisecondDisplay(); //this.RemoteReceivedReadCntTxtBox.Text = this.connect.received_data_from_client; Communication.File.CmdFromClient harvester_command = this.tcpFile.DivideCmdDataReceivedFromClient(this.connect.received_data_from_client); this.ApplyCmdReceivedClientToVy446(harvester_command); // log data = readcount + send time to client + received time from client + received data from client string log_data = null; if (this.server_log_flag == true) { log_data = Convert.ToString(this.readCount) + " " + send_time + " " + received_time + " " + this.connect.received_data_from_client; this.tcpFile.AddLogData(log_data); } } } if (this.TcpIpClientCheckBox.Checked == true) { if (this.connect.server.Connected == true) { // client - received data from server. this.connect.ClientReceiveDataFromServer(); string received_time = this.MillisecondDisplay(); this.tcpFile.DivideStringData( this.connect.received_data_from_server, this.sickLidar.dataLength, this.BodyModelComboBox.SelectedIndex ); // client - client debug message received server this.ClientDebugMessageFromServer(); // client - send command data to server. string harvester_command = this.CreateCommandForVy446(this.TcpIpWheelControlCheckBox.Checked); string send_time = this.MillisecondDisplay(); this.connect.ClientSendDataToServer(harvester_command); // log data = readcount + received time to server + send time to server + send data to server string log_data = null; if (this.client_log_flag == true) { log_data = Convert.ToString(this.tcpFile.read_count_from_server) + " " + received_time + " " + send_time + " " + harvester_command; this.tcpFile.AddLogData(log_data); } } } }
/// <summary> /// Create command data for control of vy446 /// </summary> /// <returns></returns> private string CreateCommandForVy446(bool _is_wheel) { int buzzer = 0; int red_lamp = 0; if (_is_wheel == true) { // vy446 if (this.BodyModelComboBox.SelectedIndex == 1) { this.tcpFile.set_forward_HST = this._vy446.SetHstCmd(Convert.ToDouble(this.ClientSetForwardSpeedTxtBox.Text)); this.tcpFile.set_backward_HST = this._vy446.SetHstCmd(Convert.ToDouble(this.ClientSetBackwardSpeedTxtBox.Text)); } Communication.File.CmdFromClient wheel_command = this.tcpFile.DivideWheelData( this.g27.Controller().ToString(), this.remote_client_flag, Convert.ToInt32(this.ClientHstNumericUpDown.Value), Convert.ToInt32(this.ClientSteerNumericUpDown.Value), Convert.ToInt32(this.ClientHeaderNumericUpDown.Value) ); this.remote_client_flag = wheel_command.flag; this.ClientHstNumericUpDown.Value = wheel_command.hst; this.ClientSteerNumericUpDown.Value = wheel_command.steer; this.ClientHeaderNumericUpDown.Value = wheel_command.header; buzzer = wheel_command.buzzer; red_lamp = wheel_command.red_lamp; if (wheel_command.buzzer == 1) { this.ClientBuzzerTxtBox.Text = "on"; } else { this.ClientBuzzerTxtBox.Text = "off"; } if (wheel_command.red_lamp == 1) { this.ClientRedLampTxtBox.Text = "on"; } else { this.ClientRedLampTxtBox.Text = "off"; } if (this.remote_client_flag == 0) { this.ClientControlFlagTxtBox.Text = "Initialize"; this.remote_client_flag = 0; this.ClientHstNumericUpDown.Value = 1405; this.ClientSteerNumericUpDown.Value = 430; this.ClientHeaderNumericUpDown.Value = 650; this.ClientBuzzerTxtBox.Text = "off"; this.ClientRedLampTxtBox.Text = "off"; } else { this.ClientControlFlagTxtBox.Text = "Sending"; } // display steering gauge value this.G27Gauge.Value = this.tcpFile.steer_gauge; } string command = null; command = Convert.ToString(this.remote_client_flag) + " " + Convert.ToString(this.ClientHstNumericUpDown.Value) + " " + Convert.ToString(this.ClientSteerNumericUpDown.Value) + " " + Convert.ToString(this.ClientHeaderNumericUpDown.Value) + " " + Convert.ToString(buzzer) + " " + Convert.ToString(red_lamp); return(command); }