@kvaser/canking-api
Version:
CanKing API to communicate with the CanKing service using Node.js.
2 lines (1 loc) • 4.72 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./models.js"),w=require("./status_params.js"),t=window.electron??c.electronApiFake,g=e=>e!=null&&typeof e.message=="string",r=(e,s,a)=>{t.ipcRenderer.invoke("main-add-log-message",{time:Date.now(),logLevel:e,categoryName:s,message:a})};class R{categoryName;constructor(s){this.categoryName=s}trace(s){r(0,this.categoryName,s)}debug(s){r(1,this.categoryName,s)}info(s){r(2,this.categoryName,s)}warn(s){r(3,this.categoryName,s)}error(s,a){typeof s=="string"?r(4,this.categoryName,s):g(s)&&r(4,this.categoryName,s.message),g(a)&&r(4,this.categoryName,a.message)}critical(s){r(5,this.categoryName,s)}}const u=e=>new R(e),v=async(e,s)=>{await t.ipcRenderer.invoke("main-show-message-box",e,s)},k=async(e,s,a,o,i)=>await t.ipcRenderer.invoke("main-show-question-box",e,s,a,o,i),f=async()=>{await t.ipcRenderer.invoke("mm-start-measurement")},M=async()=>{await t.ipcRenderer.invoke("mm-stop-measurement")},T=async e=>{await t.ipcRenderer.invoke("mm-add-source",e)},h=async e=>{await t.ipcRenderer.invoke("mm-update-source",e)},F=async e=>{await t.ipcRenderer.invoke("mm-delete-source",e)},L=async(e,s,a)=>{await t.ipcRenderer.invoke("mm-add-data-processor",e,s,a)},N=async e=>{await t.ipcRenderer.invoke("mm-update-data-processor",e)},b=async e=>{await t.ipcRenderer.invoke("mm-delete-data-processor",e)},D=async e=>{await t.ipcRenderer.invoke("mm-add-target",e)},P=async e=>{await t.ipcRenderer.invoke("mm-update-target",e)},S=async e=>{await t.ipcRenderer.invoke("mm-delete-target",e)},x=async(e,s)=>{await t.ipcRenderer.invoke("mm-connect-nodes",e,s)},q=async(e,s)=>{await t.ipcRenderer.invoke("mm-disconnect-nodes",e,s)},B=async e=>{await t.ipcRenderer.invoke("mm-enable-node",e)},I=async e=>{await t.ipcRenderer.invoke("mm-disable-node",e)},l=async(e,s)=>{await t.ipcRenderer.invoke("mm-send-message",e,s)},C=async(e,s,a,...o)=>{const i=w.WriteFrame.fromPartial({id:s,data:a,canFrameFlags:{flags:o}});await l(e,i)},K=async(e,s)=>{await t.ipcRenderer.invoke("mm-update-lin-message",e,s)},A=async(e,s)=>{await t.ipcRenderer.invoke("mm-clear-lin-message",e,s)},E=async(e,s)=>{await t.ipcRenderer.invoke("mm-request-lin-message",e,s)},Q=async e=>await t.ipcRenderer.invoke("mm-start-periodic-transmission",e),$=async(e,s)=>{await t.ipcRenderer.invoke("mm-update-periodic-transmission",e,s)},j=async e=>{await t.ipcRenderer.invoke("mm-stop-periodic-transmission",e)},z=async e=>{await t.ipcRenderer.invoke("mm-start-log-replay",e)},O=async e=>{await t.ipcRenderer.invoke("mm-stop-log-replay",e)},W=async()=>await t.ipcRenderer.invoke("mm-get-message-log-file-formats"),_=async()=>await t.ipcRenderer.invoke("mm-get-signal-log-file-formats"),G=async e=>{try{const s=await t.ipcRenderer.invoke("mm-get-frame-definitions-with-meta",e);return s?.truncated&&u("ipc").warn(`Frame definitions response was truncated by IPC payload limits. Returned ${s.items.length} of ${s.originalCount}.`),s?.items??[]}catch{return await t.ipcRenderer.invoke("mm-get-frame-definitions",e)}},H=async(e,s,a)=>{const o=await t.ipcRenderer.invoke("mm-get-measurement-data-before-timestamp",e,s);if(a&&a.length>0){const i=new Map;return a.forEach(n=>{const m=c.calculateSubscriptionKey(n);i.set(m,{ignoreSource:n.sourceId===void 0||n.sourceId==="",ignoreDirection:n.tx===void 0,ignoreMux:n.mux===void 0})}),o.filter(n=>{const m=c.deserializeFrame(n);let p=!1;return i.forEach((d,y)=>{c.calculateSubscriptionKeyFromFrame(m,d.ignoreSource,d.ignoreDirection,d.ignoreMux)===y&&(p=!0)}),p})}return o},J=async()=>await t.ipcRenderer.invoke("mm-get-first-timestamp"),U=async()=>await t.ipcRenderer.invoke("mm-get-latest-timestamp"),V=async()=>await t.ipcRenderer.invoke("mm-get-first-and-latest-timestamp");exports.addDataProcessor=L;exports.addSource=T;exports.addTarget=D;exports.clearLinMessage=A;exports.connectNodes=x;exports.deleteDataProcessor=b;exports.deleteSource=F;exports.deleteTarget=S;exports.disableNode=I;exports.disconnectNodes=q;exports.enableNode=B;exports.getFirstAndLatestTimestamp=V;exports.getFirstTimestamp=J;exports.getFrameDefinitions=G;exports.getLatestTimestamp=U;exports.getLogger=u;exports.getMessageDataBeforeTimestamp=H;exports.getMessageLogFileFormats=W;exports.getSignalLogFileFormats=_;exports.requestLinMessage=E;exports.sendCanMessage=C;exports.sendMessage=l;exports.showMessageBox=v;exports.showQuestionBox=k;exports.startLogReplay=z;exports.startMeasurement=f;exports.startPeriodicTransmission=Q;exports.stopLogReplay=O;exports.stopMeasurement=M;exports.stopPeriodicTransmission=j;exports.updateDataProcessor=N;exports.updateLinMessage=K;exports.updatePeriodicTransmission=$;exports.updateSource=h;exports.updateTarget=P;