Skip to content

hxComps ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793390153/FIN+5.3.1+hxComps 中文整理基于 FIN 5.3.1

导读: 核心组件库

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • mixins
  • classes
  • Slot Details
    • calculate
    • minInputs
    • axon
    • onExecute
    • inA
    • inB
    • bindIn
    • bindOut
    • out
    • in
    • make
    • offDelay
    • onChangeThis
    • onDelay
    • onExecuteFreq
    • outNot
    • curVal
    • statusBool
    • bool
    • dateTime
    • date
    • rec
    • grid
    • cx
    • bias
    • cv
    • dc
    • enabled
    • freq
    • ic
    • maxOut
    • minOut
    • pc
    • rampTime
    • sp
    • statusNumber
    • num
    • inC
    • inD
    • ref
    • amplitude
    • offset
    • onMount
    • period
    • updateInterval
    • alarm
    • clear
    • disabled
    • down
    • fault
    • fromCurStatus
    • fromName
    • fromStr
    • isAlarm
    • isDisabled
    • isDown
    • isFault
    • isOk
    • isOverridden
    • isStale
    • isUnacked
    • isValid
    • merge
    • ok
    • only
    • overridden
    • set
    • stale
    • unacked
    • str
    • invalidToNull
    • status
    • toStr
    • val
    • statusStr
    • time

API 正文(英文) ​

| NumberPointInput | | | NumberPointOutput | | | NumberVar | | | Or | Computes the logical "or" of its inputs | | PointInput | | | PointOutput | | | PointVar | | | Power | Computes a raised to the b power: out = inA ^ inB | | QuadLogic | The base spec for all logic components that operate on up to four inputs | | QuadMath | The base spec for all math components that operate on up to four inputs | | RefVar | | | Sine | Computes the sine of its input: out = sin(inA) | | SineWave | The output of this component generates a sine wave. | | SquareRoot | Computes the square root of its input: out = sqrt(inA) | | StrConst | Str constant | | StrPointInput | | | StrPointOutput | | | StrVar | | | Subtract | Computes the difference of its inputs (A - B) | | Tangent | Computes the cosine of its input: out = tan(inA) | | TimeVar | | | UnaryMath | The base spec for all math components that operate on one input | | Var | | | Xor | Computes the exclusive-or of its inputs |


AbsValue ​

class AbsValue : UnaryMath

Computes the absolute value of its input

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


Add ​

class Add : QuadMath

Computes the sum of its inputs

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(StatusNumber? a, StatusNumber? b, StatusNumber? c, StatusNumber? d)


minInputs ​

protected virtual const override Int minInputs := 1


And ​

class And : QuadLogic

Computes the logical "and" of its inputs

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Bool? a, Bool? b, Bool? c, Bool? d)


minInputs ​

protected virtual const override Int minInputs := 1


ArcCosine ​

class ArcCosine : UnaryMath

