@joergmittaglawo/dmvconfig
Version:
DMV Configuration scripts for Lawo V__matrix Distributed Multiviewers.
1 lines • 3.56 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0}),exports.StronglyTypedArray=exports.StronglyTypedNamedTable=exports.StronglyTypedTable=exports.lowerArray=exports.liftArray=exports.duplexKeyword=exports.rwKeyword=exports.wKeyword=exports.rKeyword=exports.same=void 0;const t=require("assert"),r=require("./time");exports.same=function(t,r){return null!==t&&null!==r?t.raw.kwl===r.raw.kwl&&t.raw.socket.ip===r.raw.socket.ip:null===t==(null===r)};class e{constructor(t,r,e){this.parent=t,this.m_kw=r,this.m_type_converters=e}async read(t){const r=await this.parent.raw.read({kw:this.m_kw},t);return this.m_type_converters?this.m_type_converters.lift(r,this.parent.raw.socket):r}async wait_until(t,r){const e=this.m_type_converters?r=>t(this.m_type_converters.lift(r,this.parent.raw.socket)):t,s=await this.parent.raw.wait_until({kw:this.m_kw},e,r);return this.m_type_converters?this.m_type_converters.lift(s,this.parent.raw.socket):s}async update(t){const r=await this.parent.raw.update({kw:this.m_kw},t);return this.m_type_converters?this.m_type_converters.lift(r,this.parent.raw.socket):r}async watch(t,r){const e=this.m_type_converters?r=>t(this.m_type_converters.lift(r,this.parent.raw.socket)):t;return await this.parent.raw.watch({kw:this.m_kw},e,r)}}async function s(e,s,i,a,n){var o;let c=a&&"status"===(null===(o=null==n?void 0:n.retry_until)||void 0===o?void 0:o.criterion)?t=>n.retry_until.validator(a.lift(t,i.raw.socket)):void 0;void 0===c&&(s instanceof r.Timestamp||s instanceof r.Duration)&&(t.strict(a),c=t=>null===t&&null===s||s.equal(a.lift(t,i.raw.socket))),await i.raw.write({kw:e},a?a.lower(s,i.raw.socket):s,{...n,...c?{retry_until:{criterion:"status",validator:c}}:{}})}exports.rKeyword=e;exports.wKeyword=class{constructor(t,r,e){this.parent=t,this.m_kw=r,this.m_type_converters=e}async write(t,r){return s(this.m_kw,t,this.parent,this.m_type_converters,r)}};class i extends e{constructor(t,r,e){super(t,r,e)}async write(t,r){return s(this.m_kw,t,this.parent,this.m_type_converters,r)}}exports.rwKeyword=i;exports.duplexKeyword=class{constructor(t,r,s){this.parent=t,this.status=new e(t,r+"_status",s),this.command=new i(t,r+"_command",s)}},exports.liftArray=function(t){return(r,e)=>r.map(r=>t(r,e))},exports.lowerArray=function(t){return r=>r.map(t)};exports.StronglyTypedTable=class{constructor(t,r){this.raw=t,this.m_lift=r}async rows(t){return(await this.raw.rows(t)).map(t=>this.m_lift(t,this))}async allocated_indices(t){return this.raw.allocated_indices(t)}async is_allocated(t,r){return this.raw.is_allocated(t,r)}row(t,r){return this.m_lift(this.raw.row(t,r),this)}row_unchecked(t){return this.m_lift(this.raw.row_unchecked(t),this)}};exports.StronglyTypedNamedTable=class{constructor(t,r){this.raw=t,this.m_lift=r}async allocated_indices(t){return this.raw.allocated_indices(t)}async is_allocated(t,r){return this.raw.is_allocated(t,r)}async create_row(t){return this.m_lift(await this.raw.create_row(t),this)}async rows(t){return(await this.raw.rows(t)).map(t=>this.m_lift(t,this))}row(t,r){return this.m_lift(this.raw.row(t,r),this)}row_unchecked(t){return this.m_lift(this.raw.row_unchecked(t),this)}};class a{constructor(t,r,e){this.parent=t,this.basename=r,this.m_lift=e}row(t){return this.m_lift(this.parent.raw.find(`${this.basename}[${t}]`),t,this.parent)}get size(){const r=this.parent.raw.find(this.basename).description;t.strict(!Array.isArray(r));return r.local_multiplicity}[Symbol.iterator](){const t=this.size,r=this;return function*(){for(let e=0;e<t;++e)yield r.row(e)}()}}exports.StronglyTypedArray=a;