lavva.exalushome.extalife
Version:
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
2 lines • 13.2 kB
JavaScript
"use strict";(self.webpackChunklavva_exalushome_extalife=self.webpackChunklavva_exalushome_extalife||[]).push([[815],{6532:(e,t,n)=>{n.d(t,{W:()=>i,_:()=>r});class r{constructor(e){this.DeviceGuid="",this.DeviceGuid=e}}class i{constructor(e,t){this.DeviceGuid="",this.Channel=0,this.DeviceGuid=e,this.Channel=t}}},6815:(e,t,n)=>{n.r(t),n.d(t,{Rob21ConfigService:()=>w});var r,i,o,s=n(5046),a=n(6440),l=n(6895),u=n(624),c=n(4533),d=n(5564),h=n(8308),m=n(6532);!function(e){e[e.Gate=1]="Gate",e[e.Gateway=2]="Gateway",e[e.Monostable=3]="Monostable"}(r||(r={})),function(e){e[e.LimitSwitchDisabled=0]="LimitSwitchDisabled",e[e.LimitSwitchClosed=1]="LimitSwitchClosed",e[e.LimitSwitchOpened=2]="LimitSwitchOpened"}(i||(i={})),function(e){e[e.NormallyOpened=1]="NormallyOpened",e[e.NormallyClosed=2]="NormallyClosed"}(o||(o={}));class g{constructor(){this.Channel=0,this.Input=0,this.Function=i.LimitSwitchDisabled,this.Type=o.NormallyClosed}}var v=n(2889),p=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class w{constructor(){this._connection=s.V.Get(l.c.ServiceName),this._logger=s.V.Get(d.m.ServiceName),this._controllerConfigurationService=s.V.Get(c.Q.ServiceName)}GetServiceName(){return w.ServiceName}GetGateModeAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new u.tp(h.v.InvalidChannelNumber,`Cannot get gate working mode - invalid channel number, channel: ${t}`);const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new y(new m.W(e.Guid,t)),8e3,!1);return null==r||null==r.Status?new u.tp(h.v.OtherError,"Cannot get gate working mode - unknown error."):r.Status!==a.qb.OK?new u.tp(h.v.OtherError,`Cannot get gate working mode - controller responded with error code: ${r.Status}.`):null==r.Data?new u.tp(h.v.NoData,"Cannot get gate working mode - no data in response."):r.Data.TypeOfGateChannel}catch(e){return new u.tp(h.v.OtherError,"Cannot get gate working mode - unknown error.")}}))}SetGateModeAsync(e,t,n){var r;return p(this,void 0,void 0,(function*(){try{const i=new S;i.DeviceGuid=e.Guid,i.Channel=t,i.TypeOfGateChannel=n,yield this._controllerConfigurationService.EnterConfigurationModeAsync();const o=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new f(i),8e3,!1);return null==o||null==o.Status?(this._logger.Error(w.ServiceName,"Failed to set working mode parameter - unknown error."),a.qb.FatalError):(o.Status!==a.qb.OK&&this._logger.Error(w.ServiceName,`Failed to set working mode parameter, response status: ${o.Status}`),o.Status)}catch(e){return this._logger.Error(w.ServiceName,"Failed to set working mode parameter - unknown error."),a.qb.FatalError}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync(),s.V.Get(v.Ih.ServiceName).GetDevicesAsync()}}))}GetPulseTimeAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new u.tp(h.v.InvalidChannelNumber,`Cannot get pulse time - invalid channel number, channel: ${t}`);const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new C(new m.W(e.Guid,t)),8e3,!1);return null==r||null==r.Status?new u.tp(h.v.OtherError,"Cannot get pulse time - unknown error."):r.Status!==a.qb.OK?new u.tp(h.v.OtherError,`Cannot get pulse time - controller responded with error code: ${r.Status}.`):null==r.Data?new u.tp(h.v.NoData,"Cannot get pulse time - no data in response."):r.Data.PulseTime/10}catch(e){return new u.tp(h.v.OtherError,"Cannot get pulse time - unknown error.")}}))}SetPulseTimeAsync(e,t,n){var i;return p(this,void 0,void 0,(function*(){try{if(n<.1||n>300||n*Math.pow(10,1)%1!=0)return this._logger.Error(w.ServiceName,"Failed to set pulse time - value is out of range!"),a.qb.WrongData;const o=yield this.GetGateModeAsync(e,t);if(null!=o.Type)return this._logger.Error(w.ServiceName,"Failed to set pulse time - cannot get current mode of gate controller."),a.qb.Error;if(o==r.Monostable)return this._logger.Error(w.ServiceName,"Failed to set pulse time - cannot set pulse time when channel mode is 'monostable'."),a.qb.OperationNotPermitted;const s=new S;s.DeviceGuid=e.Guid,s.Channel=t,s.PulseTime=10*n,yield this._controllerConfigurationService.EnterConfigurationModeAsync();const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new b(s),8e3,!1);return null==l||null==l.Status?(this._logger.Error(w.ServiceName,"Failed to set pulse time - unknown error."),a.qb.FatalError):(l.Status!==a.qb.OK&&this._logger.Error(w.ServiceName,`Failed to set pulse time, response status: ${l.Status}`),l.Status)}catch(e){return this._logger.Error(w.ServiceName,"Failed to set pulse time - unknown error."),a.qb.FatalError}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}GetLimitingSwitchesConfigurationsAsync(e,t){var n,r;return p(this,void 0,void 0,(function*(){try{const t=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new N(new E(e.Guid,1)),8e3,!1),i=yield null===(r=this._connection)||void 0===r?void 0:r.SendAndWaitForResponseAsync(new N(new E(e.Guid,2)),8e3,!1);if(null==t||null==t.Status||null==t.Data||null==i||null==i.Status||null==i.Data)return new u.tp(h.v.OtherError,"Cannot get limiting switch configuration - unknown error.");if(t.Status!==a.qb.OK||i.Status!==a.qb.OK)return new u.tp(h.v.OtherError,`Cannot get limiting switch configuration - controller responded with error code: ${t.Status!=a.qb.OK?t.Status:i.Status}.`);const o=[];return o.push(t.Data),o.push(i.Data),o.map((e=>{const t=new g;return t.Channel=e.Channel,t.Function=e.Function,t.Input=e.Input,t.Type=e.Type,t}))}catch(e){return new u.tp(h.v.OtherError,"Cannot get limiting switch configuration - unknown error.")}}))}SetLimitingSwitchConfigurationAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{const i=yield this.GetGateModeAsync(e,t.Channel);if(null!=i.Type)return this._logger.Error(w.ServiceName,"Failed to set limiting switch parameters - cannot get current mode of gate controller."),a.qb.Error;if(i==r.Monostable)return this._logger.Error(w.ServiceName,"Failed to set limiting switch parameters - cannot set this params when channel mode is 'monostable'."),a.qb.OperationNotPermitted;yield this._controllerConfigurationService.EnterConfigurationModeAsync();const o=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new G(Object.assign(Object.assign({},t),{DeviceGuid:e.Guid})),8e3,!1);return null==o||null==o.Status?(this._logger.Error(w.ServiceName,"Failed to set limiting switch parameters - unknown error."),a.qb.FatalError):(o.Status!==a.qb.OK&&this._logger.Error(w.ServiceName,`Failed to set limiting switch parameters, response status: ${o.Status}`),o.Status)}catch(e){return this._logger.Error(w.ServiceName,"Failed to set limiting switch parameters - unknown error."),a.qb.FatalError}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}GetTimeBetweenPulsesAsync(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new u.tp(h.v.InvalidChannelNumber,`Cannot get time between pulses - invalid channel number, channel: ${t}`);const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new _(new m.W(e.Guid,t)),8e3,!1);return null==r||null==r.Status?new u.tp(h.v.OtherError,"Cannot get time between pulses - unknown error."):r.Status!==a.qb.OK?new u.tp(h.v.OtherError,`Cannot get time between pulses - controller responded with error code: ${r.Status}.`):null==r.Data?new u.tp(h.v.NoData,"Cannot get time between pulses - no data in response."):r.Data.TimeBetwenPulse/10}catch(e){return new u.tp(h.v.OtherError,"Cannot get time between pulses - unknown error.")}}))}SetTimeBetweenPulsesAsync(e,t,n){var i;return p(this,void 0,void 0,(function*(){try{if(n<1||n>300||n%1!=0)return this._logger.Error(w.ServiceName,"Failed to set time between pulses - value is out of range!"),a.qb.WrongData;const o=yield this.GetGateModeAsync(e,t);if(null!=o.Type)return this._logger.Error(w.ServiceName,"Failed to set time between pulses - cannot get current mode of gate controller."),a.qb.Error;if(o!=r.Gateway)return this._logger.Error(w.ServiceName,"Failed to set time between pulses - cannot set this parameter when channel mode is 'monostable' or 'gate'."),a.qb.OperationNotPermitted;const s=new S;s.DeviceGuid=e.Guid,s.Channel=t,s.TimeBetwenPulse=10*n,yield this._controllerConfigurationService.EnterConfigurationModeAsync();const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new F(s),8e3,!1);return null==l||null==l.Status?(this._logger.Error(w.ServiceName,"Failed to set time between pulses - unknown error."),a.qb.FatalError):(l.Status!==a.qb.OK&&this._logger.Error(w.ServiceName,`Failed to set time between pulses, response status: ${l.Status}`),l.Status)}catch(e){return this._logger.Error(w.ServiceName,"Failed to set time between pulses - unknown error."),a.qb.FatalError}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}GetOpeningTime(e,t){var n;return p(this,void 0,void 0,(function*(){try{if(!e.Channels.any((e=>e.Number===t)))return new u.tp(h.v.InvalidChannelNumber,`Cannot get gate opening time - invalid channel number, channel: ${t}`);const r=yield null===(n=this._connection)||void 0===n?void 0:n.SendAndWaitForResponseAsync(new A(new m.W(e.Guid,t)),8e3,!1);return null==r||null==r.Status?new u.tp(h.v.OtherError,"Cannot get gate opening time - unknown error."):r.Status!==a.qb.OK?new u.tp(h.v.OtherError,`Cannot get gate opening time - controller responded with error code: ${r.Status}.`):null==r.Data?new u.tp(h.v.NoData,"Cannot get gate opening time - no data in response."):r.Data.GateOpenTime}catch(e){return new u.tp(h.v.OtherError,"Cannot get gate opening time - unknown error.")}}))}SetOpeningTimeAsync(e,t,n){var i;return p(this,void 0,void 0,(function*(){try{if(n<1||n>300||n%1!=0)return this._logger.Error(w.ServiceName,"Failed to set opening time - value is out of range!"),a.qb.WrongData;const o=yield this.GetGateModeAsync(e,t);if(null!=o.Type)return this._logger.Error(w.ServiceName,"Failed to set opening time - cannot get current mode of gate controller."),a.qb.Error;if(o!=r.Gateway)return this._logger.Error(w.ServiceName,"Failed to set opening time - cannot set this parameter when channel mode is 'monostable' or 'gate'."),a.qb.OperationNotPermitted;const s=new S;s.DeviceGuid=e.Guid,s.Channel=t,s.GateOpenTime=n,yield this._controllerConfigurationService.EnterConfigurationModeAsync();const l=yield null===(i=this._connection)||void 0===i?void 0:i.SendAndWaitForResponseAsync(new D(s),8e3,!1);return null==l||null==l.Status?(this._logger.Error(w.ServiceName,"Failed to set opening time - unknown error."),a.qb.FatalError):(l.Status!==a.qb.OK&&this._logger.Error(w.ServiceName,`Failed to set opening time, response status: ${l.Status}`),l.Status)}catch(e){return this._logger.Error(w.ServiceName,"Failed to set opening time - unknown error."),a.qb.FatalError}finally{yield this._controllerConfigurationService.ExitConfigurationModeAsync()}}))}}w.ServiceName="Rob21ConfigService";class S{constructor(){this.Channel=0,this.DeviceGuid="",this.PulseTime=0,this.TimeBetwenPulse=0,this.GateOpenTime=0,this.TypeOfGateChannel=r.Gate}}class y extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/channel/type",this.Method=a.n$.Get,this.Data=e}}class f extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/channel/type",this.Method=a.n$.Put,this.Data=e}}class C extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/time/pulse",this.Method=a.n$.Get,this.Data=e}}class b extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/time/pulse",this.Method=a.n$.Put,this.Data=e}}class E{constructor(e,t){this.DeviceGuid="",this.Input=0,this.DeviceGuid=e,this.Input=t}}class N extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/inputs/configuration",this.Method=a.n$.Get,this.Data=e}}class G extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/inputs/configuration",this.Method=a.n$.Put,this.Data=e}}class _ extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/time/between/pulse",this.Method=a.n$.Get,this.Data=e}}class F extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/time/between/pulse",this.Method=a.n$.Put,this.Data=e}}class A extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/time/gate/opening",this.Method=a.n$.Get,this.Data=e}}class D extends a.NE{constructor(e){super(),this.Resource="/extalife/device/parameters/time/gate/opening",this.Method=a.n$.Put,this.Data=e}}}}]);
//# sourceMappingURL=815-exalushome-extalife.bundle.js.map