{"version":3,"file":"ReadNumberOfCardOrScanBoardInPort.cjs","names":["Request"],"sources":["../../generated/api/ReadNumberOfCardOrScanBoardInPort.ts"],"sourcesContent":["import { decodeUIntLE, Packet, Request, Session } from '@novastar/codec';\nimport AddressMapping from '../AddressMapping';\nimport { CardTypeEnum } from '../CardType';\n\ndeclare module '@novastar/codec' {\n  interface API {\n    ReadNumberOfCardOrScanBoardInPort(\n      addr: number,\n      portIndex: number,\n      cardType: CardTypeEnum\n    ): Promise<number>;\n    tryReadNumberOfCardOrScanBoardInPort(\n      addr: number,\n      portIndex: number,\n      cardType: CardTypeEnum\n    ): Promise<Packet | null>;\n  }\n}\nexport default function createReadNumberOfCardOrScanBoardInPort(\n  addr: number,\n  portIndex: number,\n  cardType: CardTypeEnum\n): Request {\n  const req = new Request(\n    AddressMapping.NumberOfCardOrBoardInPortOccupancy,\n    'ReadNumberOfCardOrScanBoardInPort'\n  );\n  req.destination = addr;\n  req.address = 0;\n  if (portIndex < AddressMapping.New16PortOccupancy) {\n    req.address =\n      AddressMapping.NumberOfCardOrBoardInPortAddr +\n      portIndex * AddressMapping.NumOfCardAndBoardInPortOccupancy +\n      cardType * AddressMapping.NumberOfCardOrBoardInPortOccupancy;\n  } else {\n    req.address =\n      AddressMapping.NumberOfCardOrBoardInPort16Addr +\n      portIndex * AddressMapping.NumOfCardAndBoardInPortOccupancy +\n      cardType * AddressMapping.NumberOfCardOrBoardInPortOccupancy;\n  }\n  return req;\n}\nSession.prototype.ReadNumberOfCardOrScanBoardInPort =\n  async function ReadNumberOfCardOrScanBoardInPort(\n    this: Session,\n    addr: number,\n    portIndex: number,\n    cardType: CardTypeEnum\n  ): Promise<number> {\n    const req = createReadNumberOfCardOrScanBoardInPort(addr, portIndex, cardType);\n    return decodeUIntLE(await this.connection.send(req));\n  };\nSession.prototype.tryReadNumberOfCardOrScanBoardInPort =\n  async function tryReadNumberOfCardOrScanBoardInPort(\n    this: Session,\n    addr: number,\n    portIndex: number,\n    cardType: CardTypeEnum\n  ): Promise<Packet | null> {\n    const req = createReadNumberOfCardOrScanBoardInPort(addr, portIndex, cardType);\n    return this.connection.trySend(req);\n  };\n"],"mappings":";;;;;AAkBA,SAAwB,wCACtB,MACA,WACA,UACS;CACT,MAAM,MAAM,IAAIA,2BAEd,mCACF;CACA,IAAI,cAAc;CAClB,IAAI,UAAU;CACd,IAAI,eACF,IAAI,qBAEF,iBACA;MAEF,IAAI,qBAEF,iBACA;CAEJ,OAAO;AACT;AACA,wBAAQ,UAAU,oCAChB,eAAe,kCAEb,MACA,WACA,UACiB;CACjB,MAAM,MAAM,wCAAwC,MAAM,WAAW,QAAQ;CAC7E,yCAAoB,MAAM,KAAK,WAAW,KAAK,GAAG,CAAC;AACrD;AACF,wBAAQ,UAAU,uCAChB,eAAe,qCAEb,MACA,WACA,UACwB;CACxB,MAAM,MAAM,wCAAwC,MAAM,WAAW,QAAQ;CAC7E,OAAO,KAAK,WAAW,QAAQ,GAAG;AACpC"}