/** * Converts a JCA timestamp to an epics.util timestamp. * * @param epicsTimeStamp the epics timestamp * @return a new epics.util timestamp */ static java.time.Instant timestampOf(gov.aps.jca.dbr.TimeStamp epicsTimeStamp) { if (epicsTimeStamp == null) return null; return java.time.Instant.ofEpochSecond(epicsTimeStamp.secPastEpoch() + TS_EPOCH_SEC_PAST_1970, 0) .plus(Duration.ofNanos(epicsTimeStamp.nsec())); }
/** * Constructor of memory process variable. * @param name name of the PV. * @param eventCallback event callback, where to report value changes if <code>interest</code> is <code>true</code>. * @param type type of the PV (of initial value). * @param initialValue initial value, array is expected. */ public MemoryProcessVariable(String name, ProcessVariableEventCallback eventCallback, DBRType type, Object initialValue) { super(name, eventCallback); // check if initial value is an array if (!initialValue.getClass().isArray()) throw new IllegalArgumentException("array expected as initialValue"); this.type = type; this.value = initialValue; this.count = java.lang.reflect.Array.getLength(this.value); this.timestamp = new TimeStamp(); }
/** * Converts a JCA timestamp to an epics.util timestamp. * * @param epicsTimeStamp the epics timestamp * @return a new epics.util timestamp */ static org.epics.util.time.Timestamp timestampOf(gov.aps.jca.dbr.TimeStamp epicsTimeStamp) { if (epicsTimeStamp == null) return null; return org.epics.util.time.Timestamp.of(epicsTimeStamp.secPastEpoch() + TS_EPOCH_SEC_PAST_1970, 0) .plus(TimeDuration.ofNanos(epicsTimeStamp.nsec())); }
/** * Constructor of memory process variable. * @param name name of the PV. * @param eventCallback event callback, where to report value changes if <code>interest</code> is <code>true</code>. * @param type type of the PV (of initial value). * @param initialValue initial value, array is expected. */ public MemoryProcessVariable(String name, ProcessVariableEventCallback eventCallback, DBRType type, Object initialValue) { super(name, eventCallback); // check if initial value is an array if (!initialValue.getClass().isArray()) throw new IllegalArgumentException("array expected as initialValue"); this.type = type; this.value = initialValue; this.count = java.lang.reflect.Array.getLength(this.value); this.timestamp = new TimeStamp(); }
payloadBuffer.putInt((int)ts.secPastEpoch()); payloadBuffer.putInt((int)ts.nsec());
/** * Initialize PV. * Sets initial counter state and spawns a counter thread. */ protected void initialize() { value = startValue; timestamp = new TimeStamp(); checkForAlarms(); Thread thread = new Thread(this, getName() + " counter"); thread.setDaemon(true); thread.start(); }
payloadBuffer.putInt((int)ts.secPastEpoch()); payloadBuffer.putInt((int)ts.nsec());
/** * Initialize PV. * Sets initial counter state and spawns a counter thread. */ protected void initialize() { value = startValue; timestamp = new TimeStamp(); checkForAlarms(); Thread thread = new Thread(this, getName() + " counter"); thread.setDaemon(true); thread.start(); }
long seconds = timeStamp.secPastEpoch(); seconds += 7305*86400; pvSeconds.put(seconds); pvNanoseconds.put((int)timeStamp.nsec());
/** * Write value. * Copies given value to local memory (array). * If event interest flag <code>interest</code> is set, an event is fired to <code>eventCallback</code>. * @see gov.aps.jca.cas.ProcessVariable#write(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableWriteCallback) */ public synchronized CAStatus write(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException { this.value = value.getValue(); this.count = java.lang.reflect.Array.getLength(this.value); this.timestamp = new TimeStamp(); // notify if (interest) { DBR monitorDBR = AbstractCASResponseHandler.createDBRforReading(this); fillInDBR(monitorDBR); ((TIME)monitorDBR).setTimeStamp(timestamp); System.arraycopy(this.value, 0, monitorDBR.getValue(), 0, count); eventCallback.postEvent(Monitor.VALUE|Monitor.LOG, monitorDBR); } return CAStatus.NORMAL; }
/** * Write value. * Copies given value to local memory (array). * If event interest flag <code>interest</code> is set, an event is fired to <code>eventCallback</code>. * @see gov.aps.jca.cas.ProcessVariable#write(gov.aps.jca.dbr.DBR, gov.aps.jca.cas.ProcessVariableWriteCallback) */ public synchronized CAStatus write(DBR value, ProcessVariableWriteCallback asyncWriteCallback) throws CAException { this.value = value.getValue(); this.count = java.lang.reflect.Array.getLength(this.value); this.timestamp = new TimeStamp(); // notify if (interest) { DBR monitorDBR = AbstractCASResponseHandler.createDBRforReading(this); fillInDBR(monitorDBR); ((TIME)monitorDBR).setTimeStamp(timestamp); System.arraycopy(this.value, 0, monitorDBR.getValue(), 0, count); eventCallback.postEvent(Monitor.VALUE|Monitor.LOG, monitorDBR); } return CAStatus.NORMAL; }
retVal.setTimeStamp(new TimeStamp(secPastEpoch, nsec));
retVal.setTimeStamp(new TimeStamp(secPastEpoch, nsec));
timestamp = new TimeStamp(); checkForAlarms();
timestamp = new TimeStamp(); checkForAlarms();
JCAMessagePayload(DBR metadata, MonitorEvent event) { if (event != null) { // If we have a monitor event, it may be an "incomplete" // String event because of the RTYP support if (event.getDBR() instanceof DBR_String && !(event.getDBR() instanceof DBR_TIME_String)) { DBR_String originalValue = (DBR_String) event.getDBR(); // Received only partial data. Filling in time and alarm DBR_TIME_String value = new DBR_TIME_String(originalValue.getStringValue()); value.setSeverity(Severity.NO_ALARM); value.setStatus(Status.NO_ALARM); value.setTimeStamp(new TimeStamp()); event = new MonitorEvent((Channel) event.getSource(), value, event.getStatus()); } } this.metadata = metadata; this.event = event; }
JCAMessagePayload(DBR metadata, MonitorEvent event) { if (event != null) { // If we have a monitor event, it may be an "incomplete" // String event because of the RTYP support if (event.getDBR() instanceof DBR_String && !(event.getDBR() instanceof DBR_TIME_String)) { DBR_String originalValue = (DBR_String) event.getDBR(); // Received only partial data. Filling in time and alarm DBR_TIME_String value = new DBR_TIME_String(originalValue.getStringValue()); value.setSeverity(Severity.NO_ALARM); value.setStatus(Status.NO_ALARM); value.setTimeStamp(new TimeStamp()); event = new MonitorEvent((Channel) event.getSource(), value, event.getStatus()); } } this.metadata = metadata; this.event = event; }