WIP161214
parent
0309f98a3b
commit
861dca267d
|
@ -399,6 +399,9 @@ public class ServiceLink implements NewSerialPortListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (!isOpen())
|
||||
break;
|
||||
|
||||
try {
|
||||
rx = useV2 ?
|
||||
new ServiceLinkV2Telegram() :
|
||||
|
@ -454,6 +457,9 @@ public class ServiceLink implements NewSerialPortListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (!isOpen())
|
||||
break;
|
||||
|
||||
synchronized (txQueue) {
|
||||
tx = txQueue.pollFirst();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import static org.hwo.logging.Logging.*;
|
|||
import static org.hwo.logging.LogLevel.*;
|
||||
|
||||
public class ServiceRegisterCache {
|
||||
ServiceLink serviceLink;
|
||||
Hashtable<Integer, BaseCacheItem>
|
||||
cache;
|
||||
|
||||
public class BaseCacheItem
|
||||
{
|
||||
|
@ -63,8 +66,11 @@ public class ServiceRegisterCache {
|
|||
}
|
||||
|
||||
public Object getValue(){
|
||||
if (isOld())
|
||||
if (isOld()){
|
||||
log(DEBUGDETAIL,"OLDCACHE:SLA: [%d:%d:%d:%s] = %s", ax,node,register,isFloat ? "F" : "I",value);
|
||||
fetchValue();
|
||||
log(DEBUGDETAIL,"NEWCACHE:SLA: [%d:%d:%d:%s] = %s", ax,node,register,isFloat ? "F" : "I",value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -72,7 +78,7 @@ public class ServiceRegisterCache {
|
|||
public void setValue(Object value){
|
||||
this.value = value;
|
||||
this.lastReadTime = System.currentTimeMillis();
|
||||
log(DEBUGDETAIL,"CACHE: SLA: [%d:%d:%d] = %s", ax,node,register,value);
|
||||
log(DEBUGDETAIL,"CACHE: SLA: [%d:%d:%d:%s] = %s", ax,node,register,isFloat ? "F" : "I",value);
|
||||
}
|
||||
|
||||
public void invalidate(){
|
||||
|
@ -80,6 +86,8 @@ public class ServiceRegisterCache {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Integer axFromHash(Integer hash){
|
||||
return (hash >> 20) & 0x0F;
|
||||
}
|
||||
|
@ -107,10 +115,6 @@ public class ServiceRegisterCache {
|
|||
return new ServiceLinkAddress( axFromHash(hash), nodeFromHash(hash), regFromHash(hash) );
|
||||
}
|
||||
|
||||
ServiceLink serviceLink;
|
||||
|
||||
Hashtable<Integer, BaseCacheItem>
|
||||
cache;
|
||||
|
||||
ServiceRegisterCache(ServiceLink serviceLink)
|
||||
{
|
||||
|
@ -123,10 +127,10 @@ public class ServiceRegisterCache {
|
|||
}
|
||||
|
||||
private BaseCacheItem getCacheItem(int hash){
|
||||
BaseCacheItem bci;
|
||||
|
||||
if (!cache.contains(hash)){
|
||||
cache.put(hash, new BaseCacheItem(hash));
|
||||
if (!cache.containsKey(hash)){
|
||||
BaseCacheItem bci = new BaseCacheItem(hash);
|
||||
cache.put(new Integer(hash), bci);
|
||||
log( DEBUGDETAIL, "new cache-item: 0x%08x = %s", hash, bci);
|
||||
}
|
||||
return cache.get(hash);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue