87 lines
2.7 KiB
C++
87 lines
2.7 KiB
C++
// Purpose: IPC methods between scanner and user-interface (keyboard, monitor, power, ...)
|
|
//
|
|
// Date: 2024-01-09
|
|
//
|
|
// Thinking: This module can provide services independently of the scanner-service program
|
|
//
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
namespace devui
|
|
{
|
|
enum scan
|
|
{
|
|
SCAN_STOPPED = 0, // scanning work is stopped
|
|
SCAN_PAUSED, // finished ONE turn scanning in auto-scan
|
|
SCAN_NORMAL,
|
|
SCAN_COUNT_MODE,
|
|
};
|
|
enum uicmd
|
|
{
|
|
UI_CMD_COUNT_PAPER = 0x10,
|
|
UI_CMD_STOP_SCAN,
|
|
|
|
UI_CMD_CLEAN_PASSWAY = 0x30,
|
|
|
|
UI_STATUS_SCANNING = 0x1000, // begin scanning. data: (LPSCANSTREAM)
|
|
UI_STATUS_PAPER_CNT, // ONE paper has pass through. data: (uint32_t*)milliseconds for paper pass through
|
|
UI_STATUS_MESSAGE, // status message, hold screen. data: LPSTATMSG
|
|
|
|
UI_STATUS_PEER_CLOSED = 0x8000, // peer closed.
|
|
};
|
|
enum align_component
|
|
{
|
|
ALIGN_COMPONENT_HEAD = 0,
|
|
ALIGN_COMPONENT_MID,
|
|
ALIGN_COMPONENT_TAIL,
|
|
};
|
|
enum clear_method
|
|
{
|
|
CLEAR_NONE = 0, // no clear
|
|
CLEAR_ALL, // clear all screen
|
|
CLEAR_LINE, // clear the lines which the content will output
|
|
};
|
|
|
|
#pragma pack(push)
|
|
#pragma pack(1)
|
|
typedef struct _msg_stream
|
|
{
|
|
uint16_t ver;
|
|
uint16_t size; // bytes of data
|
|
uint32_t msg; // uicmd
|
|
uint8_t data[4];
|
|
|
|
uint32_t whole_size(void)
|
|
{
|
|
if(size > sizeof(data))
|
|
return sizeof(*this) + size - sizeof(data);
|
|
else
|
|
return sizeof(*this);
|
|
}
|
|
}MSGSTREAM, *LPMSGSTREAM;
|
|
typedef struct _scan_stream
|
|
{
|
|
uint32_t mode : 5; // see enum scan
|
|
uint32_t speed : 27;
|
|
uint32_t err; // err message word ID, 0 is normal
|
|
}SCANSTREAM, *LPSCANSTREAM;
|
|
typedef struct _status_msg
|
|
{
|
|
uint32_t msg_words_id; // words.h
|
|
uint32_t align_h : 3; // align_component
|
|
uint32_t align_v : 3; // align_component
|
|
uint32_t clear : 4; // clear screen method
|
|
uint32_t font : 8; // font size
|
|
uint32_t reserved : 14;
|
|
}STATMSG, *LPSTATMSG;
|
|
#pragma pack(pop)
|
|
|
|
void init_ui(std::function<void(LPMSGSTREAM)> uicb, bool ui);
|
|
void uninit_ui(void);
|
|
|
|
bool send_message(uint32_t msgid, uint8_t* data = nullptr, uint8_t size = 0); // re-init if return false
|
|
bool send_status_message(uint32_t msgid, int align_h = ALIGN_COMPONENT_MID, int align_v = ALIGN_COMPONENT_MID, int font = 16, int clears = CLEAR_ALL);
|
|
};
|