コード例 #1
0
ファイル: sscedemo.c プロジェクト: jimmccurdy/ArchiveGit
// Display the result from SSCE_CheckBlock or SSCE_CheckWord.
static void displayCheckResult(HWND win, const char *funcName,
  SSCE_S16 result) {
	if (result <= 0) {
		displayResult(win, funcName, result);
	}
	else {
		int i;
		char msg[256];

		wsprintf(msg, "%s returned:", funcName);
		appendMsg(win, msg);
		for (i = 0; i < sizeof(checkResults) / sizeof(checkResults[0]); ++i) {
			if ((checkResults[i].mask & result) != 0) {
				appendMsg(win, checkResults[i].name);
			}
		}
	}
}
コード例 #2
0
ファイル: sscedemo.c プロジェクト: jimmccurdy/ArchiveGit
// Display the result from an SSCE function.
static void displayResult(HWND win, const char *funcName, SSCE_S16 rv) {
	char msg[256];

	if (rv < 0) {
		wsprintf(msg, "%s returned %s", funcName, errorNames[-rv]);
	}
	else {
		wsprintf(msg, "%s returned %hd", funcName, rv);
	}
	appendMsg(win, msg);
}
コード例 #3
0
ファイル: sscedemo.c プロジェクト: jimmccurdy/ArchiveGit
// Respond to a WM_SHOWWINDOW message.
static void onShowWindow(HWND win, BOOL fShow, UINT status) {
	static BOOL firstTime = TRUE;

	if (firstTime) {
		int i;

		// Fill the function list with names.
		for (i = 0; i < sizeof(functions) / sizeof(functions[0]); ++i) {
			int idx;

			idx = ListBox_AddString(GetDlgItem(win, IDC_FUNCTION_LST),
			  functions[i].name);
			ListBox_SetItemData(GetDlgItem(win, IDC_FUNCTION_LST), idx,
			  functions[i].id);
		}
		ListBox_SetCurSel(GetDlgItem(win, IDC_FUNCTION_LST), 0);
		onFunctionListSelChange(win);

		appendMsg(win, "IMPORTANT! Be sure to invoke SSCE_SetKey with your Sentry license");
		appendMsg(win, "key, provided by Wintertree Software. Enter the key in hexadecimal");
		appendMsg(win, "like this: 0x1234ABCD");
		appendMsg(win, "The demo will not run without a valid key!");
	}
}
Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);

    /*******************************/
    QTextCodec::setCodecForTr(QTextCodec::codecForName("GBK")); //当QString变量中含有中文时,需要增加这两行代码
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));

    // 【注意】顺序:先有masterProgramInstance,才能连接信号槽

    MasterProgram::getMasterProgramInstance();

    connect(MasterProgram::getMasterProgramInstance(),
            SIGNAL(signalMsgToGUI(QString)), this, SLOT(appendMsg(QString)));
    connect(MasterProgram::getMasterProgramInstance(),
            SIGNAL(signalErrorToGUI(QString)), this, SLOT(appendError(QString)));

    // connect函数必在MasterProgram::getMasterProgramInstance()之后

    MasterProgram::getMasterProgramInstance()->init();

    // 【已经作废】
    // 【注意】顺序:先有masterProgramInstance,才run,能连接信号槽
    //MasterProgram::getMasterProgramInstance()->run();
    /*******************************/
    connect(MasterProgram::getMasterProgramInstance(),
            SIGNAL(signalToLights(HardwareType, QString, HardwareStatus)), this, SLOT(changeHardwareStatus(HardwareType, QString, HardwareStatus)));

    ui->slave1Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave2Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave3Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave4Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave5Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave6Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave7Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->slave8Label_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
    ui->backupLabel_net->setPixmap(QString::fromUtf8(":image//lightred.png"));
}
Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);

    copywidget = NULL;

    /*******************************/

    // 【注意】顺序:先有masterProgramInstance,才能连接信号槽
    ServerProgram::getServerProgramInstance();

    connect(ServerProgram::getServerProgramInstance(),
            SIGNAL(signalMsgToGUI(QString)), this, SLOT(appendMsg(QString)));
    connect(ServerProgram::getServerProgramInstance(),
            SIGNAL(signalErrorToGUI(QString)), this, SLOT(appendError(QString)));

    // connect函数必在ServerProgram::getServerProgramInstance()之后

    ServerProgram::getServerProgramInstance()->init();

    /*******************************/

    connect(ServerProgram::getServerProgramInstance(), SIGNAL(updateEditingProjectListSignal()), this, SLOT(updateEditingProjectListView()));
    connect(ServerProgram::getServerProgramInstance(), SIGNAL(updateIPListSignal(QString, bool)), this, SLOT(updateIPListView(QString, bool)));

    // 桌面系统图标相关,防止误操作关闭,可后台运行
    createActions();
    createTrayIcon();

    setIcon();
    connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    trayIcon->show();

    // 默认发送的clientip地址
    toclientip = "10.13.29.34";

    iplistmodel = new QStringListModel(this);
    ui->iplistView->setModel(iplistmodel);

    editinglistmodel = new QStringListModel(this);
    ui->editingProjectListView->setModel(editinglistmodel);

    // 测试按钮不可见
    ui->pushButton->setVisible(false);
    ui->pushButton_2->setVisible(false);
    ui->pushButton_3->setVisible(false);
    ui->pushButton_4->setVisible(false);
    ui->pushButton_5->setVisible(false);
    ui->pushButton_6->setVisible(false);
    ui->pushButton_7->setVisible(false);

    connect(ui->saveProjDataButton, SIGNAL(clicked()), this, SLOT(saveProjData()));
    connect(ui->resetSlaveProgramButton, SIGNAL(clicked()), this, SLOT(resetSlaveProgram()));
    connect(ui->terminateSlaveProgramButton, SIGNAL(clicked()), this, SLOT(terminateSlaveProgram()));
    connect(ui->shutdownAllButton, SIGNAL(clicked()), this, SLOT(shotdownALlSlaves()));
    connect(ui->updateSlaveExeFileButton, SIGNAL(clicked()), this, SLOT(updateSlaveExeFile()));
}
コード例 #6
0
ファイル: simpleterminal.cpp プロジェクト: wgraba/yaTerm
//**********************************************************************************************************************
void SimpleTerminal::modifyDspText(DspType type, const QString &text)
{
    // Format text according to type of message
    static DspType last_type = DspType::NONE;

    // Need to end the last message?
    if (last_type != type && _is_msg_open)
        emit endMsg();

    switch(type)
    {
        case DspType::READ_MESSAGE:
        {
            static QString prev_msg("");

            // Parse message and look for EOM string(s) - there could be 0 - n in this message
            // Emit approriate details to system - end of message? Start of message? Append message?
            QString msg(text.toHtmlEscaped());

            // Find all occurences of EOM
            int start_pos = 0;
            int eom_pos = 0;
            do
            {
                QString shared_msg(prev_msg + msg);
                eom_pos = shared_msg.indexOf(_eom, start_pos);
                if (eom_pos >= 0)
                {
                    // Found EOM!
                    if (!_is_msg_open)
                        emit startMsg();

                    if (eom_pos < prev_msg.length())
                        // Found EOM start before start of actual message; need to correct start position
                        // to be first character after previous message
                        start_pos += prev_msg.length();

                    int len = (eom_pos + _eom.length()) - start_pos;

                    emit appendMsg(shared_msg.mid(start_pos, len));
                    emit endMsg();

                    start_pos = eom_pos + _eom.length();
                }
                else if (start_pos < shared_msg.length())
                {
                    // No EOMs left; send rest of message
                    if (!_is_msg_open)
                        emit startMsg();

                    emit appendMsg(shared_msg.mid(start_pos));
                }
            } while(eom_pos >= 0);

            // Keep end of msg for next time
            if (_eom.length() > 0)
            {
                int num_prev_msg_keep = _eom.length() - msg.length();
                if (num_prev_msg_keep > 0)
                    prev_msg = prev_msg.right(num_prev_msg_keep) + msg;

                else
                    prev_msg = msg.right(_eom.length() - 1);
            }
            else
                prev_msg = "";

            break;
        }

        case DspType::WRITE_MESSAGE:
        {
            QString msg = "<span><b>" + text.toHtmlEscaped() + "</b></span>";
            emit newMsg(msg);

            break;
        }

        case DspType::COMMAND:
        {
            QString msg = "<span style = \"color: blue;\"><b>$ " + text.toHtmlEscaped() + "</b></span>";
            emit newMsg(msg);

            break;
        }

        case DspType::COMMAND_RSP:
        {
            QString msg = "<span style = \"color: green;\">" + text + "</span>";
            emit newMsg(msg);

            break;
        }

        case DspType::ERROR:
        {
            QString msg = "<span style = \"color: red;\">ERROR: " + text + "</span>";
            emit newMsg(msg);

            break;
        }

        default:
            break;
    }

    last_type = type;
}
コード例 #7
0
ファイル: sscedemo.c プロジェクト: jimmccurdy/ArchiveGit
// Respond to an Invoke button press
static void onInvokeBtn(HWND win) {
	int idx = ListBox_GetCurSel(GetDlgItem(win, IDC_FUNCTION_LST));
	int id;
	int i;
	char str[256];
	char path[MAX_PATH];
	SSCE_S16 s16, s16_1, s16_2, s16_3;
	SSCE_S32 s32, s32_1, s32_2, s32_3, s32_4;
	SSCE_CHAR word[SSCE_MAX_WORD_SZ];
	SSCE_CHAR otherWord[SSCE_MAX_WORD_SZ];
	SSCE_CHAR *bfr;
	SSCE_CHAR *p;
	const char *fmt, *lang;
	SSCE_S16 scores[16];

	if (LB_ERR == idx) {
		return;
	}

	id = (int)ListBox_GetItemData(GetDlgItem(win, IDC_FUNCTION_LST), idx);

	// Invoke the selected function.
	switch (id) {
	case AddToLex:
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		GetDlgItemText(win, IDC_PARAM3_EDT, otherWord, sizeof(otherWord));
		s16 = SSCE_AddToLex(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT), word,
		  getS16(win, IDC_PARAM2_EDT), otherWord);
		displayResult(win, "SSCE_AddToLex", s16);
		break;
	case CheckBlock:
		s16 = SSCE_CheckBlock(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), word, sizeof(word),
		  otherWord, sizeof(otherWord));
		displayCheckResult(win, "SSCE_CheckBlock", s16);
		if (s16 >= 0) {
			wsprintf(str, "errWord: %s; otherWord: %s", word, otherWord);
		}
		appendMsg(win, str);
		break;
	case CheckBlockDlg:
		s32_1 = getS32(win, IDC_PARAM1_EDT);
		bfr = (SSCE_CHAR *)malloc((size_t)s32_1);
		GetDlgItemText(win, IDC_TEXT_EDT, bfr, (int)s32_1);
		s32 = SSCE_CheckBlockDlg(win, bfr, strlen(bfr), s32_1,
		  getS16(win, IDC_PARAM2_EDT));
		wsprintf(str, "SSCE_CheckBlockDlg returned %ld", s32);
		appendMsg(win, str);
		if (s32 >= 0) {
			SetDlgItemText(win, IDC_TEXT_EDT, bfr);
		}
		free(bfr);
		break;
	case CheckCtrlDlg:
		s16 = SSCE_CheckCtrlDlg(win, GetDlgItem(win, IDC_TEXT_EDT),
		  getS16(win, IDC_PARAM1_EDT));
		displayResult(win, "SSCE_CheckCtrlDlg", s16);
		break;
	case CheckWord:
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		s16 = SSCE_CheckWord(getS16(win, IDC_SESSION_ID_EDT),
		  word, otherWord, sizeof(otherWord));
		displayCheckResult(win, "SSCE_CheckWord", s16);
		if (s16 >= 0) {
			wsprintf(str, "otherWord: %s", otherWord);
		}
		appendMsg(win, str);
		break;
	case ClearLex:
		s16 = SSCE_ClearLex(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT));
		displayResult(win, "SSCE_ClearLex", s16);
		break;
	case CloseBlock:
		s16 = SSCE_CloseBlock(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT));
		displayResult(win, "SSCE_CloseBlock", s16);
		break;
	case CloseLex:
		s16 = SSCE_CloseLex(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT));
		displayResult(win, "SSCE_CloseLex", s16);
		break;
	case CloseSession:
		s16 = SSCE_CloseSession(getS16(win, IDC_SESSION_ID_EDT));
		displayResult(win, "SSCE_CloseSession", s16);
		break;
	case CreateLex:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_CreateLex(getS16(win, IDC_SESSION_ID_EDT),
		  path, getS16(win, IDC_PARAM2_EDT));
		if (s16 >= 0) {
			wsprintf(str, "%hd", s16);
			SetDlgItemText(win, IDC_LEXICON_ID_EDT, str);
		}
		wsprintf(str, "SSCE_CreateLex(%s) returned %hd", path, s16);
		appendMsg(win, str);
		break;
	case DelBlockText:
		s16 = SSCE_DelBlockText(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), getS32(win, IDC_PARAM1_EDT));
		displayResult(win, "SSCE_DelBlockText", s16);
		break;
	case DelBlockWord:
		s32 = SSCE_DelBlockWord(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), word, sizeof(word));
		wsprintf(str, "SSCE_DelBlockWord returned %ld; deleted text = %s",
		  s32, word);
		appendMsg(win, str);
		break;
	case DelFromLex:
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		s16 = SSCE_DelFromLex(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT), word);
		displayResult(win, "SSCE_DelFromLex", s16);
		break;
	case EditLexDlg:
		s16 = SSCE_EditLexDlg(win);
		displayResult(win, "SSCE_EditLexDlg", s16);
		break;
	case FindLexWord:
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		s16 = SSCE_FindLexWord(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT), word, otherWord, sizeof(otherWord));
		if (s16 < 0) {
			displayResult(win, "SSCE_FindLexWord", s16);
		}
		else {
			int i;
			const char *actionName = "(unknown)";

			for (i = 0; i < sizeof(actions) / sizeof(actions[0]); ++i) {
				if (actions[i].action == s16) {
					actionName = actions[i].name;
					break;
				}
			}
			wsprintf(str, "SSCE_FindLexWord returned %s", actionName);
			appendMsg(win, str);
			if (otherWord[0] != '\0') {
				wsprintf(str, "otherWord: %s", otherWord);
				appendMsg(win, str);
			}
		}
		break;
	case GetAutoCorrect:
		s16 = SSCE_GetAutoCorrect();
		displayResult(win, "SSCE_GetAutoCorrect", s16);
		break;
	case GetBlock:
		s16 = SSCE_GetBlockInfo(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), &s32_1, NULL, NULL, NULL);
		if (s16 < 0) {
			displayResult(win, "SSCE_GetBlockInfo", s16);
			break;
		}
		bfr = (SSCE_CHAR *)malloc((size_t)s32_1 + 1);
		if (NULL == bfr) {
			appendMsg(win, "Out of memory");
			break;
		}
		s16 = (SSCE_S16)SSCE_GetBlock(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), bfr, s32_1 + 1);
		bfr[s32_1] = '\0';
		displayResult(win, "SSCE_GetBlock", s16);
		appendMsg(win, "Block contents:");
		appendMsg(win, bfr);
		free(bfr);
		break;
	case GetBlockInfo:
		s16 = SSCE_GetBlockInfo(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), &s32_1, &s32_2, &s32_3, &s32_4);
		displayResult(win, "SSCE_GetBlockInfo", s16);
		wsprintf(str,
		  "textLen = %ld; blkSz = %ld; curPos = %ld; wordCount = %ld",
		  s32_1, s32_2, s32_3, s32_4);
		appendMsg(win, str);
		break;
	case GetBlockWord:
		s16 = SSCE_GetBlockWord(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), word, sizeof(word));
		displayResult(win, "SSCE_GetBlockWord", s16);
		wsprintf(str, "word: %s", word);
		appendMsg(win, str);
		break;
	case GetHelpFile:
		SSCE_GetHelpFile(path, sizeof(path));
		wsprintf(str, "help file: %s", path);
		appendMsg(win, str);
		break;
	case GetLex:
		s16 = SSCE_GetLexInfo(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT), &s32_1, NULL, NULL);
		if (s16 < 0) {
			displayResult(win, "SSCE_GetLexInfo", s16);
			break;
		}
		bfr = (SSCE_CHAR *)malloc((size_t)s32_1);
		if (NULL == bfr) {
			appendMsg(win, "Out of memory");
			break;
		}
		s32 = SSCE_GetLex(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT), bfr, s32_1);
		wsprintf(str, "SSCE_GetLex returned %ld", s32);
		appendMsg(win, str);
		for (p = bfr; *p != '\0'; p += strlen(p) + 1) {
			appendMsg(win, p);
		}
		free(bfr);
		break;
	case GetLexId:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_GetLexId(path);
		displayResult(win, "SSCE_GetLexId", s16);
		break;
	case GetLexInfo:
		s16 = SSCE_GetLexInfo(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_LEXICON_ID_EDT), &s32_1, &s16_2, &s16_3);
		displayResult(win, "SSCE_GetLexInfo", s16);
		fmt = "(unknown)";
		for (i = 0; i < sizeof(lexFormats) / sizeof(lexFormats[0]); ++i) {
			if (lexFormats[i].format == s16_2) {
				fmt = lexFormats[i].name;
				break;
			}
		}
		lang = "(unknown)";
		for (i = 0; i < sizeof(languages) / sizeof(languages[0]); ++i) {
			if (languages[i].lang == s16_3) {
				lang = languages[i].name;
				break;
			}
		}
		wsprintf(str, "size = %ld; format = %s; language = %s", s32_1,
		  fmt, lang);
		appendMsg(win, str);
		break;
	case GetMainLexFiles:
		SSCE_GetMainLexFiles(path, sizeof(path));
		wsprintf(str, "MainLexFiles: %s", path);
		appendMsg(win, str);
		break;
	case GetMainLexPath:
		SSCE_GetMainLexPath(path, sizeof(path));
		wsprintf(str, "MainLexPath: %s", path);
		appendMsg(win, str);
		break;
	case GetMinSuggestDepth:
		s16 = SSCE_GetMinSuggestDepth();
		displayResult(win, "SSCE_GetMinSuggestDepth", s16);
		break;
	case GetOption:
		s32 = (SSCE_S32)SSCE_GetOption(getS16(win, IDC_SESSION_ID_EDT),
		  (SSCE_U32)getS32(win, IDC_PARAM1_EDT));
		if (s32 < 0) {
			displayResult(win, "SSCE_GetOption", (SSCE_S16)s32);
		}
		else {
			wsprintf(str, "SSCE_GetOption returned %ld", s32);
			appendMsg(win, str);
		}
		break;
	case GetRegTreeName:
		SSCE_GetRegTreeName(path, sizeof(path));
		wsprintf(str, "RegTreeName: %s", path);
		appendMsg(win, str);
		break;
	case GetSid:
		s16 = SSCE_GetSid();
		displayResult(win, "SSCE_GetSid", s16);
		if (s16 >= 0) {
			wsprintf(str, "%hd", s16);
			SetDlgItemText(win, IDC_SESSION_ID_EDT, str);
		}
		break;
	case GetStatistics:
		SSCE_GetStatistics((SSCE_U32 *)&s32_1, (SSCE_U32 *)&s32_2,
		  (SSCE_U32 *)&s32_3);
		wsprintf(str,
		  "wordsChecked = %lu; wordsChanged = %lu; errorsDetected = %lu",
		  s32_1, s32_2, s32_3);
		appendMsg(win, str);
		break;
	case GetStringTableName:
		SSCE_GetStringTableName(path, sizeof(path));
		wsprintf(str, "StringTableName: %s", path);
		appendMsg(win, str);
		break;
	case GetUserLexFiles:
		SSCE_GetUserLexFiles(path, sizeof(path));
		wsprintf(str, "UserLexFiles: %s", path);
		appendMsg(win, str);
		break;
	case GetUserLexPath:
		SSCE_GetUserLexPath(path, sizeof(path));
		wsprintf(str, "UserLexPath: %s", path);
		appendMsg(win, str);
		break;
	case InsertBlockText:
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		s16 = SSCE_InsertBlockText(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), word);
		displayResult(win, "SSCE_InsertBlockText", s16);
		break;
	case NextBlockWord:
		s16 = SSCE_NextBlockWord(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT));
		displayResult(win, "SSCE_NextBlockWord", s16);
		break;
	case OpenBlock:
		s32_1 = getS32(win, IDC_PARAM1_EDT);
		bfr = (SSCE_CHAR *)malloc((size_t)s32_1);
		if (NULL == bfr) {
			appendMsg(win, "Out of memory");
			break;
		}
		GetDlgItemText(win, IDC_TEXT_EDT, bfr, (int)s32_1);
		s16 = SSCE_OpenBlock(getS16(win, IDC_SESSION_ID_EDT),
		  bfr, strlen(bfr), s32_1, TRUE);
		if (s16 >= 0) {
			wsprintf(str, "%hd", s16);
			SetDlgItemText(win, IDC_BLOCK_ID_EDT, str);
		}
		displayResult(win, "SSCE_OpenBlock", s16);
		free(bfr);
		break;
	case OpenLex:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_OpenLex(getS16(win, IDC_SESSION_ID_EDT),
		  path, getS32(win, IDC_PARAM2_EDT));
		if (s16 >= 0) {
			wsprintf(str, "%hd", s16);
			SetDlgItemText(win, IDC_LEXICON_ID_EDT, str);
		}
		wsprintf(str, "SSCE_OpenLex(%s) returned %hd", path, s16);
		appendMsg(win, str);
		break;
	case OpenSession:
		s16 = SSCE_OpenSession();
		if (s16 >= 0) {
			wsprintf(str, "%hd", s16);
			SetDlgItemText(win, IDC_SESSION_ID_EDT, str);
		}
		displayResult(win, "SSCE_OpenSession", s16);
		break;
	case OptionsDlg:
		s16 = SSCE_OptionsDlg(win);
		displayResult(win, "SSCE_OptionsDlg", s16);
		break;
	case ReplaceBlockWord:
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		s16 = SSCE_ReplaceBlockWord(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), word);
		displayResult(win, "SSCE_ReplaceBlockWord", s16);
		break;
	case ResetLex:
		s16 = SSCE_ResetLex();
		displayResult(win, "SSCE_ResetLex", s16);
		break;
	case SetAutoCorrect:
		s16 = SSCE_SetAutoCorrect(getS16(win, IDC_PARAM1_EDT));
		displayResult(win, "SSCE_SetAutoCorrect", s16);
		break;
	case SetBlockCursor:
		s16 = SSCE_SetBlockCursor(getS16(win, IDC_SESSION_ID_EDT),
		  getS16(win, IDC_BLOCK_ID_EDT), getS32(win, IDC_PARAM1_EDT));
		displayResult(win, "SSCE_SetBlockCursor", s16);
		break;
	case SetDebugFile:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		SSCE_SetDebugFile(path);
		wsprintf(str, "Diagnostic file set to %s", path);
		break;
	case SetDialogOrigin:
		SSCE_SetDialogOrigin(getS16(win, IDC_PARAM1_EDT),
		  getS16(win, IDC_PARAM2_EDT));
		appendMsg(win, "Dialog origin set");
		break;
	case SetHelpFile:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetHelpFile(path);
		displayResult(win, "SSCE_SetHelpFile", s16);
		break;
	case SetIniFile:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetIniFile(path);
		displayResult(win, "SSCE_SetIniFile", s16);
		break;
	case SetKey:
		s32 = SSCE_SetKey(getU32(win, IDC_PARAM1_EDT));
		wsprintf(str, "SSCE_SetKey returned %ld", s32);
		appendMsg(win, str);
		break;
	case SetMainLexFiles:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetMainLexFiles(path);
		displayResult(win, "SSCE_SetMainLexFiles", s16);
		break;
	case SetMainLexPath:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetMainLexPath(path);
		displayResult(win, "SSCE_SetMainLexPath", s16);
		break;
	case SetMinSuggestDepth:
		s16 = SSCE_SetMinSuggestDepth(getS16(win, IDC_PARAM1_EDT));
		displayResult(win, "SSCE_SetMinSuggestDepth", s16);
		break;
	case SetOption:
		s32 = (SSCE_S32)SSCE_SetOption(getS16(win, IDC_SESSION_ID_EDT),
		  (SSCE_U32)getS32(win, IDC_PARAM1_EDT),
		  (SSCE_U32)getS32(win, IDC_PARAM2_EDT));
		wsprintf(str, "SSCE_SetOption returned %ld", s32);
		appendMsg(win, str);
		break;
	case SetRegTreeName:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetRegTreeName(path);
		displayResult(win, "SSCE_SetRegTreeName", s16);
		break;
	case SetStringTableName:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetStringTableName(path);
		displayResult(win, "SSCE_SetStringTableName", s16);
		break;
	case SetUserLexFiles:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetUserLexFiles(path);
		displayResult(win, "SSCE_SetUserLexFiles", s16);
		break;
	case SetUserLexPath:
		GetDlgItemText(win, IDC_PARAM1_EDT, path, sizeof(path));
		s16 = SSCE_SetUserLexPath(path);
		displayResult(win, "SSCE_SetUserLexPath", s16);
		break;
	case Suggest:
		s16_1 = SSCE_MAX_WORD_SZ * 16;
		bfr = (SSCE_CHAR *)malloc((size_t)s16_1);
		if (NULL == bfr) {
			appendMsg(win, "Out of memory");
			break;
		}
		GetDlgItemText(win, IDC_PARAM1_EDT, word, sizeof(word));
		s16 = SSCE_Suggest(getS16(win, IDC_SESSION_ID_EDT),
		  word, getS16(win, IDC_PARAM2_EDT), bfr, (SSCE_S32)s16_1,
		  scores, sizeof(scores) / sizeof(scores[0]));
		displayResult(win, "SSCE_Suggest", s16);
		if (s16 >= 0) {
			for (p = bfr, i = 0; *p != '\0'; p += strlen(p) + 1, ++i) {
				wsprintf(str, "%s [%hd]", p, scores[i]);
				appendMsg(win, str);
			}
		}
		free(bfr);
		break;
	case Version:
		SSCE_Version(word, sizeof(word));
		wsprintf(str, "Version: %s", word);
		appendMsg(win, str);
		break;
	}
}
/**
 * 构造函数传入WorkingStatus status初始化界面
 * @param newsinglewidgetapp 是否为单一界面程序(采集程序有可能为单一界面程序,其结束方式与复界面程序不用) @see closeEvent方法
 * @param status 工作状态,@see status.h
 * Collecting = 1 采集时
 * Calculating_Backuping = 5 计算备份同时进行
 */
