<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PC SDK on TiJet</title><link>https://www.tainuohc.com/en/docs/sdk/</link><description>Recent content in PC SDK on TiJet</description><generator>Hugo</generator><language>en</language><atom:link href="https://www.tainuohc.com/en/docs/sdk/index.xml" rel="self" type="application/rss+xml"/><item><title>Current Print Workflow</title><link>https://www.tainuohc.com/en/docs/sdk/quickstart/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://www.tainuohc.com/en/docs/sdk/quickstart/</guid><description>&lt;h1 id="current-print-workflow">Current Print Workflow&lt;/h1>
&lt;p>This document describes the actual print workflow across the C client, C SDK, and &lt;code>tijet_1/tincore&lt;/code> gRPC server.&lt;/p>
&lt;p>This document only describes the current codebase and client behavior, and does not include future refactoring plans.&lt;/p>
&lt;h2 id="source-baseline">Source Baseline&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Module&lt;/th>
 &lt;th>Repository&lt;/th>
 &lt;th>Branch&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Proto contracts &amp;amp; C SDK&lt;/td>
 &lt;td>&lt;code>tijet_1/sw-grpc-libraries&lt;/code>&lt;/td>
 &lt;td>&lt;code>master&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>tincore gRPC server&lt;/td>
 &lt;td>&lt;code>tijet_1/tincore&lt;/code>&lt;/td>
 &lt;td>&lt;code>feature-grpc-cpp&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="participants">Participants&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Participant&lt;/th>
 &lt;th>Responsibility&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Qt Client Business Layer&lt;/td>
 &lt;td>Register event callbacks, upload print data, retry &lt;code>START_PRINT&lt;/code>, wait for final result&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>C SDK Call Thread&lt;/td>
 &lt;td>Encapsulate &lt;code>SetPrintData&lt;/code> and &lt;code>StartPrint&lt;/code> RPC calls&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>C SDK Event Thread&lt;/td>
 &lt;td>Continuously read &lt;code>SubscribeEvents&lt;/code> server stream and invoke registered callbacks&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>TinCoreServiceImpl&lt;/code>&lt;/td>
 &lt;td>gRPC protocol layer, dispatches RPC requests to server Handlers&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>DefaultTinCoreHandlers&lt;/code>&lt;/td>
 &lt;td>Handles print data reception, data readiness validation, and async print start logic&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>gAFBridge&lt;/code> / Printhead Hardware&lt;/td>
 &lt;td>Processes print data in background, controls driver board power, communicates with printhead and enables high voltage&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="current-call-sequence">Current Call Sequence&lt;/h2>
&lt;pre class="mermaid">sequenceDiagram
 autonumber
 participant Caller as Caller
 participant Callee as Callee

 Caller-&amp;gt;&amp;gt;Callee: tijet_client_set_event_callback(callback, user_data)
 Callee--&amp;gt;&amp;gt;Caller: Callback registered

 Caller-&amp;gt;&amp;gt;Callee: tijet_client_start_event_subscription()
 Callee--&amp;gt;&amp;gt;Caller: TIJET_OK
 Note over Callee: Background event thread created
 Note over Callee: SubscribeEvents() polling

 Caller-&amp;gt;&amp;gt;Callee: tijet_client_set_print_data(data, index, is_static)
 Callee--&amp;gt;&amp;gt;Caller: SetPrintDataResponse{success=true}
 Note over Callee: Print data enters background processing
 Note over Callee: DATA_READY may still be 0 on return

 loop START_PRINT retry, total timeout 10s
 Caller-&amp;gt;&amp;gt;Callee: tijet_client_print_control(START_PRINT)
 alt DATA_READY == 0
 Callee--&amp;gt;&amp;gt;Caller: TIJET_ERR_SERVER
 Note over Caller: Wait 1s before retry
 else DATA_READY != 0
 Callee--&amp;gt;&amp;gt;Caller: TIJET_OK
 Note over Callee: High-voltage thread created
 end
 end

 Note over Caller: After START_PRINT success, wait for PrintStarted

 alt High voltage successful
 Callee--&amp;gt;&amp;gt;Caller: PrintStarted{success=true}
 Note over Caller: Ready for printing
 else High voltage failed
 Callee--&amp;gt;&amp;gt;Caller: PrintStarted{success=false}
 Note over Caller: Failure, message contains failed head count
 else PrintStarted not received within 10s
 Note over Caller: Timeout
 end&lt;/pre>
