Package jmri.jmrix.loconet.sdf
Class SdfMacro
- java.lang.Object
-
- jmri.jmrix.loconet.sdf.SdfMacro
-
- All Implemented Interfaces:
SdfConstants
- Direct Known Subclasses:
BranchTo
,ChannelStart
,CommentMacro
,DelaySound
,EndSound
,FourByteMacro
,GenerateTrigger
,InitiateSound
,LabelMacro
,LoadModifier
,MaskCompare
,Play
,SdlVersion
,SkemeStart
,SkipOnTrigger
,TwoByteMacro
public abstract class SdfMacro extends java.lang.Object implements SdfConstants
Common base for all the SDF macros defined by Digitrax for their sound definition language.Each macro has a number of descriptive forms:
- name()
- Just the name, in MPASM form.
- toString()
- A brief description, with a terminating newline
- oneInstructionString()
- The entire single instruction in MPASM from, with a terminating newline
- allInstructionString()
- The instruction and all those logically grouped within it.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.ArrayList<SdfMacro>
children
Local member hold list of child (contained) instructions-
Fields inherited from interface jmri.jmrix.loconet.sdf.SdfConstants
ABOVE, ABOVE_BIT, ANALOG_GAIN_MODIFY, ANALOG_PITCH_MODIFY, arg1ModCodes, arg1ModNames, arg3ModCodes, arg3ModMasks, arg3ModNames, BLEND_ALL, BLEND_CURRENT_CHNL, BLEND_FASE0, BLEND_FASE1, BLEND_FASEMASK, BLEND_GAIN0, BLEND_GAIN1, BLEND_GAINMASK, BLEND_TGTMASK, blendArg1Codes, blendArg1Masks, blendArg1Names, blendArg2Codes, blendArg2Names, blendArg3Codes, blendArg3Names, BLENDF_DSL_ACCEL0, BLENDF_DSL_ACCEL1, BLENDF_DSL_DECEL0, BLENDG_DSL_ACCEL0, BLENDG_DSL_ACCEL1, BLENDG_DSL_DECEL0, CMD_ZAP_BIT, COMP_7LSB, COMP_ALL, CV_PITCH_MODIFY, DEFAULT_GLBL_GAIN, DELAY_CV, DELAY_GLOBAL, DELAY_THIS, DITHER, DITHER_BIT, DITHERG_DIESEL, DITHERG_NONE, DITHERG_WHISTLE, ditherGCodes, ditherGNames, DITHERP_DIESEL, DITHERP_NONE, DITHERP_WHISTLE, ditherPCodes, ditherPNames, editorTriggerNames, FALSE, FCMD_MASK, FCMD_NONE, fixedCVCodes, fixedCVNames, FMATH_AND, FMATH_INTEGRATE, FMATH_LODE, FMATH_OR, FMATH_TEST_ZERO, FMATH_XOR, GCMD_MASK, GCMD_NONE, IMMED_DATA, IMMED_GAIN_MODIFY, loop_GLOBAL, loop_GLOBAL_BIT, loop_INVERT, loop_INVERT_BIT, loop_MASK, loop_STD, loop_till_cam, loop_till_DIRNOW_CHNG, loop_till_F0, loop_till_F1, loop_till_F10, loop_till_F11, loop_till_F12, loop_till_F2, loop_till_F3, loop_till_F4, loop_till_F5, loop_till_F6, loop_till_F7, loop_till_F8, loop_till_F9, loop_till_init_TRIG, loop_till_MOVING, loop_till_NEVER, loop_till_SCAT4, loop_till_SCAT5, loop_till_SCAT6, loop_till_SCAT7, loop_till_SND_ACTV11, loopCodes, loopMasks, loopNames, LOW_DITH, MAX_DITH, MAXG_DIESEL, MAXG_NONE, MAXG_STEAM, MAXG_WHISTLE, maxGCodes, maxGNames, MAXP_DIESEL, MAXP_NONE, MAXP_STEAM, MAXP_WHISTLE, maxPCodes, maxPNames, MERGE_ALL_MASK, MG0_BIT, MG1_BIT, MID_DITH, MIN_DITH, modControlCodes, modControlNames, MOVE_BIT, MTYPE_BLEND, MTYPE_GAIN, MTYPE_PITCH, MTYPE_SCATTER, MTYPE_SNDCV, MTYPE_TIME, MTYPE_WORK_IMMED, MTYPE_WORK_INDIRECT, MVFN_MASK, no_loop, NO_PREEMPT_TRIG, NO_PREEMPT_TRIG_BIT, NORMAL, NOT_TRIG, NOT_TRIG_BIT, premptCodes, premptMasks, premptNames, RUN_WHILE_TRIG, RUN_WHILE_TRIG_BIT, SCALE_2, SCALE_4, SCALE_5, SCALE_6, SCALE_8, SCALE_C, SCALE_F, SCAT_CHNL0, SCAT_CHNL1, SCAT_CHNL2, SCAT_CHNL3, SCAT_CHNL4, SCAT_CHNL5, SCAT_CHNL6, SCAT_CHNL7, SCAT_CMD_PERIOD, SCAT_CMD_PERIOD_REV, SCAT_CMD_SAWTOOTH, SCAT_CMD_SAWTOOTH_REV, SCAT_PERIOD_POLARITY_BIT, SCAT_TRIG_BASE, scatChannelCodes, scatChannelNames, scatCommandCodes, scatCommandNames, SCV_137, SCV_138, SCV_DCONFIG, SCV_DISTANCE_RATE, SCV_FREEFORM, SCV_MAIN_PITCH, SCV_MUTE_VOL, SCV_NOTCH, SCV_STGEAR, SINTEN_HIGH, SINTEN_IMMED, SINTEN_LOW, SINTEN_MID, SINTEN_MIN, SINTEN_OFF, sintenCodes, sintenNames, SK_SENS_BIT, SKATTER_INCREMENT, SKIP_GRTR, SKIP_LESS, SKIP_RSVD, SKIP_SAME, SNDCV_CONFIGA, SNDCV_CONFIGB, SNDCV_SRC, SNDCV_SRC_BIT, SNDCV_STEAM, STEAM_CAM_BIT, SUM_BIT, SUMG, T_SPD_ACC_CHNG, T_SPD_ACCEL1, T_SPD_ACCEL2, T_SPD_DEC_CHNG, T_SPD_DEC_IDLE, T_SPD_DEC_SP1, T_SPD_DEC_SP2, T_SPD_DECEL1, T_SPD_DECEL2, T_SPD_DIR_CHNG, T_SPD_IDLE, T_SPD_IDLEXIT, T_SPD_MUTE, T_SPD_RUN, T_SPD_TURNOFF, T_SPD_TURNON, T_SS_BASE, TARGET_DATA, TRIG_BSC0, TRIG_BSC1, TRIG_BSC2, TRIG_BSC3, TRIG_BSC4, TRIG_BSC5, TRIG_BSC6, TRIG_BSC7, TRIG_CAM, TRIG_DIRNOW_CHNG, TRIG_DISTANCE, TRIG_FACTORY_CVRESET, TRIG_FALSE, TRIG_IN_0, TRIG_IN_1, TRIG_IN_2, TRIG_IN_3, TRIG_IN_4, TRIG_IN_5, TRIG_IN_6, TRIG_IN_7, TRIG_IN_BASE, TRIG_MATH, TRIG_MODE_CHNG, TRIG_MOVING, TRIG_NEVER, TRIG_NOT_TRIG, TRIG_NOTCH_CHNG, TRIG_OPSPROGWR_CV, TRIG_SCAT0, TRIG_SCAT1, TRIG_SCAT2, TRIG_SCAT3, TRIG_SCAT4, TRIG_SCAT5, TRIG_SCAT6, TRIG_SCAT7, TRIG_SF0, TRIG_SF1, TRIG_SF10, TRIG_SF11, TRIG_SF12, TRIG_SF13, TRIG_SF14, TRIG_SF15, TRIG_SF16, TRIG_SF17, TRIG_SF18, TRIG_SF19, TRIG_SF2, TRIG_SF20, TRIG_SF21, TRIG_SF22, TRIG_SF23, TRIG_SF24, TRIG_SF25, TRIG_SF26, TRIG_SF27, TRIG_SF28, TRIG_SF3, TRIG_SF4, TRIG_SF5, TRIG_SF6, TRIG_SF7, TRIG_SF8, TRIG_SF9, TRIG_SND_ACTV11, TRIG_SPD_DEC, TRIG_SPD_INC, TRIG_TIME_16PPS, TRIG_TRUE, triggerCodes, triggerNames, trigLogicCodes, trigLogicMasks, trigLogicNames, TRUE, trueFalseCodes, trueFalseNames, TSPD, wavebrkCodes, wavebrkMasks, wavebrkNames, WKSB_ACEL_BIT, WKSB_ACEL_MASK, WKSB_ANALOG_BIT, WKSB_ANALOG_MASK, WKSB_DIRNOW_BIT, WKSB_DIRNOW_MASK, WKSB_MATH_BIT, WKSB_MATH_MASK, WKSB_RUN_BIT, WKSB_RUN_MASK, WKSB_SPDDELTA_BIT, WKSB_SPDDELTA_MASK, WORK_ACHNL_7E, WORK_ACHNL_7F, WORK_DISTANCE, WORK_GAIN_TRIM, WORK_GLBL_GAIN, WORK_MVOLTS, WORK_NOTCH, WORK_PEAK_SPD, WORK_PITCH_TRIM, WORK_SCATTER4, WORK_SCATTER5, WORK_SCATTER6, WORK_SCATTER7, WORK_SERVO, WORK_SKAT_FAST, WORK_SKAT_SLOW, WORK_SPEED, WORK_SPEED_DELTA, WORK_STATUS_BITS, WORK_TIMEBASE, WORK_USER_0, WORK_USER_1, WORK_USER_2, WORK_USER_3, WORK_USER_4, WORK_USER_5, WORK_USER_LINES, workRegCodes, workRegNames, workStatusBitCodes, workStatusBitNames, ZAP
-
-
Constructor Summary
Constructors Constructor Description SdfMacro()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.String
allInstructionString(java.lang.String indent)
Provide instructions in MPASM format, including the trailing newline and all nested instructions.(package private) java.lang.String
decodeFlags(int input, int[] values, int[] masks, java.lang.String[] labels)
Service method to unpack various bit-coded values for display, using a mask array.static SdfMacro
decodeInstruction(SdfBuffer buff)
Get the next instruction macro in a buffer.(package private) java.lang.String
decodeState(int input, int[] values, java.lang.String[] labels)
java.util.List<SdfMacro>
getChildren()
Access child (nested) instructions.abstract int
length()
Provide number of bytes defined by this macrovoid
loadByteArray(SdfBuffer buffer)
Store into a buffer.abstract java.lang.String
name()
Name used by the macro in the SDF definitionabstract java.lang.String
oneInstructionString()
Provide single instruction in MPASM format, including the trailing newline.abstract java.lang.String
toString()
Provide a single-line simplified representation, including the trailing newline.int
totalLength()
Total length, including contained instructions
-
-
-
Constructor Detail
-
SdfMacro
public SdfMacro()
-
-
Method Detail
-
name
public abstract java.lang.String name()
Name used by the macro in the SDF definition- Returns:
- Fixed name associated with this type of instructio
-
length
public abstract int length()
Provide number of bytes defined by this macro- Returns:
- Fixed numher of bytes defined (a constant for the instruction type)
-
toString
public abstract java.lang.String toString()
Provide a single-line simplified representation, including the trailing newline. This is used e.g. in the tree format section of theEditorFrame
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- newline-terminated string; never null
-
oneInstructionString
public abstract java.lang.String oneInstructionString()
Provide single instruction in MPASM format, including the trailing newline.- Returns:
- Newline terminated string, never null
-
allInstructionString
public abstract java.lang.String allInstructionString(java.lang.String indent)
Provide instructions in MPASM format, including the trailing newline and all nested instructions.- Parameters:
indent
- String inserted at the start of each output line, typically some number of spaces.- Returns:
- Newline terminated string, never null
-
getChildren
public java.util.List<SdfMacro> getChildren()
Access child (nested) instructions.- Returns:
- List of children, which will be null except in case of nesting.
-
totalLength
public int totalLength()
Total length, including contained instructions- Returns:
- length of all parts
-
loadByteArray
public void loadByteArray(SdfBuffer buffer)
Store into a buffer.This provides a default implementation for children, but each subclass needs to store its own data with setAtIndexAndInc().
- Parameters:
buffer
- load with all children
-
decodeInstruction
public static SdfMacro decodeInstruction(SdfBuffer buff)
Get the next instruction macro in a buffer.Note this uses the index contained in the SdfBuffer implementation, and has the side-effect of bumping that forward.
- Parameters:
buff
- The SdfBuffer being scanned for instruction macros.- Returns:
- Object of SdfMacro subtype for specific next instruction
-
decodeFlags
java.lang.String decodeFlags(int input, int[] values, int[] masks, java.lang.String[] labels)
Service method to unpack various bit-coded values for display, using a mask array.Note that multiple values can be returned, e.g. this can be used to scan for individual bits set in a variable.
- Parameters:
input
- Single value to be matchedvalues
- Array of possible values which the input might matchmasks
- Array of masks to be applied when comparing against the corresponding items in the values array. This is separate for each possible value to e.g. allow the encoding of a set of independent bits.labels
- Should there be a match-under-mask of a value, the corresponding label is returned- Returns:
- "+" separated list of labels, or "<ERROR>" if none matched
-
decodeState
java.lang.String decodeState(int input, int[] values, java.lang.String[] labels)
-
-