MainWidget::MainWidget(bool newsinglewidgetapp, WorkingStatus initstatus, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainWidget)
{
    ui->setupUi(this);

    // 初始化结束方式
    singlewidgetapp = newsinglewidgetapp;

    // 初始化工作状态
    workingstatus = initstatus;

    // 初始时采集工程文件名为空
    projectfilename = "";

    // 默认用户不知道是谁
    currentusername = "******";

    // 在主界面连接主控底层服务信号槽
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(makeGUIActive(WorkingStatus, bool)), this, SLOT(msgToGUICreateProjectWidget(WorkingStatus, bool)));
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalMsgToGUI(WorkingStatus, QString)), this, SLOT(appendMsg(WorkingStatus, QString)));
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalErrorToGUI(WorkingStatus, QString)), this, SLOT(appendError(WorkingStatus, QString)));
    // [采集转发消息]
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalToLights(HardwareType, QString, HardwareStatus)), this, SLOT(changeHardwareStatus(HardwareType, QString, HardwareStatus)));
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalToCameraFC(QString, qint64)), this, SLOT(changeCameraFC_slot(QString, qint64)));
    // [采集、计算、备份转发消息]
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalToCameraTask(WorkingStatus, QString, int, QString, QString)), this, SLOT(changeSlaveCameraTask_slot(WorkingStatus, QString, int, QString, QString)));
    // [计算转发消息]
    // 每个从控每个线程每个任务帧号反馈消息转发
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalToCameraTaskFC(WorkingStatus, QString, int, QString, long long)), this, SLOT(changeSlaveCameraTaskFC_slot(WorkingStatus, QString, int, QString, long long)));
    // 每个从控每个线程每个任务初始化界面(起始帧、终止帧)消息转发
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(signalToSlaveCameraTaskFC_init(WorkingStatus, QString, int, QString, long long, long long)), this, SLOT(changeSlaveCameraTaskFC_init_slot(WorkingStatus, QString, int, QString, long long, long long)));
    // [计算备份转发消息]
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(calcubackupProgressingBar(WorkingStatus, QString, int, int, int, bool)), this, SLOT(changecalcubackupProgressingBar_slot(WorkingStatus, QString, int, int, int, bool)));
    
    connect(MasterProgram::getMasterProgramInstance(), SIGNAL(turnOffAllHardware()), this, SLOT(turnOffLights()));
    //connect(MasterProgram::getMasterProgramInstance(), SIGNAL(makeGUIActive(bool)), this, SLOT(getCalcuBackupGUIActive(bool)));

    // 重启服务器按钮信号槽
    connect(ui->restartServerButton, SIGNAL(clicked()), this, SLOT(restartServer()));
    // 关闭服务器
    connect(ui->closeServerButton, SIGNAL(clicked()), this, SLOT(closeServer()));
 
    // 初始时关闭所有提示灯
    turnOffLights();
    // 开启网络连接从控计算机提示灯
    initConnectedSlaves();

    /******设置采集机、备份机、相机的状态,正常或者不正常**********/
    //   statuscollectmessage为从控机发送过来的采集机和备份机的状态信息,如0表示正常,则显示为黄色,1表示异常,则显示为红色。
    //     if 采集机异常
    //     ui->slave1Label_net->setPixmap(QPixmap(":/image/lightred.png"));

    this->setWindowTitle(QObject::tr("铁路隧道建筑限界测量系统-主控终端"));
    QIcon icon;
    icon.addFile(QString::fromUtf8(":image/icon.png"), QSize(), QIcon::Normal, QIcon::Off);
    this->setWindowIcon(icon);

    // 功能,设置小图标变灰
    ui->collectstatuslabel->setPixmap(QString::fromUtf8(":image//collectstatus1_2.png"));
    ui->backupstatuslabel->setPixmap(QString::fromUtf8(":image//up_alt_2.png"));
    ui->calculatestatuslabel->setPixmap(QString::fromUtf8(":image//Calculatorstatus1_2.png"));

    // 导入已有工程、创建新工程界面
    CreateProjectWidget * cpwidget = new CreateProjectWidget(workingstatus, ui->createprojwidget);
    connect(cpwidget, SIGNAL(sendproject_file_name(QString)), this, SLOT(slotprojectfilename(QString)));
    connect(this, SIGNAL(setCreateProjectWidgetEnabled(bool)), cpwidget, SLOT(setWidgetEnabled(bool)));

    // @author 范翔 3个界面合二为一之后,关闭重启服务器两个按钮无效
    ui->closeServerButton->setVisible(false);
    ui->restartServerButton->setVisible(false);

    if (workingstatus == Collecting)
    {        
        // Tab界面布局
        // ui->gridLayout_5是整个Window的最外层布局Layout。可从.ui文件中找出
        ui->gridLayout_5->addWidget(ui->page, 4, 0);
        CollectWidget * collectWidget = new CollectWidget(ui->page, MasterSetting::getSettingInstance()->getDefaultDistanceMode());

        QGridLayout *layout5 = new QGridLayout();
        layout5->addWidget(collectWidget);
        ui->page->setLayout(layout5);

        // 得到帧间隔里程
        connect(this, SIGNAL(sendproject_file_name(QString)), collectWidget,SLOT(getDistanceMode(QString)));

        // 界面信号槽
        connect(this, SIGNAL(changeCameraStatus(QString,HardwareStatus)), collectWidget, SLOT(changeCamera(QString, HardwareStatus)));
        connect(this, SIGNAL(changeLayserStatus(QString,HardwareStatus)), collectWidget, SLOT(changeLayser(QString, HardwareStatus)));
        connect(this, SIGNAL(changeCameraFC(QString,qint64)), collectWidget, SLOT(changeCameraFC(QString, qint64)));
        connect(this, SIGNAL(changeSlaveCameraTask(WorkingStatus, QString, int, QString, QString)), collectWidget, SLOT(changeCameraTask(WorkingStatus, QString, int, QString, QString)));
        connect(this, SIGNAL(turnOffAllHardware()), collectWidget, SLOT(turnOffHardwares()), Qt::DirectConnection);

        collectWidget->turnOffHardwares();

        // 【标记1】此处作废
        // 因为有master的单一实例模式+各种对应方法,此处无需接受底层界面发送的消息了,因为底层界面可以直接调用各类主控方法
        //connect(calcuWidget,SIGNAL(clicked111()),this,SLOT(sendToMaster(QString)));

        // 可以导入已有、创建新工程
        connect(ui->operationConfigButton, SIGNAL(clicked()), this, SLOT(configCurrentOperation()));
        connect(ui->operationConfigButton2, SIGNAL(clicked()), this, SLOT(configCurrentOperation2()));

        // 初始时的界面显示
        ui->page->setVisible(true);

        // projectclass
        projectclass = LzProjectClass::Collect;
        projectclassstr = "collect";
    }