read and write Field done. pushToField to do
This commit is contained in:
		| @@ -4,31 +4,33 @@ import ch.hevs.isi.core.DataPoint; | ||||
| import ch.hevs.isi.core.DataPointListener; | ||||
| import ch.hevs.isi.core.FloatDataPoint; | ||||
|  | ||||
| import java.util.Timer; | ||||
|  | ||||
| public class FieldConnector implements DataPointListener { | ||||
|  | ||||
|     private static FieldConnector mySelf = null; | ||||
|  | ||||
|     private FieldConnector(){ | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public static FieldConnector getMySelf(){ | ||||
|         if (mySelf == null){ | ||||
|             mySelf = new FieldConnector(); | ||||
|         } | ||||
|         return mySelf; | ||||
|     } | ||||
|  | ||||
|     public void initialize(String host, int port){ | ||||
|  | ||||
|         ModbusAccessor mbA = ModbusAccessor.getMySelf(); | ||||
|         mbA.connect(host, port); | ||||
|     } | ||||
|  | ||||
|     private void pushToField(DataPoint dp){ | ||||
|         System.out.println(dp.toString() + " -> Field"); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onNewValue(DataPoint dp) { | ||||
|         pushToField(dp); | ||||
|         ModbusRegister mr = ModbusRegister.getRegisterFromDatapoint(dp); | ||||
|         mr.write(); | ||||
|     } | ||||
|     public void periodicalPolling(){ | ||||
|         Timer pollTimer = new Timer(); | ||||
|         PollTask pollTask = new PollTask(); | ||||
|         pollTimer.scheduleAtFixedRate(pollTask,0,2000); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user