Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ハードウェア対応のリアル.pdf

たまねぎ
May 16, 2023
54

 ハードウェア対応のリアル.pdf

たまねぎ

May 16, 2023
Tweet

Transcript

  1. ϋʔυ΢ΣΞରԠͷϦΞϧ
    !@DIPDPZBNB
    &CJTVNPCJMF

    View full-size slide

  2. ࣗݾ঺հ
    w ͨ·Ͷ͗ʢ!@DIPDPZBNBʣ
    w 4503&4ϨδͷJ04ΞϓϦ։ൃ
    w ϋʔυ΢ΣΞରԠ͸

    ॳΊͯ΍Γ࢝Ί͔ͯΒd೥

    View full-size slide

  3. ࠓ೔࿩͢͜ͱ
    w ϋʔυ΢ΣΞରԠͱ͸ʁ
    w ։ൃͷϦΞϧ
    w ӡ༻ͷϦΞϧ
    w ςΫϊϩδʔʹΑΔ՝୊ղܾ


    ˞શମతʹJ04دΓͷ࿩ʹͳΓ·͢🙏

    View full-size slide

  4. ϋʔυ΢ΣΞରԠͱ͸ʁ

    View full-size slide

  5. ϝΠϯػͱ͸ผͷೖग़ྗ୺຤ͱ࿈ܞ͢ΔରԠ
    ܾࡁ୺຤
    υϩΞʔ
    όʔίʔυεΩϟφʔ
    ΧελϚʔσΟεϓϨΠ
    #FBDPO
    ϚΠΫ
    εϐʔΧʔ
    ϖϯγϧ
    Ϛ΢ε ΩʔϘʔυ
    ΠϠϗϯ
    ೖྗ
    ग़ྗ
    ϓϦϯλʔ
    εϚʔτϑΥϯ୯ମͰ͸
    ղܾͰ͖ͳ͍՝୊ʹϦʔνͰ͖Δ

    View full-size slide

  6. 4503&4ϨδͷରԠϋʔυ΢ΣΞͱػೳ
    όʔίʔυεΩϟφʔͰɺΞΠςϜΛΧʔτʹ௥Ճ
    ௥Ճͨ͠Χʔτͷ৘ใΛɺΧελϚʔσΟεϓϨΠʹ൓ө
    ܾࡁ୺຤ͰɺܾࡁॲཧΛ࣮ߦ
    ܾࡁ͕׬ྃͨ͠஫จͷϨγʔτΛɺϓϦϯλʔͰग़ྗ

    View full-size slide

  7. ར༻͍ͯ͠Δٕज़
    ୺຤ ར༻ٕज़
    ܾࡁ୺຤ #MVFUPPUI
    ϓϦϯλʔ
    υϩΞʔ
    #MVFUPPUI
    όʔίʔυεΩϟφʔ #MVFUPPUI
    ΧελϚʔσΟεϓϨΠ

    ʢεϚʔτϑΥϯʣ
    -PDBM/FUXPSL
    ղܾͰ͖Δ՝୊΋େ͖͍͕ɺ։ൃɾӡ༻ͷίετ΋େ͖͍

    View full-size slide

  8. ։ൃͷϦΞϧ

    View full-size slide

  9. ࣮૷ϋʔυϧ͕ߴ͍
    w ୺຤ͱͷ࿈ܞ෦෼Ͱ

    ௿ϨΠϠʔͳ࣮૷͕ඞཁ
    w ઀ଓ؅ཧɾ௨৴ॲཧͰͷ

    ࡉ͔͍έΞ͕େม
    w ඇಉظॲཧ͕ଟ͘ɺ

    ॲཧͷྲྀΕ͕௫ΈͮΒ͍
    uint8_t *pos_papercut(cy_printer const printer, size_t *out_len)


    {


    if(printer & cy_paper_cut) {


    INIT_BUF();


    size_t nl_len;


    uint8_t * const newlines = pos_cutter_newlines(printer, &nl_len);


    if(nl_len > 0)


    APPEND_BUF(newlines, nl_len);




    if(CY_PRINTER_TYPE(printer) == cy_sm_desktop_printer)


    APPEND_BUF_AUTO(POS_LM_CUTPAPER);


    else


    APPEND_BUF_AUTO(POS2_CUTPAPER);




    if(out_len)


    *out_len = BUF_LEN();


    return BUF();


    }


    else


    return pos_cutter_newlines(printer, out_len);


    }


    $ݴޠʹΑΔ࣮૷ίʔυ

    View full-size slide

  10. ςετ͕ͮ͠Β͍
    w ग़͕ࣾඞཁ
    w ࣗಈςετͰͷ୲อ͕ͮ͠Β͍
    w 04ɾ୺຤όʔδϣϯ͚ͩͰͳ͘ɺ

    ϝʔΧʔ΍ϋʔυ΢ΣΞछผͷ

    ֻ͚߹Θͤ΋૿͑Δ

    View full-size slide

  11. ӡ༻ͷϦΞϧ

    View full-size slide

  12. ༷ʑͳ؀ڥɾछྨ΁ͷରԠ͕େม
    w #MVFUPPUIͷׯব΍8J'JઃఆʹΑΔҟৗಈ࡞
    w ϝʔΧʔ΍୺຤ʹґଘͨ͠ෆ۩߹ใࠂ
    w αϙʔτΛ੾ΓͮΒ͍

    View full-size slide

  13. Ϋϥογϡ΍ෆ۩߹͕ൃੜ͠΍͍͢
    w τοϓΫϥογϡ͸ϋʔυ΢ΣΞؔ࿈͕੮ר
    w ؆୯ʹݪҼΛಛఆͰ͖ͳ͍Ϋϥογϡϩά

    View full-size slide

  14. ͭΒΈϙΠϯτ·ͱΊ
    w ࣮૷ɾอकͷϋʔυϧ͕ߴ͍
    w ෆ۩߹͕ى͖΍͘͢୺຤ࠩ෼΋͋Δ
    w ςετίετ͕ߴࣗ͘ಈԽ΋ͮ͠Β͍
    w αϙʔτΛ੾ΓͮΒ͍
    ςΫϊϩδʔͰղܾ͠Α͏ʂ

    View full-size slide

  15. ࣮૷ɾอकͷϋʔυϧΛԼ͛ΔऔΓ૊Έ
    w ࣄྫɿඇಉظॲཧΛ4XJGU$PODVSSFODZͰ୯७Խ
    w ࣄྫɿυΩϡϝϯτཧղΛ$IBU(15Ͱߴ଎Խ
    w ࣄྫɿ۪௚ͳ࣮૷Λ3FTVMU#VJMEFSͰந৅Խ

    View full-size slide

  16. ࣄྫɿඇಉظॲཧΛ4XJGU$PODVSSFODZͰ୯७Խ
    w ՝୊
    w %FMFHBUF$PNQMFUJPO)BOEMFSϕʔεͷ࣮૷͕ଟ͍
    w ඇಉظॲཧΛ࿈ଓͰߦ͏έʔε΋ଟ͍
    w ίʔϧόοΫ஍ࠈʹͳΓɺॲཧϑϩʔ͕ಡΈऔΓͮΒ͍
    w 5SZ
    w 4XJGU$PODVSSFODZΛ༻͍࣮ͨ૷ʹஔ͖׵͑
    w ίʔυΛ୯७ʹ্͔ΒԼ΁ಡΉ͚ͩͰ͍͍ঢ়گʹվળ

    View full-size slide

  17. detectPaperWidth {


    guard $0 != PaperWidth.unknown else {


    // Ϩγʔτ෯ͷऔಘʹࣦഊͨ͠৔߹ɺ1౓͚ͩϦτϥΠ͢Δ


    _ = detectPaperWidth {


    update(paperWidth: $0)


    }


    return


    }


    update(paperWidth: $0)


    }


    var paperWidth = await paperWidthDetector.getWidth()


    if paperWidth == .unknown {


    // Ϩγʔτ෯ͷऔಘʹࣦഊͨ͠৔߹ɺ1౓͚ͩϦτϥΠ͢Δ


    paperWidth = await paperWidthDetector.getWidth()


    }


    update(paperWidth: paperWidth)


    ωετ͕গͳ͘ɺॲཧͷྲྀΕ͕௫Έ΍͘͢ͳͬͨ
    $PNQMFUJPO)BOEMFS%FMFHBUF 4XJGU$PODVSSFODZ
    ˞ཁ఺ΛߜΔͨΊσϑΥϧϝͯ͠·͢
    XJUI$IFDLFE$POUJOVBUJPOͰɺ

    ڧ੍తʹ4XJGU$PODVSSFODZͷܗ΁

    View full-size slide

  18. func getWidth() async -> PaperWidth {


    await withCheckedContinuation { (continuation: CheckedContinuation) in


    session.listen { inputStream, _ in


    var input: UInt8 = 0


    let inputLength = inputStream.read(&input, maxLength: 4096)


    if inputLength > 0 {


    let paperWidth = getPaperWidth(


    printerModel: printerModel,


    fromResponseValue: Data(bytes: &input, count: inputLength).ex.toBytes()


    )


    continuation.resume(returning: paperWidth)


    }


    }


    session.write(Data(bytes: cmd, count: cmdLength))


    }


    }
    ֎͔Βݟͨ࣌͸BTZODBXBJUͷγϯϓϧͳ*'
    $PNQMFUJPO)BOEMFSϕʔεͷ۪௚ͳ࣮૷͸
    ด͡ࠐΊͯந৅Խ͢Δ

    View full-size slide

  19. let print = {


    printReceiptML(receiptML)


    _ = cutPaper()


    completion()


    }


    let supportedVariableWidth = (printerType & cy_variable_paper_width) != 0


    if supportedVariableWidth {


    let continuePrint = { (width: PrinterWidth) in


    paperWidth = width


    print()


    }




    detectPaperWidth {


    guard $0 != PrinterWidth.unknown else {


    _ = detectPaperWidth {


    continuePrint($0)


    }


    return


    }


    continuePrint($0)


    }


    } else {


    print()


    }
    guard


    let activePrinter,


    let receipt = PaymentReceipt(order: order, store: store)?.build(),


    let image = try? await receipt.image(


    width: CGFloat(await activePrinter.receiptWidth())


    )


    else { return }


    activePrinter.printReceiptImage(image)
    ϨΨγʔͳ෦෼ΛϞμϯͳٕज़Ͱϥοϓ
    ҹ࡮໋ྩΛߦ͏ؔ਺ͷαϯϓϧ
    ॲཧͷྲྀΕ͕௥͍΍͘͢ͳΓɺίʔυͷ࡟ݮ΋Ͱ͖ͨ

    View full-size slide

  20. ࣄྫɿυΩϡϝϯτཧղΛ$IBU(15Ͱߴ଎Խ
    ʮग़ྗ͞ΕΔ༻ࢴ෯ͷऔಘʯʹؔ͢ΔϓϦϯλʔͷެࣜυΩϡϝϯτ

    View full-size slide

  21. ϋʔυ΢ΣΞؔ࿈ͷυΩϡϝϯτ
    w ՝୊
    w ීஈࢀর͢Δ%PDͱ͸͔͚཭Εͨ಺༰
    w αοͱཧղ͢Δʹ͸ϋʔυϧ͕ߴ͍
    w ࣄྫ͕গͳ͘άάͬͯ΋ώοτͮ͠Β͍
    w 5SZ
    w άάͬͯμϝͳΒδϐͬͯΈΑ͏

    View full-size slide

  22. %PDͷҰ෦Λίϐϖͯ͠
    ʮΑ͘Θ͔Βͳ͍ͷͰɺΘ͔ΔΑ͏ʹڭ͑ͯʯ
    ͬͯݴͬͯΈΔ
    ˠৄࡉͳղઆΛͯ͘͠ΕΔ
    $IBU(15ͷ׆༻

    View full-size slide

  23. ·ͩΑ͘Θ͔Βͳ͍ͷͰɺ
    υΩϡϝϯτʹهࡌͷͳ͍ύλʔϯΛྫʹ
    ࢓༷ͷཧղΛਂΊΑ͏ͱ͢Δ
    ˠ%PDͷΑ͏ʹҰൠԽͨ͠಺༰Ͱ͸ͳ͘ɺ

    ʮ"ͷ৔߹ɺ#ʹͳΔʯͱ͍ͬͨ
    ۩ମతͳ࢓༷Λڭ͑ͯ͘ΕΔ

    View full-size slide

  24. ˠ۩ମతͳظ଴݁ՌΛڭ͑ͯ͘ΕΔ
    ੩తͳ%PDͰ͸ෆՄೳͳΠϯλϥΫςΟϒͳ2"ʹΑΓɺ
    ཧղ͕ઙ͍෦෼Λ໌֬ʹ͠ͳ͕Β࢓༷Λ೺ѲͰ͖ͨ
    ࢓༷͕໌֬ʹͳͬͨͷͰɺ
    ࠓճͷϢʔεέʔεΛΠϯϓοτ͢Δ͜ͱͰ
    ͦͷ৔߹Ͳ͏ͳΔ͔Λฉ͘

    View full-size slide

  25. ࣄྫɿ۪௚ͳ࣮૷Λ3FTVMU#VJMEFSͰந৅Խ
    9.-จࣈྻͷੜ੒Λɺ4XJGU6*ͷΑ͏ͳ*'ͰͰ͖ΔΑ͏ʹͨ͠
    SFGʲJ04%$ʳ෼ͰΘ͔Δʂ଎शSFTVMU#VJMEFS

    View full-size slide

  26. ·ͱΊ
    w ਖ਼௚ϋʔυ΢ΣΞରԠΛͯ͠ΔͱɺͭΒ͍ہ໘ʹ౓ʑͿ͔ͭΔ
    w ௿ϨΠϠʔͳ࣮૷΍ϨΨγʔͳ෦෼Λɺ

    Ϟμϯͳٕज़Ͱิ׬Ͱ͖Δָ͕͋͠͞Δ
    w ιϑτ΢ΣΞ͚ͩͰ͸࣮ݱͰ͖ͳ͍ϢʔβʔମݧΛఏڙͰ͖Δ

    View full-size slide

  27. େม͚ͩͲɺ
    ໘ന͞΋͋ΔΑʂ

    View full-size slide