-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNcrComPort.h
161 lines (114 loc) · 2.74 KB
/
NcrComPort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#ifndef NCRCOMPORT_H
#define NCRCOMPORT_H
#include <windows.h>
#include <vector>
#include <string>
#define MIN_DISPLAY_INTERVAL 300
class NcrMarqueeData {
public:
NcrMarqueeData();
NcrMarqueeData(const NcrMarqueeData &src);
void Step();
void Stop();
std::string text;
int direction;
HANDLE timerId;
unsigned x, y, pos;
unsigned width;
const char *port;
};
class NcrWindow
{
public:
NcrWindow();
~NcrWindow();
NcrWindow(
const char *port,
int Yview,
int Xview,
int Hview,
int Wview,
int Hwindow,
int Wwindow);
int Yview;
int Xview;
int Hview;
int Wview;
int Hwindow;
int Wwindow;
int MarqueeType;
int MarqueeFormat;
int MarqueeRepeatWait;
int MarqueeUnitWait;
HANDLE timerId;
std::string Text;
const char *port;
void OutputText();
void StartMarquee();
void StopMarquee();
};
class NcrComPort
{
public:
NcrComPort();
NcrComPort(const char *port);
virtual ~NcrComPort();
void SetModel(int model);
int GetModel() const;
void SetDeviceName(const std::wstring &name);
const std::wstring &GetDeviceName() const;
int ReadByte();
bool SendData(const char *data);
bool SendByte(int byte);
void SendString(const char *str);
void SendStringLimited(const char *str, int n);
void SendStringLimitedBlanked(const char *str, int n);
void Open(const char *port);
void Close();
int GetResult() const;
void TurnOn();
void TurnOff();
bool TurnedOn() const;
void ClearText();
void SetCursorPos(int Row, int Col);
unsigned GetColumnCount() const;
int WindowCount() const;
int CurrentWindowNumber() const;
void CurrentWindowNumber(int num);
NcrWindow &CurrentWindow();
const NcrWindow &CurrentWindow() const;
void CreateNcrWindow(int Yview, int Xview, int Hview, int Wview, int Hwindow, int Wwindow);
void DeleteNcrWindow();
void SendStringPosThreaded(int row, int column, const char *str);
protected:
private:
void FillDcb(DCB &dcb);
DCB dcb;
HANDLE hPort;
const char *Port;
int m_model;
std::wstring m_DeviceName;
int m_Result;
bool m_turned_on;
std::vector<NcrWindow> m_windows;
unsigned m_current_window;
int OpenPort();
void ClosePort();
};
class NcrDeviceList : public std::vector<NcrComPort> {
public:
NcrDeviceList();
void AddDevice();
void DeleteDevice();
int GetCurrentDeviceNumber() const;
NcrComPort &Current();
const NcrComPort &Current() const;
void Current(unsigned DeviceNumber);
private:
unsigned m_CurrentDeviceNumber;
};
extern int timer_counter;
HANDLE AddMarquee(const char *port, const std::string &text, int x, int y, int ms, int W);
void DeleteMarquee(HANDLE timerId);
void StopAllMarquees();
#endif // NCRCOMPORT_H