{"version":3,"file":"SetRtco.cjs","names":["Request"],"sources":["../../generated/api/SetRtco.ts"],"sourcesContent":["import { ErrorType, Request, Session } from '@novastar/codec';\nimport AddressMapping from '../AddressMapping';\n\ndeclare module '@novastar/codec' {\n  interface API {\n    SetRtco(addr: number, bBroadcast: boolean, rtco: number[] | Buffer): Promise<void>;\n    trySetRtco(addr: number, rtco: number[] | Buffer): Promise<ErrorType | null>;\n  }\n}\nexport default function createSetRtco<Broadcast extends boolean>(\n  addr: number,\n  bBroadcast: Broadcast,\n  rtco: number[] | Buffer\n): Request<Broadcast> {\n  if (rtco.length !== AddressMapping.RtcoOccupancy)\n    throw new TypeError(`Invalid buffer size: ${rtco.length}`);\n  const req = new Request(rtco, bBroadcast, 'SetRtco');\n  req.destination = addr;\n  req.address = AddressMapping.RtcoAddr;\n  return req;\n}\nSession.prototype.SetRtco = async function SetRtco(\n  this: Session,\n  addr: number,\n  bBroadcast: boolean,\n  rtco: number[] | Buffer\n): Promise<void> {\n  const req = createSetRtco(addr, bBroadcast, rtco);\n  await this.connection.send(req);\n};\nSession.prototype.trySetRtco = async function trySetRtco(\n  this: Session,\n  addr: number,\n  rtco: number[] | Buffer\n): Promise<ErrorType | null> {\n  const req = createSetRtco(addr, false, rtco);\n  return (await this.connection.trySend(req))?.ack ?? null;\n};\n"],"mappings":";;;;;AASA,SAAwB,cACtB,MACA,YACA,MACoB;CACpB,IAAI,KAAK,cACP,MAAM,IAAI,UAAU,wBAAwB,KAAK,QAAQ;CAC3D,MAAM,MAAM,IAAIA,wBAAQ,MAAM,YAAY,SAAS;CACnD,IAAI,cAAc;CAClB,IAAI;CACJ,OAAO;AACT;AACA,wBAAQ,UAAU,UAAU,eAAe,QAEzC,MACA,YACA,MACe;CACf,MAAM,MAAM,cAAc,MAAM,YAAY,IAAI;CAChD,MAAM,KAAK,WAAW,KAAK,GAAG;AAChC;AACA,wBAAQ,UAAU,aAAa,eAAe,WAE5C,MACA,MAC2B;CAC3B,MAAM,MAAM,cAAc,MAAM,OAAO,IAAI;CAC3C,QAAQ,MAAM,KAAK,WAAW,QAAQ,GAAG,IAAI,OAAO;AACtD"}