Computes the arccosine of its input: out = acos(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


ArcSine ​

class ArcSine : UnaryMath

Computes the arcsine of its input: out = asin(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


ArcTangent ​

class ArcTangent : UnaryMath

Computes the arctangent of its input: out = atan(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


AxonComp ​

class AxonComp : HxComp

A component that evaluates an Axon expression

Fields

axon

Methods

onExecute

Slot Details ​


axon ​

virtual Str axon


onExecute ​

virtual override Void onExecute()


BinaryMath ​

abstract class BinaryMath : Math

The base spec for all math components that operate on two inputs

Fields

inAInput A
inBInput B

Methods

calculate
onExecute

Slot Details ​


calculate ​

protected abstract Number calculate(Number a, Number b)


inA ​

virtual StatusNumber? inA

Input A


inB ​

virtual StatusNumber? inB

Input B


onExecute ​

virtual override Void onExecute()


BindableComp ​

mixin BindableComp : Comp

Methods

bindIn
bindOut

Slot Details ​


bindIn ​

virtual Void bindIn(Obj? val)


bindOut ​

abstract StatusVal? bindOut()


BoolConst ​

class BoolConst : HxComp

Boolean constant

Fields

out

Slot Details ​


out ​

virtual StatusBool? out


BoolDelay ​

class BoolDelay : HxComp

Bool delay

Constructors

make

Fields

inInput to the delay.
offDelayHow long to wait before setting the out slot to false when the in slot transitions to false.
onDelayHow long to wait before setting the out slot to true when the in slot transitions to true.

Methods

onChangeThis
onExecute
onExecuteFreq
outThe value of the in slot after any delays are accounted for.
outNotThe inverse of the current out slot.

Slot Details ​


in ​

virtual StatusBool? in

Input to the delay.


make ​

new make()


offDelay ​

virtual Duration offDelay

How long to wait before setting the out slot to false when the in slot transitions to false.


onChangeThis ​

virtual override Void onChangeThis(Str slot, Obj? newVal)


onDelay ​

virtual Duration onDelay

How long to wait before setting the out slot to true when the in slot transitions to true.


onExecute ​

virtual override Void onExecute()


onExecuteFreq ​

virtual override Duration? onExecuteFreq()


out ​

virtual StatusBool? out()

The value of the in slot after any delays are accounted for.


outNot ​

virtual StatusBool? outNot()

The inverse of the current out slot.


BoolPointInput ​

class BoolPointInput : PointInput

Methods

curVal

Slot Details ​


curVal ​

virtual override StatusBool? curVal()


BoolPointOutput ​

class BoolPointOutput : PointOutput

Methods

statusBool

Slot Details ​


statusBool ​

StatusBool? statusBool()


BoolVar ​

class BoolVar : Var

Methods

bool

Slot Details ​


bool ​

Bool? bool()


Comparison ​

abstract class Comparison : Logic

The base spec for all mathematical comparison operators

Fields

inAInput A
inBInput B

Methods

calculate
onExecute

Slot Details ​


calculate ​

protected abstract Bool calculate(Number a, Number b)


inA ​

virtual StatusNumber? inA

Input A


inB ​

virtual StatusNumber? inB

Input B


onExecute ​

override Void onExecute()


Cosine ​

class Cosine : UnaryMath

Computes the cosine of its input: out = cos(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


DateTimeVar ​

class DateTimeVar : Var

Methods

dateTime

Slot Details ​


dateTime ​

DateTime? dateTime()


DateVar ​

class DateVar : Var

Methods

date

Slot Details ​


date ​

Date? date()


Divide ​

class Divide : BinaryMath

Computes the quotient of its inputs (A / B)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a, Number b)


EntityVar ​

class EntityVar : Var

Methods

rec

Slot Details ​


rec ​

Dict? rec()


Equal ​

class Equal : Comparison

Computes A == B

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Number a, Number b)


Exponential ​

class Exponential : UnaryMath

Computes out = e ^ inA where e is Euler's number

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


Factorial ​

class Factorial : UnaryMath

Computes out = inA!

Methods

calculate
onExecute

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


onExecute ​

virtual override Void onExecute()


Folder ​

class Folder : HxComp

Slot Details ​


GreaterThan ​

class GreaterThan : Comparison

Computes A > B

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Number a, Number b)


GreaterThanEqual ​

class GreaterThanEqual : Comparison

Computes A >= B

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Number a, Number b)


GridVar ​

class GridVar : Var

Methods

grid

Slot Details ​


grid ​

Grid? grid()


HxComp ​

abstract class HxComp : CompObj, BindableComp

Methods

bindOut
cx

Slot Details ​


bindOut ​

virtual override StatusVal? bindOut()


cx ​

CompContext cx()


LessThan ​

class LessThan : Comparison

Computes A < B

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Number a, Number b)


LessThanEqual ​

class LessThanEqual : Comparison

Computes A <= B

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Number a, Number b)


LogBase10 ​

class LogBase10 : UnaryMath

