ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
ARCSscreen.hh
[詳解]
1
6//
7// Copyright (C) 2011-2024 Yokokura, Yuki
8// MIT License. For details, see the LICENSE file.
9
10#ifndef ARCSSCREEN
11#define ARCSSCREEN
12
13#include <ncurses.h>
14#include <pthread.h>
15#include <array>
16#include <string>
17#include "ConstParams.hh"
18#include "EquipParams.hh"
19#include "RingBuffer.hh"
20
21// 前方宣言
22namespace ARCS {
23 class ARCSeventlog;
24 class ARCSassert;
25 class ARCSprint;
26 class ARCSscrparams;
27 class ARCSgraphics;
28}
29
30namespace ARCS { // ARCS名前空間
33 public:
34 ARCSscreen(ARCSeventlog& EvLog, ARCSassert& Asrt, ARCSprint& Prnt, ARCSscrparams& Scrp, ARCSgraphics& Grph);
35 ~ARCSscreen();
36
50
51 enum PhaseStatus GetCmdStatus(void) const;
52 void WriteEventLogBuffer(const std::string& LogText);
53 void WriteDebugPrintBuffer(const std::string& PrintText);
54 void WriteDebugIndicator(const uint64_t u, const unsigned int i);
55 enum PhaseStatus WaitStartOrExit(void);
57 void WaitStop(void);
59
60 private:
61 ARCSscreen(const ARCSscreen&) = delete;
62 const ARCSscreen& operator=(const ARCSscreen&) = delete;
63
64 // イベントログの定数
65 static constexpr unsigned int EVLOG_TOP = 2;
66 static constexpr unsigned int EVLOG_LEFT = 68;
67 static constexpr unsigned int EVLOG_WIDTH = EquipParams::SCR_HORIZONTAL_MAX - 84;
68 static constexpr unsigned int EVLOG_NUM = 3;
69
70 // デバッグプリントの定数
71 static constexpr unsigned int DBPRNT_TOP = 6;
72 static constexpr unsigned int DBPRNT_LEFT = 38;
73 static constexpr unsigned int DBPRNT_WIDTH = EquipParams::SCR_HORIZONTAL_MAX - 38;
74 static constexpr unsigned int DBPRNT_NUM = EquipParams::SCR_VERTICAL_MAX - 8;
75
76 // デバッグインジケータの定数
77 static constexpr unsigned int DBINDC_TOP = 6;
78 static constexpr unsigned int DBINDC_LEFT = EquipParams::SCR_HORIZONTAL_MAX - 23;
79 static constexpr unsigned int DBINDC_NUM = 16;
80
81 // 非常停止ウィンドウの定数
82 static constexpr int EMWIN_LEFT = 0;
83 static constexpr int EMWIN_RIGHT = EquipParams::SCR_HORIZONTAL_MAX;
84 static constexpr int EMWIN_TOP = 1;
85 static constexpr int EMWIN_BOTTOM = 5;
86
87 // オンライン設定変数の定数
88 static constexpr double SETVAR_MAXVAL = 100000000;
89
91 enum ARCSbutton {
92 BUTTON_ON,
93 BUTTON_OFF,
94 BUTTON_DISABLE
95 };
96
98 enum text_color {
99 WHITE_BLACK = 1,
100 BLACK_CYAN,
101 CYAN_BLACK,
102 WHITE_BLUE,
103 BLUE_BLACK,
104 WHITE_RED,
105 BLACK_YELLOW,
106 BLACK_GREEN,
107 GREEN_BLACK,
108 RED_BLACK,
109 BLACK_BLUE
110 };
111
114 enum ARCSkeycode {
115 KEYCODE_EMPTY,
116 KEYCODE_UP,
117 KEYCODE_DOWN,
118 KEYCODE_LEFT,
119 KEYCODE_RIGHT,
120 KEYCODE_BS = 8,
121 KEYCODE_ENTER = 13,
122 KEYCODE_HYPH = 45,
123 KEYCODE_DOT = 46,
124 KEYCODE_0 = 48,
125 KEYCODE_1 = 49,
126 KEYCODE_2 = 50,
127 KEYCODE_3 = 51,
128 KEYCODE_4 = 52,
129 KEYCODE_5 = 53,
130 KEYCODE_6 = 54,
131 KEYCODE_7 = 55,
132 KEYCODE_8 = 56,
133 KEYCODE_9 = 57,
134 KEYCODE_DEL = 127
135 };
136
137 ARCSeventlog& ARCSlog;
138 ARCSassert& ARCSast;
139 ARCSprint& ARCSprt;
140 ARCSscrparams& ScrPara;
141 ARCSgraphics& Graph;
142
143 enum PhaseStatus CommandStatus;
144 enum PhaseStatus ActualStatus;
145 int CmdPosition;
146 int SetVarPosition;
147 bool SetVarNowTyping;
148 std::string SetVarStrBuffer;
149 pthread_t CommandThreadID;
150 pthread_t DisplayThreadID;
151 pthread_t EmergencyThreadID;
152 pthread_t GraphThreadID;
153 WINDOW* MainScreen;
154 int VERTICAL_MAX;
155 int HORIZONTAL_MAX;
156 RingBuffer<std::string, EVLOG_NUM> EventLogLines;
157 RingBuffer<std::string, DBPRNT_NUM> DebugPrintLines;
158 std::array<uint64_t, DBINDC_NUM> DebugIndicator;
159 std::string EventLogSpace;
160 std::string DebugPrintSpace;
161 pthread_mutex_t SyncMutex;
162 pthread_cond_t SyncCond;
163 pthread_mutex_t DbIdcMutex;
164 pthread_mutex_t SetVarMutex;
165
166 static void CommandThread(ARCSscreen* const p);
167 static void DisplayThread(ARCSscreen* const p);
168 static void EmergencyThread(ARCSscreen* const p);
169 static void GraphThread(ARCSscreen* const p);
170 void OnlineSetVarSelect(void);
171 void OnlineSetVarKeyInput(void);
172 void DispMessage(void);
173 void DispButtons(void);
174 void DispBaseScreen(void);
175 void DispParameters(void);
176 void DispEventLog(void);
177 void DispDebugPrint(void);
178 void DispDebugIndicator(void);
179 void DispEmergencyWindow(void);
180 void DispOnlineSetVarCursor(void);
181 void AddHLine(int X1, int X2, int Y);
182 void AddVLine(int Y1, int Y2, int X);
183 void ShowStatusIndic(
184 const int y, const int x, const double Iref, const double Irat, const double Imax
185 );
186 void ShowOperationIndic(const bool SW);
187 void ShowStorageIndic(const bool SW);
188 void ShowNetLinkIndic(const bool SW);
189 void ShowInitIndic(const bool SW);
190 void ShowStartButton(const enum ARCSbutton command);
191 void ShowExitButton(const enum ARCSbutton command);
192 void ShowSetVarButton(const enum ARCSbutton command);
193 void ShowStopButton(const enum ARCSbutton command);
194 void ShowRestartButton(const enum ARCSbutton command);
195 void ShowDiscExitButton(const enum ARCSbutton command);
196 void ShowSaveExitButton(const enum ARCSbutton command);
197 void ShowMessageText(const std::string& Text, const int color);
198 void ShowEmergencyWindow(void);
199 enum ARCSkeycode GetKey(void);
200};
201}
202
203#endif
204
実験装置用定数値格納用クラス ARCSに必要な実験装置に特有な定数値を格納します。
定数値格納用クラス ARCSに必要な定数値を格納します。
ARCS用ASSERTクラス
Definition ARCSassert.hh:21
ARCS イベントログクラス
Definition ARCSeventlog.hh:32
グラフィッククラス
Definition ARCSgraphics.hh:23
ARCS printライブラリ
Definition ARCSprint.hh:35
ARCS画面描画クラス
Definition ARCSscreen.hh:32
void WriteDebugPrintBuffer(const std::string &PrintText)
デバッグプリントバッファに書き込む関数
Definition ARCSscreen.cc:153
PhaseStatus
フェーズ状態定義
Definition ARCSscreen.hh:38
@ PHAS_EXIT
2 = 終了
Definition ARCSscreen.hh:41
@ PHAS_START
1 = 開始
Definition ARCSscreen.hh:40
@ PHAS_RESTART
5 = 再開始
Definition ARCSscreen.hh:44
@ PHAS_DISCEXIT
6 = 破棄して終了
Definition ARCSscreen.hh:45
@ PHAS_EMEREXIT
8 = 緊急終了
Definition ARCSscreen.hh:47
@ PHAS_INIT
0 = 初期
Definition ARCSscreen.hh:39
@ PHAS_STOP
4 = 停止
Definition ARCSscreen.hh:43
@ PHAS_SAVEEXIT
7 = 保存して終了
Definition ARCSscreen.hh:46
@ PHAS_SETVAR
3 = 変数設定
Definition ARCSscreen.hh:42
@ PHAS_NONE
9 = 状態無し
Definition ARCSscreen.hh:48
ARCSscreen(ARCSeventlog &EvLog, ARCSassert &Asrt, ARCSprint &Prnt, ARCSscrparams &Scrp, ARCSgraphics &Grph)
画面描画の初期化と準備を行う
Definition ARCSscreen.cc:30
~ARCSscreen()
RCS画面表示の消去
Definition ARCSscreen.cc:117
void WriteEventLogBuffer(const std::string &LogText)
イベントログバッファに書き込む関数
Definition ARCSscreen.cc:146
enum PhaseStatus WaitDiscOrSaveExit(void)
破棄して終了or保存して終了指令入力を待機する関数(ブロッキング)
Definition ARCSscreen.cc:221
enum PhaseStatus GetCmdStatus(void) const
指令状態を返す関数
Definition ARCSscreen.cc:140
void WriteDebugIndicator(const uint64_t u, const unsigned int i)
デバッグインジケータバッファに書き込む関数
Definition ARCSscreen.cc:161
enum PhaseStatus WaitRestartOrDiscOrSaveExit(void)
再開始 or 破棄して終了 or 保存して終了指令入力を待機する関数(ブロッキング)
Definition ARCSscreen.cc:244
enum PhaseStatus WaitStartOrExit(void)
開始or終了指令入力を待機する関数(ブロッキング)
Definition ARCSscreen.cc:169
void WaitStop(void)
停止指令入力を待機する関数(ブロッキング)
Definition ARCSscreen.cc:195
ARCS画面パラメータ格納クラス
Definition ARCSscrparams.hh:22
static constexpr int SCR_VERTICAL_MAX
[文字] 画面の最大高さ文字数
Definition EquipParams.hh:26
static constexpr int SCR_HORIZONTAL_MAX
[文字] 画面の最大幅文字数
Definition EquipParams.hh:27