@wildboar/copp
Version:
Connection-oriented presentation protocol (COPP) data structures and business logic in TypeScript
211 lines (210 loc) • 8.65 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from '@wildboar/asn1';
import * as $ from '@wildboar/asn1/functional';
import { monologue /* IMPORTED_SHORT_NAMED_INTEGER */, _decode_RTORQapdu_dialogueMode, _encode_RTORQapdu_dialogueMode, _decode_ConnectionData, _encode_ConnectionData, } from '@wildboar/rtse';
/**
* @summary CP_type_x410_mode_parameters
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* CP-type-x410-mode-parameters ::= SEQUENCE { -- REMOVED_FROM_UNNESTING -- }
* ```
*
*/
export class CP_type_x410_mode_parameters {
checkpointSize;
windowSize;
dialogueMode;
connectionDataRQ;
applicationProtocol;
constructor(
/**
* @summary `checkpointSize`.
* @public
* @readonly
*/
checkpointSize /* REPLICATED_COMPONENT */,
/**
* @summary `windowSize`.
* @public
* @readonly
*/
windowSize /* REPLICATED_COMPONENT */,
/**
* @summary `dialogueMode`.
* @public
* @readonly
*/
dialogueMode /* REPLICATED_COMPONENT */,
/**
* @summary `connectionDataRQ`.
* @public
* @readonly
*/
connectionDataRQ /* REPLICATED_COMPONENT */,
/**
* @summary `applicationProtocol`.
* @public
* @readonly
*/
applicationProtocol /* REPLICATED_COMPONENT */) {
this.checkpointSize = checkpointSize;
this.windowSize = windowSize;
this.dialogueMode = dialogueMode;
this.connectionDataRQ = connectionDataRQ;
this.applicationProtocol = applicationProtocol;
}
/**
* @summary Restructures an object into a CP_type_x410_mode_parameters
* @description
*
* This takes an `object` and converts it to a `CP_type_x410_mode_parameters`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `CP_type_x410_mode_parameters`.
* @returns {CP_type_x410_mode_parameters}
*/
static _from_object(_o) {
return new CP_type_x410_mode_parameters(_o.checkpointSize, _o.windowSize, _o.dialogueMode, _o.connectionDataRQ, _o.applicationProtocol);
}
/**
* @summary Getter that returns the default value for `checkpointSize`.
* @public
* @static
* @method
*/
static get _default_value_for_checkpointSize() {
return 0;
}
/**
* @summary Getter that returns the default value for `windowSize`.
* @public
* @static
* @method
*/
static get _default_value_for_windowSize() {
return 3;
}
/**
* @summary Getter that returns the default value for `dialogueMode`.
* @public
* @static
* @method
*/
static get _default_value_for_dialogueMode() {
return monologue;
}
}
/**
* @summary The Leading Root Component Types of CP_type_x410_mode_parameters
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_1_spec_for_CP_type_x410_mode_parameters = [
new $.ComponentSpec('checkpointSize', true, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec('windowSize', true, $.hasTag(_TagClass.context, 1)),
new $.ComponentSpec('dialogueMode', true, $.hasTag(_TagClass.context, 2)),
new $.ComponentSpec('connectionDataRQ', false, $.hasTag(_TagClass.context, 3)),
new $.ComponentSpec('applicationProtocol', true, $.hasTag(_TagClass.context, 4)),
];
/**
* @summary The Trailing Root Component Types of CP_type_x410_mode_parameters
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_2_spec_for_CP_type_x410_mode_parameters = [];
/**
* @summary The Extension Addition Component Types of CP_type_x410_mode_parameters
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _extension_additions_list_spec_for_CP_type_x410_mode_parameters = [];
let _cached_decoder_for_CP_type_x410_mode_parameters = null;
/**
* @summary Decodes an ASN.1 element into a(n) CP_type_x410_mode_parameters
* @function
* @param {_Element} el The element being decoded.
* @returns {CP_type_x410_mode_parameters} The decoded data structure.
*/
export function _decode_CP_type_x410_mode_parameters(el) {
if (!_cached_decoder_for_CP_type_x410_mode_parameters) {
_cached_decoder_for_CP_type_x410_mode_parameters = function (el) {
/* START_OF_SET_COMPONENT_DECLARATIONS */
let checkpointSize = CP_type_x410_mode_parameters._default_value_for_checkpointSize;
let windowSize = CP_type_x410_mode_parameters._default_value_for_windowSize;
let dialogueMode = CP_type_x410_mode_parameters._default_value_for_dialogueMode;
let connectionDataRQ;
let applicationProtocol;
/* END_OF_SET_COMPONENT_DECLARATIONS */
const callbacks = {
checkpointSize: (_el) => {
checkpointSize = $._decode_implicit(() => $._decodeInteger)(_el);
},
windowSize: (_el) => {
windowSize = $._decode_implicit(() => $._decodeInteger)(_el);
},
dialogueMode: (_el) => {
dialogueMode = $._decode_implicit(() => _decode_RTORQapdu_dialogueMode)(_el);
},
connectionDataRQ: (_el) => {
connectionDataRQ = $._decode_explicit(() => _decode_ConnectionData)(_el);
},
applicationProtocol: (_el) => {
applicationProtocol = $._decode_implicit(() => $._decodeInteger)(_el);
},
};
$._parse_set(el, callbacks, _root_component_type_list_1_spec_for_CP_type_x410_mode_parameters, _extension_additions_list_spec_for_CP_type_x410_mode_parameters, _root_component_type_list_2_spec_for_CP_type_x410_mode_parameters, undefined);
return new CP_type_x410_mode_parameters /* SET_CONSTRUCTOR_CALL */(checkpointSize, windowSize, dialogueMode, connectionDataRQ, applicationProtocol);
};
}
return _cached_decoder_for_CP_type_x410_mode_parameters(el);
}
let _cached_encoder_for_CP_type_x410_mode_parameters = null;
/**
* @summary Encodes a(n) CP_type_x410_mode_parameters into an ASN.1 Element.
* @function
* @param value The element being encoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The CP_type_x410_mode_parameters, encoded as an ASN.1 Element.
*/
export function _encode_CP_type_x410_mode_parameters(value, elGetter) {
if (!_cached_encoder_for_CP_type_x410_mode_parameters) {
_cached_encoder_for_CP_type_x410_mode_parameters = function (value) {
return $._encodeSet([]
.concat([
/* IF_DEFAULT */ value.checkpointSize === undefined ||
$.deepEq(value.checkpointSize, CP_type_x410_mode_parameters._default_value_for_checkpointSize)
? undefined
: $._encode_implicit(_TagClass.context, 0, () => $._encodeInteger, $.BER)(value.checkpointSize, $.BER),
/* IF_DEFAULT */ value.windowSize === undefined ||
$.deepEq(value.windowSize, CP_type_x410_mode_parameters._default_value_for_windowSize)
? undefined
: $._encode_implicit(_TagClass.context, 1, () => $._encodeInteger, $.BER)(value.windowSize, $.BER),
/* IF_DEFAULT */ value.dialogueMode === undefined ||
$.deepEq(value.dialogueMode, CP_type_x410_mode_parameters._default_value_for_dialogueMode)
? undefined
: $._encode_implicit(_TagClass.context, 2, () => _encode_RTORQapdu_dialogueMode, $.BER)(value.dialogueMode, $.BER),
/* REQUIRED */ $._encode_explicit(_TagClass.context, 3, () => _encode_ConnectionData, $.BER)(value.connectionDataRQ, $.BER),
/* IF_ABSENT */ value.applicationProtocol === undefined
? undefined
: $._encode_implicit(_TagClass.context, 4, () => $._encodeInteger, $.BER)(value.applicationProtocol, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CP_type_x410_mode_parameters(value, elGetter);
}
/* eslint-enable */