Computes the log base 10 of its input: out = log10(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


LogNatural ​

class LogNatural : UnaryMath

Computes the natural logarithm of its input: out = ln(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


Logic ​

abstract class Logic : HxComp

The base spec for all logic components

Methods

outThe computed value

Slot Details ​


out ​

virtual StatusBool? out()

The computed value


LoopPoint ​

class LoopPoint : HxComp

A simple PID loop TODO:slots? Loop Action, Disable Action,

Fields

biasBias
cvController variable
dcDerivative constant
enabledIs the loop enabled or not
freqHow often to execute the loop
icIntegral constant
maxOutMaximum output value
minOutMinimum output value
pcProportional constant
rampTimeRamp time
spSetpoint

Methods

onExecute
onExecuteFreq
outThe output of the PID loop

Slot Details ​


bias ​

virtual Float bias

Bias


cv ​

virtual StatusNumber? cv

Controller variable


dc ​

virtual Float dc

Derivative constant


enabled ​

virtual Bool enabled

Is the loop enabled or not


freq ​

virtual Duration freq

How often to execute the loop


ic ​

virtual Float ic

Integral constant


maxOut ​

virtual Float maxOut

Maximum output value


minOut ​

virtual Float minOut

Minimum output value


onExecute ​

virtual override Void onExecute()


onExecuteFreq ​

virtual override Duration? onExecuteFreq()


out ​

virtual StatusNumber? out()

The output of the PID loop


pc ​

virtual Duration pc

Proportional constant


rampTime ​

virtual Duration rampTime

Ramp time


sp ​

virtual StatusNumber? sp

Setpoint


Math ​

abstract class Math : HxComp

The base spec for all math components

Methods

outThe computed value

Slot Details ​


out ​

virtual StatusNumber? out()

The computed value


Maximum ​

class Maximum : QuadMath

Finds the maximum value of its valid inputs and sets that value to out. out = max(inA, inB, inC, inD)

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(StatusNumber? a, StatusNumber? b, StatusNumber? c, StatusNumber? d)


minInputs ​

protected virtual const override Int minInputs := 1


Minimum ​

class Minimum : QuadMath

Finds the minimum value of its valid inputs and sets that value to out. out = min(inA, inB, inC, inD)

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(StatusNumber? a, StatusNumber? b, StatusNumber? c, StatusNumber? d)


minInputs ​

protected virtual const override Int minInputs := 1


Multiply ​

class Multiply : QuadMath

Computes the product of its inputs

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(StatusNumber? a, StatusNumber? b, StatusNumber? c, StatusNumber? d)


minInputs ​

protected virtual const override Int minInputs := 1


Not ​

class Not : Logic

Computes the logical negation of its input

Fields

in

Methods

onExecute

Slot Details ​


in ​

virtual StatusBool? in


onExecute ​

virtual override Void onExecute()


NotEqual ​

class NotEqual : Comparison

Computes A != B

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Number a, Number b)


NumberConst ​

class NumberConst : HxComp

Number constant

Fields

out

Slot Details ​


out ​

virtual StatusNumber? out


NumberPointInput ​

class NumberPointInput : PointInput

Methods

curVal

Slot Details ​


curVal ​

virtual override StatusNumber? curVal()


NumberPointOutput ​

class NumberPointOutput : PointOutput

Methods

statusNumber

Slot Details ​


statusNumber ​

StatusNumber? statusNumber()


NumberVar ​

class NumberVar : Var

Methods

num

Slot Details ​


num ​

Number? num()


Or ​

class Or : QuadLogic

Computes the logical "or" of its inputs

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Bool? a, Bool? b, Bool? c, Bool? d)


minInputs ​

protected virtual const override Int minInputs := 1


PointInput ​

abstract class PointInput : PointVar

Methods

bindOut
curVal
onChangeThis

Slot Details ​


bindOut ​

virtual override StatusVal? bindOut()


curVal ​

virtual StatusVal? curVal()


onChangeThis ​

virtual override Void onChangeThis(Str slot, Obj? newVal)


PointOutput ​

abstract class PointOutput : PointVar

Fields

in

Methods

bindOut

Slot Details ​


bindOut ​

virtual override StatusVal? bindOut()


in ​

virtual StatusVal? in


PointVar ​

abstract class PointVar : EntityVar

Slot Details ​


Power ​

class Power : BinaryMath

Computes a raised to the b power: out = inA ^ inB

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a, Number b)


QuadLogic ​

abstract class QuadLogic : Logic

The base spec for all logic components that operate on up to four inputs

Fields

inAInput A
inBInput B
inCInput C
inDInput D

Methods

