WIP: Asynchrones Interface für ServiceLink
parent
69db4cd9f7
commit
3cbf13f260
|
@ -0,0 +1,40 @@
|
|||
package org.hwo.io.servicelink;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class AsynchronServiceLinkProvider {
|
||||
|
||||
ServiceRegisterCache cache;
|
||||
Hashtable<Integer, List<ServiceRegisterListener>> serviceRegisterListeners;
|
||||
|
||||
public AsynchronServiceLinkProvider(ServiceRegisterCache cache){
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
private Integer calcRegisterHash(int ax,int node,int registerno){
|
||||
Integer hash = (ax << 24) | (node << 16) | registerno;
|
||||
return hash;
|
||||
}
|
||||
|
||||
private List<ServiceRegisterListener> getListeners(Integer hash){
|
||||
if (!serviceRegisterListeners.containsKey(hash))
|
||||
serviceRegisterListeners.put(hash, new LinkedList<ServiceRegisterListener>());
|
||||
|
||||
return serviceRegisterListeners.get(hash);
|
||||
}
|
||||
|
||||
public void addServiceRegisterListener(int ax,int node,int registerno,ServiceRegisterListener listener){
|
||||
getListeners(calcRegisterHash(ax, node, registerno)).add(listener);
|
||||
}
|
||||
public void removeServiceRegisterListener(int ax,int node,int registerno,ServiceRegisterListener listener){
|
||||
getListeners(calcRegisterHash(ax, node, registerno)).remove(listener);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
/* TODO: Implementieren des Update Zyklus */
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.hwo.io.servicelink;
|
||||
|
||||
public interface ServiceRegisterListener {
|
||||
|
||||
void ServiceRegisterValueUpdated(int ax,int node,int registervalue,Integer value);
|
||||
void ServiceRegisterValueUpdated(int ax,int node,int registervalue,Float value);
|
||||
|
||||
}
|
Loading…
Reference in New Issue