new Status()
Represents a baja:Status
in BajaScript.
Status
provides a bit mask for various standardized
status flags in the Baja control architecture. Plus
it provides for arbitrary extensions using BFacets
.
When creating a Simple
, always use the make()
method instead of
creating a new Object.
Extends
Members
-
<static> ACTIVE_LEVEL :String
-
String used in a
Facets
for identifying the active priority level of a
writable point.Type:
-
<static> alarm :baja.Status
-
Status
for alarm (null facets).Type:
-
<static> ALARM :Number
-
Bit for alarm.
Type:
- Number
-
<static> DEFAULT :baja.Status
-
Default
Status
instance.Type:
-
<static> disabled :baja.Status
-
Status
for disabled (null facets).Type:
-
<static> DISABLED :Number
-
Bit for disabled.
Type:
- Number
-
<static> down :baja.Status
-
Status
for down (null facets).Type:
-
<static> DOWN :Number
-
Bit for down.
Type:
- Number
-
<static> FAULT :Number
-
Bit for fault.
Type:
- Number
-
<static> fault :baja.Status
-
Status
for fault (null facets).Type:
-
<static> NULL :Number
-
Bit for null.
Type:
- Number
-
<static> nullStatus :baja.Status
-
Status
for null status (null facets).Type:
-
<static> ok :baja.Status
-
Status
for ok (null facets).Type:
-
<static> overridden :baja.Status
-
Status
for overridden (null facets).Type:
-
<static> OVERRIDDEN :Number
-
Bit for overridden.
Type:
- Number
-
<static> STALE :Number
-
Bit for stale.
Type:
- Number
-
<static> stale :baja.Status
-
Status
for stale (null facets).Type:
-
<static> UNACKED_ALARM :Number
-
Bit for unacked alarm.
Type:
- Number
-
<static> unackedAlarm :baja.Status
-
Status
for unacked alarm (null facets).Type:
Methods
-
<static> getStatusFromIStatus()
-
Return the status from a
BIStatus
.Returns:
resolved status value
- Type
- baja.Status
-
<static> make(obj)
-
Make a
Status
.Parameters:
Name Type Description obj
Object | Number the Object Literal that specifies the method's arguments or Status bits.
Properties
Name Type Argument Description bits
Number the Status bits.
facets
baja.Facets <optional>
the facets for the Status.
orig
baja.Status <optional>
if defined, obj.state must also be defined. This is used to create
a new Status with one of it's bit states changed (see example above).state
Boolean <optional>
the state of the bit to change (used in conjunction with obj.orig).
Returns:
the status.
- Type
- baja.Status
Example
//The bits (Number) or (for more arguments) an Object Literal can be //used to specify the method's arguments. var st1 = baja.Status.make(baja.Status.DOWN | baja.Status.FAULT); // ... or for more arguments... var st2 = baja.Status.make({ bits: baja.Status.DOWN, facets: facets }); //The make() method can also be used to create a new status with its //state changed... var newStatus = baja.Status.make({ orig: oldStatus, bits: baja.Status.OVERRIDDEN, state: true }};
-
decodeAsync(str [, batch])
-
The string encoding of certain Simples may include Type information, or
other data that may be require asynchronous operations to decode. BOX is
designed to handle these situations when decoding data from the station,
but when user code needs to decode string-encoded Simples directly, prefer
this method as it gives the individual Simple a chance to import Types,
etc. to ensure that the decoded Simple is fully correct.The default implementation just returns
decodeFromString
directly.Parameters:
Name Type Argument Description str
string batch
baja.comm.Batch <optional>
optional batch to use
- Inherited From:
Returns:
may return the Simple instance
directly, or a Promise resolving to same - so wrap inPromise.resolve()
if unsure.- Type
- baja.Simple | Promise.<baja.Simple>
-
decodeFromString(str)
-
Decode a
Status
from aString
.Parameters:
Name Type Description str
String - Overrides:
Returns:
- Type
- baja.Status
-
encodeToString()
-
Encode the
Status
to aString
.- Overrides:
Returns:
- Type
- String
-
equals(obj)
-
Equality test.
Parameters:
Name Type Description obj
- Overrides:
Returns:
- Type
- Boolean
-
equivalent(obj)
-
Equivalence test.
equivalent()
is used to compare if two Objects have equivalent
state, but might not want to return true for equals since it
it has implied semantics for many operations. The default
implementation returns the result of baja.Object#equals.Parameters:
Name Type Description obj
- Inherited From:
Returns:
- Type
- Boolean
-
flagsToString()
-
Returns a string of just the flags which are set or
returns ok if none are set.Returns:
- Type
- String
-
get(name [, def])
-
Return a value from the status facets.
Parameters:
Name Type Argument Description name
String the name of the value to get from the status facets.
def
<optional>
if defined, this value is returned if the name can't be found in
the status facets.Returns:
the value from the status facets (null if def is undefined and name can't be found).
-
getAgents( [is], batch)
-
Returns a promise that resolves to the agent list for this Object.
Parameters:
Name Type Argument Description is
Array.<String> <optional>
An optional array of filters to add to the
agent query.batch
baja.comm.Batch An optional object used to batch network
calls together.- Inherited From:
- See:
Returns:
A promise that will resolve with the Agent Info.
- Type
- Promise
-
getBits()
-
Return the
Status
bits.Returns:
status bits.
- Type
- Number
-
getFacets()
-
Return the facets for the
Status
.Returns:
status facets
- Type
- baja.Facets
-
getIcon()
-
Return the Object's Icon.
- Inherited From:
Returns:
- Type
- baja.Icon
-
getStatus()
-
Return the status (itself).
Returns:
the status (itself).
- Type
- baja.Status
-
getType()
-
Get the type of this instance.
- Inherited From:
Returns:
- Type
- Type
-
isAlarm()
-
Return true if the
Status
is in alarm.Returns:
- Type
- Boolean
-
isDisabled()
-
Return true if the
Status
is disabled.Returns:
- Type
- Boolean
-
isDown()
-
Return true if the
Status
is down.Returns:
- Type
- Boolean
-
isFault()
-
Return true if the
Status
is in fault.Returns:
- Type
- Boolean
-
isNull()
-
Return true if the
Status
is null.Returns:
- Type
- Boolean
-
isOk()
-
Return true if the
Status
is ok.Returns:
- Type
- Boolean
-
isOverridden()
-
Return true if the
Status
is overridden.Returns:
- Type
- Boolean
-
isStale()
-
Return true if the
Status
is stale.Returns:
- Type
- Boolean
-
isUnackedAlarm()
-
Return true if the
Status
is unacked alarm.Returns:
- Type
- Boolean
-
isValid()
-
Return true if the
Status
is not disabled, fault, down
stale or null.Returns:
true if valid.
- Type
- Boolean
-
make(obj)
-
Make a
Status
.Parameters:
Name Type Description obj
Object | Number the Object Literal that specifies the method's arguments or Status bits.
Properties
Name Type Argument Description bits
Number the Status bits.
facets
baja.Facets <optional>
the facets for the Status.
orig
baja.Status <optional>
if defined, obj.state must also be defined. This is used to create
a new Status with one of it's bit states changed (see example above).state
Boolean <optional>
the state of the bit to change (used in conjunction with obj.orig).
- Overrides:
Returns:
the status.
- Type
- baja.Status
Example
//The bits (Number) or (for more arguments) an Object Literal can be //used to specify the method's arguments. var st1 = baja.Status.make(baja.Status.DOWN | baja.Status.FAULT); // ... or for more arguments... var st2 = baja.$("baja:Status").make({ bits: baja.Status.DOWN, facets: facets }); //The make method can also be used to create a new status with its //state changed... var newStatus = baja.$("baja:Status").make({ orig: oldStatus, bits: baja.Status.OVERRIDDEN, state: true }};
-
newCopy( [exact])
-
Every value may be cloned using the
newCopy
method.Please note that
Simple
s are immutable so they don't
allocate a new instance.Parameters:
Name Type Argument Description exact
Boolean <optional>
true if an exact copy of the value should be
made (only valid in the Component architecture).- Inherited From:
- See:
Returns:
a copy of the value (or the same instance if the value is a
Simple
). -
toString(obj)
-
Returns the string representation of the 'Status'.
This method is invoked synchronously. The string result will be returned
directly from this function.Notes on lexicons:
- A lexicon will be used if it is passed in.
- If no lexicon is passed in, the baja lexicon will be used if it has been
cached locally. - If the baja lexicon has not been cached, strings units will be
represented by their internal tag names (which are in English).
Parameters:
Name Type Description obj
Object the Object Literal for the method's arguments.
Properties
Name Type Argument Description lex
<optional>
the 'baja' lexicon
- Overrides:
Returns:
- Type
- String
-
valueOf()
-
Return the inner value of the object.
By default the object's instance is returned.
- Inherited From:
Returns:
the inner value of the object or just the object's instance.
- Type
- *