calculate
minInputs
onExecute

Slot Details ​


calculate ​

protected abstract Bool calculate(Bool? a, Bool? b, Bool? c, Bool? d)


inA ​

virtual StatusBool? inA

Input A


inB ​

virtual StatusBool? inB

Input B


inC ​

virtual StatusBool? inC

Input C


inD ​

virtual StatusBool? inD

Input D


minInputs ​

protected abstract Int minInputs()


onExecute ​

override Void onExecute()


QuadMath ​

abstract class QuadMath : Math

The base spec for all math components that operate on up to four inputs

Fields

inAInput A
inBInput B
inCInput C
inDInput D

Methods

calculate
minInputs
onExecute

Slot Details ​


calculate ​

protected abstract Number calculate(StatusNumber? a, StatusNumber? b, StatusNumber? c, StatusNumber? d)


inA ​

virtual StatusNumber? inA

Input A


inB ​

virtual StatusNumber? inB

Input B


inC ​

virtual StatusNumber? inC

Input C


inD ​

virtual StatusNumber? inD

Input D


minInputs ​

protected abstract Int minInputs()


onExecute ​

override Void onExecute()


RefVar ​

class RefVar : Var

Methods

ref

Slot Details ​


ref ​

Ref? ref()


Sine ​

class Sine : UnaryMath

