new Status()
- Description:
Represents a
baja:Statusin BajaScript.Statusprovides a bit mask for various standardized
status flags in the Baja control architecture. Plus
it provides for arbitrary extensions usingBFacets.When creating a
Simple, always use themake()method instead of
creating a new Object.
- Source:
Extends
Members
(static) ACTIVE_LEVEL :String
- Description:
String used in a
Facetsfor identifying the active priority level of a
writable point.
- Source:
String used in a Facets for identifying the active priority level of a
writable point.
Type:
(static) ALARM :Number
- Description:
Bit for alarm.
- Source:
Bit for alarm.
Type:
- Number
(static) DEFAULT :baja.Status
- Description:
Default
Statusinstance.
- Source:
Default Status instance.
Type:
(static) DISABLED :Number
- Description:
Bit for disabled.
- Source:
Bit for disabled.
Type:
- Number
(static) DOWN :Number
- Description:
Bit for down.
- Source:
Bit for down.
Type:
- Number
(static) FAULT :Number
- Description:
Bit for fault.
- Source:
Bit for fault.
Type:
- Number
(static) NULL :Number
- Description:
Bit for null.
- Source:
Bit for null.
Type:
- Number
(static) OVERRIDDEN :Number
- Description:
Bit for overridden.
- Source:
Bit for overridden.
Type:
- Number
(static) STALE :Number
- Description:
Bit for stale.
- Source:
Bit for stale.
Type:
- Number
(static) UNACKED_ALARM :Number
- Description:
Bit for unacked alarm.
- Source:
Bit for unacked alarm.
Type:
- Number
(static) alarm :baja.Status
- Description:
Statusfor alarm (null facets).
- Source:
Status for alarm (null facets).
Type:
(static) disabled :baja.Status
- Description:
Statusfor disabled (null facets).
- Source:
Status for disabled (null facets).
Type:
(static) down :baja.Status
- Description:
Statusfor down (null facets).
- Source:
Status for down (null facets).
Type:
(static) fault :baja.Status
- Description:
Statusfor fault (null facets).
- Source:
Status for fault (null facets).
Type:
(static) nullStatus :baja.Status
- Description:
Statusfor null status (null facets).
- Source:
Status for null status (null facets).
Type:
(static) ok :baja.Status
- Description:
Statusfor ok (null facets).
- Source:
Status for ok (null facets).
Type:
(static) overridden :baja.Status
- Description:
Statusfor overridden (null facets).
- Source:
Status for overridden (null facets).
Type:
(static) stale :baja.Status
- Description:
Statusfor stale (null facets).
- Source:
Status for stale (null facets).
Type:
(static) unackedAlarm :baja.Status
- Description:
Statusfor unacked alarm (null facets).
- Source:
Status for unacked alarm (null facets).
Type:
Methods
decodeAsync(str, batchopt) → {baja.Simple|Promise.<baja.Simple>}
- Description:
The string encoding of certain Simples may include Type information, or other data that may
require asynchronous operations to decode. For instance, some Simples may function as
"containers" for other Simples, and may include that Type information in the string encoding.
That Simple would then need to import those Types before it could be fully decoded in the
browser.baja.Facets is a great example of this. A Facets may contain FrozenEnum values that are
defined by Types, such asbaja:Weekday. For a Facets containing a Weekday to be fully
constructed in the browser, thebaja:WeekdayType must be imported first. Since importing
a Type may require a network call, this Facets instance might not be able to be constructed
synchronously, using onlydecodeFromString(). baja.Facets has itself implemented
decodeAsync()to import any necessary Types.When implementing a Type Extension for a Simple, if your Simple references arbitrary Types that
need to be imported when decoding your Simple, implementdecodeAsync()and perform any Type
imports (or other asynchronous operations) there.If you are writing code that decodes Simples from strings - that is, when you have a type spec
and string encoding, and you need to be able to decode any kind of Simple - favor the use of
decodeAsync, as it gives the individual Simple a chance to perform async operations to ensure
that the decoded Simple is fully correct.The default implementation just returns
decodeFromStringdirectly.Prior to Niagara 4.14,
decodeAsync()was only used in field editors. In 4.14 and later,
decodeAsync()will be used by BajaScript itself to support asynchronous decoding of Simples
when resolving ORDs and retrieving other data from the station.(Note:
decodeAsync()cannot be used by the framework to decode frozen slots. If you
have a frozen slot, whose definition is a Simple that would require the use of
decodeAsync()to construct it, it will not work. The best approach would be to implement a
Type Extension that would use thebaja!plugin to preload all the types referenced by the
default value of that frozen slot, so thatdecodeFromStringwould have all the information
it needed to construct it synchronously.)
- Source:
- Inherited From:
Example
return Promise.resolve(baja.$(simpleTypeSpec).decodeAsync(stringEncoding))
.then((simpleInstance) => {});
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
str |
string | ||
batch |
baja.comm.Batch |
<optional> |
optional batch to use |
Returns:
may return the Simple instance
directly, or a Promise resolving to same - so wrap in Promise.resolve()
if unsure.
- Type
- baja.Simple | Promise.<baja.Simple>
decodeFromString(str) → {baja.Status}
- Description:
Decode a
Statusfrom aString.
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
str |
String |
Returns:
- Type
- baja.Status
encodeToString() → {String}
- Description:
Encode the
Statusto aString.
- Source:
- Overrides:
Returns:
- Type
- String
equals(obj) → {Boolean}
- Description:
Equality test.
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Returns:
- Type
- Boolean
equivalent(obj) → {Boolean}
- Description:
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.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Returns:
- Type
- Boolean
flagsToString() → {String}
- Description:
Returns a string of just the flags which are set or
returns ok if none are set.
- Source:
Returns:
- Type
- String
get(name, defopt)
- Description:
Return a value from the status facets.
- Source:
Parameters:
| Name | Type | Attributes | 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 |
Returns:
the value from the status facets (null if def is undefined and name can't be found).
getAgents(isopt, batchopt) → {Promise}
- Description:
Returns a promise that resolves to the agent list for this Object.
- Source:
- Inherited From:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
is |
Array.<String> |
<optional> |
An optional array of filters to add to the |
batch |
baja.comm.Batch |
<optional> |
An optional object used to batch network |
Returns:
A promise that will resolve with the Agent Info.
- Type
- Promise
getBit(ordinal) → {boolean}
- Source:
- Since:
- Niagara 4.8
Parameters:
| Name | Type | Description |
|---|---|---|
ordinal |
number |
Returns:
true if this ordinal is set
- Type
- boolean
getBits() → {Number}
- Description:
Return the
Statusbits.
- Source:
Returns:
status bits.
- Type
- Number
getFacets() → {baja.Facets}
- Description:
Return the facets for the
Status.
- Source:
Returns:
status facets
- Type
- baja.Facets
getIcon() → {baja.Icon}
- Description:
Return the Object's Icon.
- Source:
- Inherited From:
Returns:
- Type
- baja.Icon
getOrdinals() → {Array.<number>}
- Source:
- Since:
- Niagara 4.8
Returns:
all known Status ordinals
- Type
- Array.<number>
getStatus() → {baja.Status}
- Description:
Return the status (itself).
- Source:
Returns:
the status (itself).
- Type
- baja.Status
getType() → {Type}
- Description:
Get the type of this instance.
- Source:
- Inherited From:
Returns:
- Type
- Type
getTypeDisplayName(cxopt) → {Promise.<string>|string}
- Description:
Gets the friendly type display name for this object.
- Source:
- Since:
- Niagara 4.10
- Inherited From:
- See:
-
- baja.Type#getDisplayName
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cx |
Object |
<optional> |
a context to be passed down to Type |
Returns:
If no context is provided, the type
display name is returned synchronously as a string. If context provided,
the type display name is resolved via a promise as a string.
- Type
- Promise.<string> | string
isAlarm() → {Boolean}
- Description:
Return true if the
Statusis in alarm.
- Source:
Returns:
- Type
- Boolean
isDisabled() → {Boolean}
- Description:
Return true if the
Statusis disabled.
- Source:
Returns:
- Type
- Boolean
isDown() → {Boolean}
- Description:
Return true if the
Statusis down.
- Source:
Returns:
- Type
- Boolean
isFault() → {Boolean}
- Description:
Return true if the
Statusis in fault.
- Source:
Returns:
- Type
- Boolean
isNull() → {Boolean}
- Description:
Return true if the
Statusis null.
- Source:
Returns:
- Type
- Boolean
isOk() → {Boolean}
- Description:
Return true if the
Statusis ok.
- Source:
Returns:
- Type
- Boolean
isOverridden() → {Boolean}
- Description:
Return true if the
Statusis overridden.
- Source:
Returns:
- Type
- Boolean
isStale() → {Boolean}
- Description:
Return true if the
Statusis stale.
- Source:
Returns:
- Type
- Boolean
isUnackedAlarm() → {Boolean}
- Description:
Return true if the
Statusis unacked alarm.
- Source:
Returns:
- Type
- Boolean
isValid() → {Boolean}
- Description:
Return true if the
Statusis not disabled, fault, down
stale or null.
- Source:
Returns:
true if valid.
- Type
- Boolean
make(obj) → {baja.Status}
- Description:
Make a
Status.
- Source:
- Overrides:
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
}};
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
obj |
Object | Number | the Object Literal that specifies the method's arguments or Status bits. Properties
|
Returns:
the status.
- Type
- baja.Status
newCopy(exactopt)
- Description:
Every value may be cloned using the
newCopymethod.Please note that
Simples are immutable so they don't
allocate a new instance.
- Source:
- Inherited From:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
exact |
Boolean |
<optional> |
true if an exact copy of the value should be |
Returns:
a copy of the value (or the same instance if the value is a
Simple).
toEnumSet() → {baja.EnumSet}
- Source:
- Since:
- Niagara 4.8
Returns:
an EnumSet representing which bits are selected
out of the available bits for a Status
- Type
- baja.EnumSet
toString(obj) → {String|Promise.<String>}
- Description:
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).
- Source:
- Overrides:
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
obj |
Object | the Object Literal for the method's arguments. Properties
|
Returns:
valueOf() → {String}
- Source:
- Inherited From:
Returns:
the string encoding of the Simple, by default
- Type
- String
(static) getStatusFromIStatus() → {baja.Status}
- Description:
Return the status from a
BIStatus.
- Source:
Returns:
resolved status value
- Type
- baja.Status
(static) make(obj) → {baja.Status}
- Description:
Make a
Status.
- Source:
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
}};
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
obj |
Object | Number | the Object Literal that specifies the method's arguments or Status bits. Properties
|
Returns:
the status.
- Type
- baja.Status