&lt;h2 id="retry--timeout-flow">Retry &amp;amp; Timeout Flow&lt;/h2>
&lt;pre class="mermaid">flowchart TD
 A[&amp;#34;Caller: Connect to server&amp;#34;] --&amp;gt; B[&amp;#34;Caller: Register callback&amp;lt;br/&amp;gt;Start event subscription&amp;#34;]
 B --&amp;gt; C[&amp;#34;Caller: set_print_data() upload print data&amp;#34;]
 C --&amp;gt; D{&amp;#34;Callee: Upload RPC successful?&amp;#34;}

 D --&amp;gt;|&amp;#34;No&amp;#34;| D1[&amp;#34;Failed, flow ends&amp;#34;]
 D --&amp;gt;|&amp;#34;Yes&amp;#34;| E[&amp;#34;Callee: Data enters background processing&amp;lt;br/&amp;gt;DATA_READY may still be 0&amp;#34;]

 E --&amp;gt; F[&amp;#34;Caller: Start START_PRINT retry timer&amp;#34;]
 F --&amp;gt; G[&amp;#34;Caller: print_control(START_PRINT)&amp;#34;]
 G --&amp;gt; H{&amp;#34;Callee: Is DATA_READY == 0?&amp;#34;}

 H --&amp;gt;|&amp;#34;Yes: data not ready&amp;#34;| I{&amp;#34;Total retry time reached 10s?&amp;#34;}
 I --&amp;gt;|&amp;#34;No&amp;#34;| J[&amp;#34;Caller: Wait 1s&amp;#34;]
 J --&amp;gt; G
 I --&amp;gt;|&amp;#34;Yes&amp;#34;| K[&amp;#34;Failed: Print data preparation timeout&amp;#34;]

 H --&amp;gt;|&amp;#34;No: data ready&amp;#34;| L[&amp;#34;Callee: Create high-voltage thread&amp;lt;br/&amp;gt;Return TIJET_OK&amp;#34;]
 L --&amp;gt; M[&amp;#34;Caller: Wait for PrintStarted event&amp;lt;br/&amp;gt;timeout 10s&amp;#34;]
 M --&amp;gt; N{&amp;#34;Result&amp;#34;}

 N --&amp;gt;|&amp;#34;success=true&amp;#34;| O[&amp;#34;Success: High voltage enabled&amp;lt;br/&amp;gt;Ready for printing&amp;#34;]
 N --&amp;gt;|&amp;#34;success=false&amp;#34;| P[&amp;#34;Failed: High voltage activation failed&amp;#34;]
 N --&amp;gt;|&amp;#34;Timeout&amp;#34;| Q[&amp;#34;Failed: High voltage activation timed out&amp;#34;]&lt;/pre>
&lt;h2 id="current-return-value-semantics">Current Return Value Semantics&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Location&lt;/th>
 &lt;th>Return Value&lt;/th>
 &lt;th>Current Actual Meaning&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;code>tijet_client_set_print_data()&lt;/code>&lt;/td>
 &lt;td>&lt;code>TIJET_OK&lt;/code>&lt;/td>
 &lt;td>Print data upload RPC completed; does NOT mean backend processing is done or &lt;code>DATA_READY=1&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>tijet_client_print_control(..., &amp;quot;START_PRINT&amp;quot;)&lt;/code>&lt;/td>
 &lt;td>&lt;code>TIJET_ERR_SERVER&lt;/code>&lt;/td>
 &lt;td>gRPC call failed, or server returned &lt;code>success=false&lt;/code>; client does not distinguish cause, retries after 1s&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>tijet_client_print_control(..., &amp;quot;START_PRINT&amp;quot;)&lt;/code>&lt;/td>
 &lt;td>&lt;code>TIJET_OK&lt;/code>&lt;/td>
 &lt;td>Server sync validation passed and created high-voltage start thread; does NOT mean high voltage is enabled&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>PrintStarted.success&lt;/code>&lt;/td>
 &lt;td>&lt;code>true&lt;/code>&lt;/td>
 &lt;td>High voltage enabled successfully, &lt;code>setDataParamReady(true)&lt;/code> called&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>PrintStarted.success&lt;/code>&lt;/td>
 &lt;td>&lt;code>false&lt;/code>&lt;/td>
 &lt;td>High voltage activation failed, &lt;code>message&lt;/code> contains count of failed heads&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="source-index">Source Index&lt;/h2>
&lt;h3 id="c-sdk">C SDK&lt;/h3>
&lt;ul>
&lt;li>&lt;code>sdk/c/src/tijet_core.cpp:342&lt;/code>: &lt;code>tijet_client_set_print_data()&lt;/code>.&lt;/li>
&lt;li>&lt;code>sdk/c/src/tijet_core.cpp:396&lt;/code>: Register event callback.&lt;/li>
&lt;li>&lt;code>sdk/c/src/tijet_core.cpp:408&lt;/code>: Start event subscription and create event thread.&lt;/li>
&lt;li>&lt;code>sdk/c/src/tijet_core.cpp:641&lt;/code>: &lt;code>tijet_client_print_control()&lt;/code>.&lt;/li>
&lt;li>&lt;code>sdk/c/src/tijet_core.cpp:655&lt;/code>: Match &lt;code>START_PRINT&lt;/code> and call &lt;code>StartPrint&lt;/code> RPC.&lt;/li>
&lt;li>&lt;code>sdk/c/include/tijet_core.h:441&lt;/code>: Print data upload C API declaration.&lt;/li>
&lt;li>&lt;code>sdk/c/include/tijet_core.h:480&lt;/code>: Event callback registration C API declaration.&lt;/li>
&lt;li>&lt;code>sdk/c/include/tijet_core.h:500&lt;/code>: Event subscription C API declaration.&lt;/li>
&lt;li>&lt;code>sdk/c/include/tijet_core.h:650&lt;/code>: Print control C API declaration.&lt;/li>
&lt;/ul>
&lt;h3 id="proto-contracts">Proto Contracts&lt;/h3>
&lt;ul>
&lt;li>&lt;code>proto/print.proto:7&lt;/code>: &lt;code>SetPrintDataRequest&lt;/code>.&lt;/li>
&lt;li>&lt;code>proto/print.proto:19&lt;/code>: &lt;code>StartPrintRequest&lt;/code>.&lt;/li>
&lt;li>&lt;code>proto/print.proto:22&lt;/code>: &lt;code>StartPrintResponse&lt;/code>.&lt;/li>
&lt;li>&lt;code>proto/event.proto:48&lt;/code>: &lt;code>PrintDataStatus&lt;/code>.&lt;/li>
&lt;li>&lt;code>proto/event.proto:53&lt;/code>: &lt;code>PrintStarted&lt;/code>.&lt;/li>
&lt;li>&lt;code>proto/tincore.proto:27&lt;/code>: &lt;code>SetPrintData&lt;/code> RPC.&lt;/li>
&lt;li>&lt;code>proto/tincore.proto:28&lt;/code>: &lt;code>StartPrint&lt;/code> RPC.&lt;/li>
&lt;li>&lt;code>proto/tincore.proto:33&lt;/code>: &lt;code>SubscribeEvents&lt;/code> RPC.&lt;/li>
&lt;/ul>
&lt;h3 id="tijet_1tincore-grpc-server">&lt;code>tijet_1/tincore&lt;/code> gRPC Server&lt;/h3>
&lt;p>The following paths are relative to the &lt;code>feature-grpc-cpp&lt;/code> branch of &lt;code>tijet_1/tincore&lt;/code>:&lt;/p></description></item></channel></rss>