public boolean writeCoil ( int unitId , int ref , boolean state ) throws ModbusException { checkTransaction ( ) ; if ( writeCoilRequest == null ) { writeCoilRequest = new WriteCoilRequest ( ) ; } writeCoilRequest . setUnitID ( unitId ) ; writeCoilRequest . setReference ( ref ) ; writeCoilRequest . setCoil ( state ) ; transaction . setRequest ( writeCoilRequest ) ; transaction . execute ( ) ; return ( ( WriteCoilResponse ) getAndCheckResponse ( ) ) . getCoil ( ) ; }
Writes a coil state to the slave .