{"version":3,"file":"SetDriverFucntion.mjs","names":[],"sources":["../../generated/api/SetDriverFucntion.ts"],"sourcesContent":["import { encodeUIntLE, ErrorType, Request, Session } from '@novastar/codec';\nimport AddressMapping from '../AddressMapping';\n\ndeclare module '@novastar/codec' {\n  interface API {\n    SetDriverFucntion(\n      addr: number,\n      portAddr: number,\n      scanBoardAddr: number,\n      bBroadcast: boolean,\n      driverFunc: number\n    ): Promise<void>;\n    trySetDriverFucntion(\n      addr: number,\n      portAddr: number,\n      scanBoardAddr: number,\n      driverFunc: number\n    ): Promise<ErrorType | null>;\n  }\n}\nexport default function createSetDriverFucntion<Broadcast extends boolean>(\n  addr: number,\n  portAddr: number,\n  scanBoardAddr: number,\n  bBroadcast: Broadcast,\n  driverFunc: number\n): Request<Broadcast> {\n  const $data = encodeUIntLE(driverFunc, AddressMapping.DriverFucntionOccupancy);\n  const req = new Request($data, bBroadcast, 'SetDriverFucntion');\n  req.destination = addr;\n  req.deviceType = 1;\n  req.port = portAddr;\n  req.rcvIndex = scanBoardAddr;\n  req.address = AddressMapping.DriverFucntionAddr;\n  return req;\n}\nSession.prototype.SetDriverFucntion = async function SetDriverFucntion(\n  this: Session,\n  addr: number,\n  portAddr: number,\n  scanBoardAddr: number,\n  bBroadcast: boolean,\n  driverFunc: number\n): Promise<void> {\n  const req = createSetDriverFucntion(addr, portAddr, scanBoardAddr, bBroadcast, driverFunc);\n  await this.connection.send(req);\n};\nSession.prototype.trySetDriverFucntion = async function trySetDriverFucntion(\n  this: Session,\n  addr: number,\n  portAddr: number,\n  scanBoardAddr: number,\n  driverFunc: number\n): Promise<ErrorType | null> {\n  const req = createSetDriverFucntion(addr, portAddr, scanBoardAddr, false, driverFunc);\n  return (await this.connection.trySend(req))?.ack ?? null;\n};\n"],"mappings":";;;;AAoBA,SAAwB,wBACtB,MACA,UACA,eACA,YACA,YACoB;CAEpB,MAAM,MAAM,IAAI,QADF,aAAa,aACC,GAAG,YAAY,mBAAmB;CAC9D,IAAI,cAAc;CAClB,IAAI,aAAa;CACjB,IAAI,OAAO;CACX,IAAI,WAAW;CACf,IAAI;CACJ,OAAO;AACT;AACA,QAAQ,UAAU,oBAAoB,eAAe,kBAEnD,MACA,UACA,eACA,YACA,YACe;CACf,MAAM,MAAM,wBAAwB,MAAM,UAAU,eAAe,YAAY,UAAU;CACzF,MAAM,KAAK,WAAW,KAAK,GAAG;AAChC;AACA,QAAQ,UAAU,uBAAuB,eAAe,qBAEtD,MACA,UACA,eACA,YAC2B;CAC3B,MAAM,MAAM,wBAAwB,MAAM,UAAU,eAAe,OAAO,UAAU;CACpF,QAAQ,MAAM,KAAK,WAAW,QAAQ,GAAG,IAAI,OAAO;AACtD"}