public static DataItemValueLight valueOf ( final DataItemValue dataItemValue ) { if ( ( dataItemValue == null ) || dataItemValue.equals ( DataItemValue.DISCONNECTED ) ) { return DISCONNECTED; } return new DataItemValueLight ( dataItemValue.getValue (), dataItemValue.getSubscriptionState (), dataItemValue.getTimestamp () == null ? Long.MIN_VALUE : dataItemValue.getTimestamp ().getTimeInMillis (), dataItemValue.isManual (), dataItemValue.isError () ); }
public Builder ( final DataItemValue sourceValue ) { if ( sourceValue == null ) { this.value = Variant.NULL; this.attributes = new HashMap<String, Variant> (); this.subscriptionState = SubscriptionState.DISCONNECTED; } else { this.value = sourceValue.getValue (); this.attributes = new HashMap<String, Variant> ( sourceValue.getAttributes () ); this.subscriptionState = sourceValue.getSubscriptionState (); this.subscriptionError = sourceValue.getSubscriptionError (); } }
/** * Return if the value is unsafe * * @return <code>true</code> if the value part is unsafe, <code>false</code> * otherwise */ protected boolean isUnsafe () { return this.value.isError () || !this.value.isConnected (); }
public boolean isError () { if ( isConnected () ) { return isAttribute ( "error", false ); } return false; }
@Override protected void update () { if ( this.value == null ) { return; } if ( this.value.getSubscriptionError () == null ) { this.stateText.setText ( this.value.getSubscriptionState ().name () ); } else { this.stateText.setText ( String.format ( Messages.OverviewDetailsPart_SubscriptionStateFormat, this.value.getSubscriptionState ().name (), this.value.getSubscriptionError ().getMessage () ) ); } this.warnText.setText ( this.value.isWarning () ? Messages.OverviewDetailsPart_WarningActiveText : Messages.OverviewDetailsPart_WarningInactiveText ); this.alarmText.setText ( this.value.isAlarm () ? Messages.OverviewDetailsPart_AlarmActiveText : Messages.OverviewDetailsPart_AlarmInactiveText ); this.errorText.setText ( this.value.isError () ? Messages.OverviewDetailsPart_ErrorActiveText : Messages.OverviewDetailsPart_ErrorInactiveText ); this.manualText.setText ( this.value.isManual () ? Messages.OverviewDetailsPart_ManualActiveText : Messages.OverviewDetailsPart_ManualInactiveText ); this.blockedText.setText ( this.value.isBlocked () ? Messages.OverviewDetailsPart_BlockedActiveText : Messages.OverviewDetailsPart_BlockedInactiveText ); this.valueText.setText ( this.value.getValue () != null ? this.value.getValue ().toString () : Messages.OverviewDetailsPart_NullText ); final Calendar c = this.value.getTimestamp (); this.timestampText.setText ( c != null ? String.format ( Messages.OverviewDetailsPart_TimeFormat, c ) : Messages.OverviewDetailsPart_NullText ); } }
if ( isConnected () ) if ( isAlarm () ) if ( isError () ) if ( isManual () ) final Calendar c = getTimestamp (); if ( c != null )
public boolean isValid ( final String name ) { final DataItemValue div = getValue ( name ); if ( div == null ) { return false; } else { if ( !div.isConnected () || div.isError () || div.getValue () == null || div.getValue ().isNull () ) { return false; } else { return true; } } }
/** * Fetch the current cached attributes. * <b>Note:</b> The returned object may not be modified! * * @return the current attributes * @deprecated You should use {@link #getSnapshotValue()} instead to get a * consistent value */ @Deprecated public Map<String, Variant> getAttributes () { return this.value.getAttributes (); }
@Override public void run () { listener.notifySubscriptionChange ( SubscriptionState.CONNECTED, null ); listener.notifyDataChange ( value.getValue (), value.getAttributes (), false ); } } );
timestamp = value.getAsTimestamp ( "org.eclipse.scada.da.master.common.block.timestamp" ); //$NON-NLS-1$ reason = value.getAttributes ().get ( "org.eclipse.scada.da.master.common.block.note" ); //$NON-NLS-1$ user = value.getAttributes ().get ( "org.eclipse.scada.da.master.common.block.user" ); //$NON-NLS-1$ image = Activator.getDefault ().getImageRegistry ().get ( value.isBlocked () ? Activator.IMG_BLOCK_LOCKED : Activator.IMG_BLOCK_UNLOCKED ); this.reasonText.setEnabled ( isAvailable () && value != null && !isActive () && value.isConnected () ); this.blockButton.setEnabled ( isAvailable () && value != null && !isActive () && value.isConnected () ); this.unblockButton.setEnabled ( isAvailable () && value != null && isActive () && value.isConnected () );
protected void updateData ( DataItemValue value ) logger.debug ( "Update data: {} -> {}", new Object[] { value, value == null ? "" : value.getAttributes () } ); if ( this.value.equals ( value ) ) this.lastValue = value == null ? null : value.getValue (); this.value = value;
private DataItemValue applyAutoTimestamp ( DataItemValue value ) { if ( value != null && value.getTimestamp () == null ) { try { if ( !this.lastValue.equals ( value.getValue () ) ) { this.lastTimestamp = Calendar.getInstance (); } } catch ( final Exception e ) { // nothing logger.info ( "Failed to update timestamp", e ); } final DataItemValue.Builder builder = new DataItemValue.Builder ( value ); builder.setTimestamp ( this.lastTimestamp ); value = builder.build (); } return value; }
public Variant getValue () { if ( this.value == null ) { return Variant.NULL; } return this.value.getValue (); }
/** * Check if the value has the manual override attribute set * * @return <code>true</code> if the value is manually overridden, <code>false</code> otherwise */ public boolean isManual () { return isAttribute ( "manual", false ) || isAttribute ( "org.eclipse.scada.da.manual.active", false ); }
public SubscriptionState getSubscriptionState () { if ( this.value == null ) { return SubscriptionState.DISCONNECTED; } return this.value.getSubscriptionState (); }
protected boolean isManual () { return this.value.isManual (); }
protected boolean isError () { return this.value.isError (); }
public boolean isConnected () { for ( final Map.Entry<String, DataValue> entry : this.data.entrySet () ) { if ( entry.getValue () == null || entry.getValue ().isIgnoreSummary () ) { continue; } if ( !entry.getValue ().getValue ().isConnected () ) { return false; } } for ( final SummaryInformation child : this.childData ) { if ( !child.isConnected () ) { return false; } } return true; }
protected boolean isAlarm () { return this.value.isAlarm (); }
if ( listEntry.getItemValue () != null ) final Calendar timestamp = listEntry.getItemValue ().getTimestamp (); if ( timestamp != null )