| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -8,61 +8,79 @@ ModbusMaster::ModbusMaster(QObject* parent) : QObject(parent) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::init() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::init(ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(!_initialized) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice = nullptr; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice = new QModbusRtuSerialMaster(this); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							connect(_modbusDevice, &QModbusClient::errorOccurred, [this](QModbusDevice::Error) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(!_initialized) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw ServoException(_modbusDevice->errorString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice = nullptr; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice = new QModbusRtuSerialMaster(this); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								connect(_modbusDevice, &QModbusClient::errorOccurred, [this](QModbusDevice::Error) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									throw ServoException(_modbusDevice->errorString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							connect(_modbusDevice, &QModbusDevice::stateChanged, this, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									&ModbusMaster::connectionStateChanged); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								connect(_modbusDevice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										&QModbusClient::stateChanged, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										this, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										&ModbusMaster::connectionStateChanged); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_initialized = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_initialized = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							else | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw ServoException( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										  "Modbus Device Object Created Before First Delete it Then Make New One"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						else | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException("Modbus Device Created Before Handle it"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::connectToDevice(ModbusConfig modbusConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::connectionStateChanged(QModbusDevice::State state) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(_modbusDevice->state() != QModbusDevice::ConnectedState) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(state == QModbusDevice::UnconnectedState) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_clientAddress = modbusConfig.clientAddress; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																  modbusConfig.serialPort); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																  modbusConfig.parity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																  modbusConfig.baud); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																  modbusConfig.dataBits); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																  modbusConfig.stopBits); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setTimeout(modbusConfig.responseTime); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->setNumberOfRetries(modbusConfig.numberOfRetries); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(!_modbusDevice->connectDevice()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								throw ServoException(_modbusDevice->errorString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException("Connection wasnt prepared"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::connectionStateChanged(QModbusDevice::State state) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::connectToDevice(ModbusConfig modbusConfig, ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(state == QModbusDevice::UnconnectedState) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if(_modbusDevice->state() != QModbusDevice::ConnectedState) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_clientAddress = modbusConfig.clientAddress; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  modbusConfig.serialPort); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  modbusConfig.parity); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  modbusConfig.baud); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  modbusConfig.dataBits); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  modbusConfig.stopBits); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setTimeout(modbusConfig.responseTime); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								_modbusDevice->setNumberOfRetries(modbusConfig.numberOfRetries); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if(!_modbusDevice->connectDevice()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									throw ServoException(_modbusDevice->errorString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException("Connection wasnt prepared"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -90,12 +108,12 @@ QBitArray ModbusMaster::getCoil(int startAddress, quint16 readSize, ExpConfig& e | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					QBitArray ModbusMaster::getInputCoil(int startAddress, quint16 readSize) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					QBitArray ModbusMaster::getInputCoil(int startAddress, quint16 readSize, ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -117,12 +135,15 @@ QBitArray ModbusMaster::getInputCoil(int startAddress, quint16 readSize) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					QVector<quint16> ModbusMaster::getHoldingRegister(int startAddress, quint16 readSize) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					QVector<quint16> ModbusMaster::getHoldingRegister(int startAddress, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  quint16 readSize, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	  ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -142,12 +163,15 @@ QVector<quint16> ModbusMaster::getHoldingRegister(int startAddress, quint16 read | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					QVector<quint16> ModbusMaster::getInputRegister(int startAddress, quint16 readSize) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					QVector<quint16> ModbusMaster::getInputRegister(int startAddress, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	quint16 readSize, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
																	ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -167,12 +191,13 @@ QVector<quint16> ModbusMaster::getInputRegister(int startAddress, quint16 readSi | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setSingleCoil(int startAddress, bool coilFlag) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setSingleCoil(int startAddress, bool coilFlag, ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -187,11 +212,16 @@ void ModbusMaster::setSingleCoil(int startAddress, bool coilFlag) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setMultipleCoil(int startAddress, quint16 writeSize, QBitArray coilFlags) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setMultipleCoil(int startAddress, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
													   quint16 writeSize, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
													   QBitArray coilFlags, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
													   ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -200,11 +230,13 @@ void ModbusMaster::setMultipleCoil(int startAddress, quint16 writeSize, QBitArra | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setSingleRegister(int startAddress, quint16 registerValue) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setSingleRegister(int startAddress, quint16 registerValue, ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -214,14 +246,15 @@ void ModbusMaster::setSingleRegister(int startAddress, quint16 registerValue) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/*************************************************************************************************/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::setMultipleRegister(int startAddress, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
														   quint16 writeSize, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
														   QVector<quint16> registerValues) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
														   QVector<quint16> registerValues, ExpConfig& expConfig) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						try | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -230,7 +263,8 @@ void ModbusMaster::setMultipleRegister(int startAddress, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						catch(const ServoException& ex) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							qDebug() << ex.what(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.valid = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							expConfig.message = ex.getMessage(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -277,15 +311,15 @@ void ModbusMaster::checkForError(QModbusReply* _reply) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(_reply->error() == QModbusDevice::ProtocolError) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException(tr("Read response error: %1 (Mobus exception: 0x%2)"). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 arg(_reply->errorString()). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 arg(_reply->rawResult().exceptionCode(), -1, 16)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException(QString("Read response error: %1 (Mobus exception: %2)") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 .arg(_reply->errorString()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 .arg(_reply->rawResult().exceptionCode())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						else | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException(tr("Read response error: %1 (code: 0x%2)"). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 arg(_reply->errorString()). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 arg(_reply->error(), -1, 16)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException(QString("Read response error: %1 (code: %2)") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 .arg(_reply->errorString()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 .arg(_reply->error())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -327,3 +361,10 @@ void ModbusMaster::writeRequest(QModbusDataUnit::RegisterType registerType, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							throw ServoException(_modbusDevice->errorString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					void ModbusMaster::close() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if(_modbusDevice) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_modbusDevice->disconnectDevice(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						delete _modbusDevice; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					
  |