Computes the sine of its input: out = sin(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


SineWave ​

class SineWave : HxComp

The output of this component generates a sine wave.

Fields

amplitudeThe height of the sine wave from its lowest to highest point.
offsetThe distance from zero that the sine wave's amplitude is shifted
periodThe amount of time it takes to output one complete cycle.
updateIntervalHow frequently to compute the sine wave

Methods

onChangeThis
onExecute
onExecuteFreq
onMount
outThe computed sine wave

Slot Details ​


amplitude ​

virtual Float amplitude

The height of the sine wave from its lowest to highest point.


offset ​

virtual Float offset

The distance from zero that the sine wave's amplitude is shifted


onChangeThis ​

virtual override Void onChangeThis(Str slot, Obj? newVal)


onExecute ​

virtual override Void onExecute()


onExecuteFreq ​

virtual override Duration? onExecuteFreq()


onMount ​

virtual override Void onMount()


out ​

virtual StatusNumber out()

The computed sine wave


period ​

virtual Duration period

The amount of time it takes to output one complete cycle.


updateInterval ​

virtual Duration updateInterval

How frequently to compute the sine wave


SquareRoot ​

class SquareRoot : UnaryMath

Computes the square root of its input: out = sqrt(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


Status ​

const mixin Status : Dict

Status flags

Methods

alarmInstance with alarm flag set
clearClear this instance flags with the given instances flags
disabledInstance with disabled flag set
downInstance with down flag set
faultInstance with fault flag set
fromCurStatusMap curStatus tags to status flags
fromNameGet an instance by name
fromStrParse a comma-separated list of status flags
isAlarmIn an alarm state
isDisabledDisabled state
isDownNetwork or communication error state
isFaultConfiguration or hardware error state
isOkIn the ok state with no other flags set
isOverriddenManual override state
isStaleData is not fresh
isUnackedAlarm has not been acknowledged
isValidReturn true if none of the following status flags are set
mergeMerge flags together for combination operations.
okGet the ok status with no flags set
onlyGet a new status where only the given flags are set
overriddenInstance with overridden flag set
setMerge all this instance flags with the given instances flags.
staleInstance with stale flag set
unackedInstance with flag set

Slot Details ​


alarm ​

static Status alarm()

Instance with alarm flag set


clear ​

Status clear(Status that)

Clear this instance flags with the given instances flags


disabled ​

static Status disabled()

Instance with disabled flag set


down ​

static Status down()

Instance with down flag set


fault ​

static Status fault()

Instance with fault flag set


fromCurStatus ​

static Status fromCurStatus(Str? curStatus)

Map curStatus tags to status flags


fromName ​

static Status? fromName(Str name, Bool checked := true)

Get an instance by name


fromStr ​

static Status fromStr(Str flags)

Parse a comma-separated list of status flags


isAlarm ​

abstract Bool isAlarm()

In an alarm state


isDisabled ​

abstract Bool isDisabled()

Disabled state


isDown ​

abstract Bool isDown()

Network or communication error state


isFault ​

abstract Bool isFault()

Configuration or hardware error state


isOk ​

abstract Bool isOk()

In the ok state with no other flags set


isOverridden ​

abstract Bool isOverridden()

Manual override state


isStale ​

abstract Bool isStale()

Data is not fresh


isUnacked ​

abstract Bool isUnacked()

Alarm has not been acknowledged


isValid ​

abstract Bool isValid()

Return true if none of the following status flags are set:

disabled,down,fault,stale

merge ​

Status merge(Status? that)

Merge flags together for combination operations. If that is null, return this


ok ​

static Status ok()

Get the ok status with no flags set


only ​

Status only(Status that)

Get a new status where only the given flags are set


overridden ​

static Status overridden()

Instance with overridden flag set


set ​

Status set(Status that)

Merge all this instance flags with the given instances flags.


stale ​

static Status stale()

Instance with stale flag set


unacked ​

static Status unacked()

Instance with flag set


StatusBool ​

const mixin StatusBool : StatusVal

Status and boolean value

Constructors

makeConstructor

Methods

boolGet the scalar value

Slot Details ​


bool ​

abstract Bool bool()

Get the scalar value


make ​

static new make(Bool val := false, Status status := Status.ok())

Constructor


StatusNumber ​

const mixin StatusNumber : StatusVal

Status and number value

Constructors

makeConstructor

Methods

numGet the scalar number value

Slot Details ​


make ​

static new make(Number val := Number.zero, Status status := Status.ok())

Constructor


num ​

abstract Number num()

Get the scalar number value


StatusStr ​

const mixin StatusStr : StatusVal

Status and string value

Constructors

makeConstructor

Methods

strGet the scalar value

Slot Details ​


make ​

static new make(Str val := "", Status status := Status.ok())

Constructor


str ​

abstract Str str()

Get the scalar value


StatusVal ​

const mixin StatusVal : Dict

Status and scalar value

Methods

invalidToNullIf the status is invalid return null; otherwise return this
statusGet the status flags
toStr<val>
valGet the scalar value

Slot Details ​


invalidToNull ​

StatusVal? invalidToNull()

If the status is invalid return null; otherwise return this


status ​

abstract Status status()

Get the status flags


toStr ​

virtual override Str toStr()

<val>


val ​

abstract Obj val()

Get the scalar value


StrConst ​

class StrConst : HxComp

Str constant

Fields

out

Slot Details ​


out ​

virtual StatusStr? out


StrPointInput ​

class StrPointInput : PointInput

Methods

curVal

Slot Details ​


curVal ​

virtual override StatusStr? curVal()


StrPointOutput ​

class StrPointOutput : PointOutput

Methods

statusStr

Slot Details ​


statusStr ​

StatusStr? statusStr()


StrVar ​

class StrVar : Var

Methods

str

Slot Details ​


str ​

Str? str()


Subtract ​

class Subtract : BinaryMath

Computes the difference of its inputs (A - B)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a, Number b)


Tangent ​

class Tangent : UnaryMath

Computes the cosine of its input: out = tan(inA)

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Number calculate(Number a)


TimeVar ​

class TimeVar : Var

Methods

time

Slot Details ​


time ​

Time? time()


UnaryMath ​

abstract class UnaryMath : Math

The base spec for all math components that operate on one input

Fields

inAInput A

Methods

calculate
onExecute

Slot Details ​


calculate ​

protected abstract Number calculate(Number a)


inA ​

virtual StatusNumber? inA

Input A


onExecute ​

virtual override Void onExecute()


Var ​

class Var : HxComp

Fields

val

Methods

bindIn

Slot Details ​


bindIn ​

virtual override Void bindIn(Obj? val)


val ​

virtual Obj? val


Xor ​

class Xor : QuadLogic

Computes the exclusive-or of its inputs

Fields

minInputs

Methods

calculate

Slot Details ​


calculate ​

protected virtual override Bool calculate(Bool? a, Bool? b, Bool? c, Bool? d)


minInputs ​

protected virtual const override Int minInputs := 2