hlp:桂林国际齿轮泵代码

This commit is contained in:
kite_lucs
2026-10-09 10:25:24 +08:00
commit fd606b3c81
2447 changed files with 999531 additions and 0 deletions
@@ -0,0 +1,87 @@
/*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* File: $Id: mbframe.h,v 1.9 2006/12/07 22:10:34 wolti Exp $
*/
#ifndef _MB_FRAME_H
#define _MB_FRAME_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
#endif
/*!
* Constants which defines the format of a modbus frame. The example is
* shown for a Modbus RTU/ASCII frame. Note that the Modbus PDU is not
* dependent on the underlying transport.
*
* <code>
* <------------------------ MODBUS SERIAL LINE PDU (1) ------------------->
* <----------- MODBUS PDU (1') ---------------->
* +-----------+---------------+----------------------------+-------------+
* | Address | Function Code | Data | CRC/LRC |
* +-----------+---------------+----------------------------+-------------+
* | | | |
* (2) (3/2') (3') (4)
*
* (1) ... MB_SER_PDU_SIZE_MAX = 256
* (2) ... MB_SER_PDU_ADDR_OFF = 0
* (3) ... MB_SER_PDU_PDU_OFF = 1
* (4) ... MB_SER_PDU_SIZE_CRC = 2
*
* (1') ... MB_PDU_SIZE_MAX = 253
* (2') ... MB_PDU_FUNC_OFF = 0
* (3') ... MB_PDU_DATA_OFF = 1
* </code>
*/
/* ----------------------- Defines ------------------------------------------*/
#define MB_PDU_SIZE_MAX 253 /*!< Maximum size of a PDU. */
#define MB_PDU_SIZE_MIN 1 /*!< Function Code */
#define MB_PDU_FUNC_OFF 0 /*!< Offset of function code in PDU. */
#define MB_PDU_DATA_OFF 1 /*!< Offset for response data in PDU. */
/* ----------------------- Prototypes 0-------------------------------------*/
typedef void ( *pvMBFrameStart ) ( void );
typedef void ( *pvMBFrameStop ) ( void );
typedef eMBErrorCode( *peMBFrameReceive ) ( UCHAR * pucRcvAddress,
UCHAR ** pucFrame,
USHORT * pusLength );
typedef eMBErrorCode( *peMBFrameSend ) ( UCHAR slaveAddress,
const UCHAR * pucFrame,
USHORT usLength );
typedef void( *pvMBFrameClose ) ( void );
#ifdef __cplusplus
PR_END_EXTERN_C
#endif
#endif
@@ -0,0 +1,331 @@
/****************************************************************************
** Meta object code from reading C++ file 'PrintSetting.h'
**
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../PrintSetting.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'PrintSetting.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.5. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_PrintSetting[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
70, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
5, // signalCount
// signals: signature, parameters, type, tag, flags
14, 13, 13, 13, 0x05,
40, 35, 13, 13, 0x05,
57, 13, 13, 13, 0x05,
72, 13, 13, 13, 0x05,
98, 93, 13, 13, 0x05,
// slots: signature, parameters, type, tag, flags
124, 13, 13, 13, 0x0a,
162, 154, 13, 13, 0x08,
207, 13, 13, 13, 0x08,
229, 13, 13, 13, 0x08,
259, 13, 13, 13, 0x08,
279, 13, 13, 13, 0x08,
294, 13, 13, 13, 0x08,
331, 13, 13, 13, 0x08,
356, 35, 13, 13, 0x08,
376, 13, 13, 13, 0x08,
405, 13, 13, 13, 0x08,
446, 13, 13, 13, 0x08,
487, 13, 13, 13, 0x08,
523, 13, 13, 13, 0x08,
554, 13, 13, 13, 0x08,
585, 13, 13, 13, 0x08,
617, 13, 13, 13, 0x08,
646, 13, 13, 13, 0x08,
675, 13, 13, 13, 0x08,
719, 13, 13, 13, 0x08,
764, 13, 13, 13, 0x08,
797, 792, 13, 13, 0x08,
852, 13, 13, 13, 0x08,
908, 894, 13, 13, 0x08,
936, 894, 13, 13, 0x08,
964, 13, 13, 13, 0x08,
991, 13, 13, 13, 0x08,
1020, 13, 13, 13, 0x08,
1050, 13, 13, 13, 0x08,
1082, 13, 13, 13, 0x08,
1112, 13, 13, 13, 0x08,
1144, 154, 13, 13, 0x08,
1179, 154, 13, 13, 0x08,
1215, 13, 13, 13, 0x08,
1249, 13, 13, 13, 0x08,
1285, 13, 13, 13, 0x08,
1321, 13, 13, 13, 0x08,
1363, 1357, 13, 13, 0x08,
1416, 154, 13, 13, 0x08,
1448, 154, 13, 13, 0x08,
1479, 792, 13, 13, 0x08,
1518, 1357, 13, 13, 0x08,
1560, 13, 13, 13, 0x08,
1601, 1582, 13, 13, 0x08,
1636, 13, 13, 13, 0x08,
1659, 792, 13, 13, 0x08,
1696, 154, 13, 13, 0x08,
1738, 13, 13, 13, 0x08,
1768, 13, 13, 13, 0x08,
1801, 792, 13, 13, 0x08,
1842, 13, 13, 13, 0x08,
1871, 13, 13, 13, 0x08,
1902, 13, 13, 13, 0x08,
1933, 13, 13, 13, 0x08,
1966, 13, 13, 13, 0x08,
2007, 13, 13, 13, 0x08,
2047, 13, 13, 13, 0x08,
2086, 13, 13, 13, 0x08,
2117, 93, 13, 13, 0x08,
2140, 93, 13, 13, 0x08,
2163, 93, 13, 13, 0x08,
2186, 13, 13, 13, 0x08,
2212, 13, 13, 13, 0x08,
2238, 13, 13, 13, 0x08,
2273, 2269, 13, 13, 0x08,
0 // eod
};
static const char qt_meta_stringdata_PrintSetting[] = {
"PrintSetting\0\0HiddenFunction(bool)\0"
"auth\0authChanged(int)\0printPriveiw()\0"
"change_OutputPulse()\0flag\0"
"SwitchTimerShowItem(bool)\0"
"updateUIForSpecialCondition()\0checked\0"
"on_radioButtonSpecialCondition_clicked(bool)\0"
"refreshtimerHandler()\0"
"ondialogShowCounterAccepted()\0"
"on_checkVarLenChg()\0on_VarLenSet()\0"
"on_pushButtonRanddomBackUP_pressed()\0"
"PrintupdateSysParaToUI()\0showVolDacEdit(int)\0"
"on_pushButtonApply_pressed()\0"
"on_checkBoxResetCnt1CurrValue_released()\0"
"on_checkBoxResetCnt2CurrValue_released()\0"
"on_pushButtonClearRunTime_pressed()\0"
"on_pushOnlyCNT1Clear_pressed()\0"
"on_pushOnlyCNT2Clear_pressed()\0"
"ondialogAuthorizationAccepted()\0"
"ondialogAuthVarSetAccepted()\0"
"on_dialogModPasswdAccepted()\0"
"on_checkBoxSuspendAfterPhaseFault_clicked()\0"
"on_checkBoxPowerOffAfterPhaseFault_clicked()\0"
"on_pushButtonAuth_pressed()\0arg1\0"
"on_spinBoxLastLineEndPointFixedValue_valueChanged(int)\0"
"on_pushButtonRecommendedSetting_clicked()\0"
"bChangeToNext\0onUpdateCnt1GroupDisp(bool)\0"
"onUpdateCnt2GroupDisp(bool)\0"
"on_Cnt3AddRowBtn_pressed()\0"
"on_Cnt3AddRowBtn_2_pressed()\0"
"on_Cnt3RemoveRowBtn_pressed()\0"
"on_Cnt3RemoveRowBtn_2_pressed()\0"
"on_Cnt3InsertRowBtn_pressed()\0"
"on_Cnt3InsertRowBtn_2_pressed()\0"
"on_checkBoxGroupCnt1_clicked(bool)\0"
"on_checkBoxGroupCnt_2_clicked(bool)\0"
"on_cnt3RemoveAllRowsBtn_pressed()\0"
"on_cnt3RemoveAllRowsBtn_2_pressed()\0"
"on_cnt3RemoveAllRowsBtn_3_pressed()\0"
"on_cnt3RemoveAllRowsBtn_4_pressed()\0"
"index\0on_comboBoxAlterPrintEnable_currentIndexChanged(int)\0"
"on_checkVol1of8En_clicked(bool)\0"
"on_checkmode0211_clicked(bool)\0"
"on_spinBoxExpiryDate_valueChanged(int)\0"
"on_CBDateFormat1_currentIndexChanged(int)\0"
"showMachInfo(QString)\0SuperNodeIP,EdgeIP\0"
"showRemoteControl(QString,QString)\0"
"on_volButton_clicked()\0"
"on_spinBoxColDelay_valueChanged(int)\0"
"on_radioButtonFUllColFIxVal_clicked(bool)\0"
"on_metreCountButton_clicked()\0"
"on_lockoulsepushButton_clicked()\0"
"on_spinBoxCnt1EndValue_valueChanged(int)\0"
"on_pushButtonUpRow_clicked()\0"
"on_pushButtonUpRow_2_clicked()\0"
"on_pushButtonDownRow_clicked()\0"
"on_pushButtonDownRow_2_clicked()\0"
"on_checkBoxResetCnt3CurrValue_released()\0"
"on_checkBoxSaveCNTStateValue_released()\0"
"on_checkBoxCircleProductCnt_released()\0"
"on_pushOnlyCNT3Clear_pressed()\0"
"setCNT1BackColor(bool)\0setCNT2BackColor(bool)\0"
"setCNT3BackColor(bool)\0setDisableFontWidth(bool)\0"
"autoUpdateFontWidth(uint)\0"
"on_checkBox_FastMode_clicked()\0sel\0"
"currentChanged(int)\0"
};
void PrintSetting::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
PrintSetting *_t = static_cast<PrintSetting *>(_o);
switch (_id) {
case 0: _t->HiddenFunction((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 1: _t->authChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: _t->printPriveiw(); break;
case 3: _t->change_OutputPulse(); break;
case 4: _t->SwitchTimerShowItem((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 5: _t->updateUIForSpecialCondition(); break;
case 6: _t->on_radioButtonSpecialCondition_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 7: _t->refreshtimerHandler(); break;
case 8: _t->ondialogShowCounterAccepted(); break;
case 9: _t->on_checkVarLenChg(); break;
case 10: _t->on_VarLenSet(); break;
case 11: _t->on_pushButtonRanddomBackUP_pressed(); break;
case 12: _t->PrintupdateSysParaToUI(); break;
case 13: _t->showVolDacEdit((*reinterpret_cast< int(*)>(_a[1]))); break;
case 14: _t->on_pushButtonApply_pressed(); break;
case 15: _t->on_checkBoxResetCnt1CurrValue_released(); break;
case 16: _t->on_checkBoxResetCnt2CurrValue_released(); break;
case 17: _t->on_pushButtonClearRunTime_pressed(); break;
case 18: _t->on_pushOnlyCNT1Clear_pressed(); break;
case 19: _t->on_pushOnlyCNT2Clear_pressed(); break;
case 20: _t->ondialogAuthorizationAccepted(); break;
case 21: _t->ondialogAuthVarSetAccepted(); break;
case 22: _t->on_dialogModPasswdAccepted(); break;
case 23: _t->on_checkBoxSuspendAfterPhaseFault_clicked(); break;
case 24: _t->on_checkBoxPowerOffAfterPhaseFault_clicked(); break;
case 25: _t->on_pushButtonAuth_pressed(); break;
case 26: _t->on_spinBoxLastLineEndPointFixedValue_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 27: _t->on_pushButtonRecommendedSetting_clicked(); break;
case 28: _t->onUpdateCnt1GroupDisp((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 29: _t->onUpdateCnt2GroupDisp((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 30: _t->on_Cnt3AddRowBtn_pressed(); break;
case 31: _t->on_Cnt3AddRowBtn_2_pressed(); break;
case 32: _t->on_Cnt3RemoveRowBtn_pressed(); break;
case 33: _t->on_Cnt3RemoveRowBtn_2_pressed(); break;
case 34: _t->on_Cnt3InsertRowBtn_pressed(); break;
case 35: _t->on_Cnt3InsertRowBtn_2_pressed(); break;
case 36: _t->on_checkBoxGroupCnt1_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 37: _t->on_checkBoxGroupCnt_2_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 38: _t->on_cnt3RemoveAllRowsBtn_pressed(); break;
case 39: _t->on_cnt3RemoveAllRowsBtn_2_pressed(); break;
case 40: _t->on_cnt3RemoveAllRowsBtn_3_pressed(); break;
case 41: _t->on_cnt3RemoveAllRowsBtn_4_pressed(); break;
case 42: _t->on_comboBoxAlterPrintEnable_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 43: _t->on_checkVol1of8En_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 44: _t->on_checkmode0211_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 45: _t->on_spinBoxExpiryDate_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 46: _t->on_CBDateFormat1_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 47: _t->showMachInfo((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 48: _t->showRemoteControl((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
case 49: _t->on_volButton_clicked(); break;
case 50: _t->on_spinBoxColDelay_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 51: _t->on_radioButtonFUllColFIxVal_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 52: _t->on_metreCountButton_clicked(); break;
case 53: _t->on_lockoulsepushButton_clicked(); break;
case 54: _t->on_spinBoxCnt1EndValue_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 55: _t->on_pushButtonUpRow_clicked(); break;
case 56: _t->on_pushButtonUpRow_2_clicked(); break;
case 57: _t->on_pushButtonDownRow_clicked(); break;
case 58: _t->on_pushButtonDownRow_2_clicked(); break;
case 59: _t->on_checkBoxResetCnt3CurrValue_released(); break;
case 60: _t->on_checkBoxSaveCNTStateValue_released(); break;
case 61: _t->on_checkBoxCircleProductCnt_released(); break;
case 62: _t->on_pushOnlyCNT3Clear_pressed(); break;
case 63: _t->setCNT1BackColor((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 64: _t->setCNT2BackColor((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 65: _t->setCNT3BackColor((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 66: _t->setDisableFontWidth((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 67: _t->autoUpdateFontWidth((*reinterpret_cast< const uint(*)>(_a[1]))); break;
case 68: _t->on_checkBox_FastMode_clicked(); break;
case 69: _t->currentChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
}
}
const QMetaObjectExtraData PrintSetting::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject PrintSetting::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_PrintSetting,
qt_meta_data_PrintSetting, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &PrintSetting::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *PrintSetting::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *PrintSetting::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_PrintSetting))
return static_cast<void*>(const_cast< PrintSetting*>(this));
if (!strcmp(_clname, "ParaSettingUI"))
return static_cast< ParaSettingUI*>(const_cast< PrintSetting*>(this));
return QWidget::qt_metacast(_clname);
}
int PrintSetting::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 70)
qt_static_metacall(this, _c, _id, _a);
_id -= 70;
}
return _id;
}
// SIGNAL 0
void PrintSetting::HiddenFunction(bool _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
// SIGNAL 1
void PrintSetting::authChanged(int _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
// SIGNAL 2
void PrintSetting::printPriveiw()
{
QMetaObject::activate(this, &staticMetaObject, 2, 0);
}
// SIGNAL 3
void PrintSetting::change_OutputPulse()
{
QMetaObject::activate(this, &staticMetaObject, 3, 0);
}
// SIGNAL 4
void PrintSetting::SwitchTimerShowItem(bool _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 4, _a);
}
QT_END_MOC_NAMESPACE
@@ -0,0 +1,139 @@
#include "dlgmutilanguage.h"
#include "ui_dlgmutilanguage.h"
#include "InputMethod.h"
#include <QFile>
#include <unistd.h>
DlgMutiLanguage::DlgMutiLanguage(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgMutiLanguage)
{
ui->setupUi(this);
// ui->listWidget->hide();
connect(ui->buttonBox,SIGNAL(accepted()),this,SLOT(SetNewLanguage()));
LangIndex=INPUT_METHOD_TYPE_CHINESE;
}
DlgMutiLanguage::~DlgMutiLanguage()
{
delete ui;
}
void DlgMutiLanguage::setCurrentLanguage(){
if(LangIndex==INPUT_METHOD_TYPE_ENGLISH) ui->radioButton_2->setChecked(true);
else if(LangIndex==INPUT_METHOD_TYPE_CHINESE) ui->radioButton->setChecked(true);
else if(LangIndex==INPUT_METHOD_TYPE_VIETNAM) ui->radioButton_3->setChecked(true);
//else if(LangIndex==INPUT_METHOD_TYPE_RUSSIAN) ui->radioButton_4->setChecked(true);
//else if(LangIndex==INPUT_METHOD_TYPE_JAPANESE) ui->radioButton_5->setChecked(true);
//else if(LangIndex==INPUT_METHOD_TYPE_KOREAN) ui->radioButton_6->setChecked(true);
else ui->radioButton->setChecked(true);
}
int DlgMutiLanguage::getCurrentLanguage(){
// LangIndex = INPUT_METHOD_TYPE_CHINESE;
// if(ui->radioButton_2->isChecked()) {
// LangIndex = INPUT_METHOD_TYPE_ENGLISH;
// QMessageBox::information(this,tr("提示"),tr("重启后切换到英文界面"));
// buf.append("English\r\n");
// buf.append("WINPY_utf8.txt\r\n");
// }
// else if(ui->radioButton_3->isChecked()) {
// LangIndex = INPUT_METHOD_TYPE_VIETNAM;
// QMessageBox::information(this,tr("提示"),tr("重启后切换到越南语界面"));
// buf.append("Vietnamese\r\n");
// buf.append("YN_utf8.txt\r\n");
// }
// /*else if(ui->radioButton->isChecked()) {
// }
// else if(ui->radioButton->isChecked()) {
// }
// else if(ui->radioButton->isChecked()) {
// }*/
// else {
// QMessageBox::information(this,tr("提示"),tr("重启后切换到中文界面"));
// buf.append("Chinese\r\n");
// buf.append("WINPY_utf8.txt\r\n");
// }
return LangIndex;
}
void DlgMutiLanguage::SetNewLanguage(){
LangIndex = INPUT_METHOD_TYPE_CHINESE;
QFile file("/home/plg/UseEn");
// QMessageBox::StandardButton ret;
// ret = QMessageBox::information(this, tr("警告"),
// tr("确定要切换显示语言吗?\r\n(重启才能生效)"),
// QMessageBox::Ok | QMessageBox::Cancel);
// if (ret != QMessageBox::Ok){
// return;
// }
QByteArray buf;
buf.clear();
if(file.open(QIODevice::ReadWrite)) {//怀疑是QIODevice::Truncate 引起参数错误,去掉试试看
if(ui->radioButton_2->isChecked()) {
LangIndex = INPUT_METHOD_TYPE_ENGLISH;
buf.append("English\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
else if(ui->radioButton_3->isChecked()) {
LangIndex = INPUT_METHOD_TYPE_VIETNAM;
buf.append("Turkish\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
else if(ui->radioButton_4->isChecked()) {
LangIndex = INPUT_METHOD_TYPE_SPANISH;
buf.append("Spanish\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
else if(ui->radioButton_5->isChecked()) {
LangIndex = INPUT_METHOD_TYPE_THAI;
buf.append("Thai\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
else if(ui->radioButton_6->isChecked()) {
LangIndex = INPUT_METHOD_TYPE_VIETNAM;
buf.append("Vietnamese\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
else if(ui->radioButton_7->isChecked()) {
LangIndex = INPUT_METHOD_TYPE_Farsi;
buf.append("Farsi\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
/*else if(ui->radioButton->isChecked()) {
}
else if(ui->radioButton->isChecked()) {
}
else if(ui->radioButton->isChecked()) {
}*/
else {
//QMessageBox::information(this,tr("提示"),tr("重启后切换到中文界面"));
buf.append("Chinese\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
if(buf.contains("Chinese\r\n"))
system("touch /home/plg/chinese");
else
system("rm /home/plg/chinese");
file.write(buf);
//#if defined(__CONVERTERBOARD__)|| defined(__VX__)
#if 1
fsync(file.handle());
#endif
file.close();
}
}
@@ -0,0 +1,134 @@
#ifndef __TAESCLASS_H__
#define __TAESCLASS_H__
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
typedef unsigned long DWORD;
typedef unsigned char UCHAR,*PUCHAR;
typedef void *PVOID,*LPVOID;
typedef unsigned char byte;
typedef DWORD *PDWORD,*LPDWORD;
#ifndef VOID
#define VOID void
#endif
//#pragma once
//enum KeySize { Bits128, Bits192, Bits256 }; // key size, in bits, for construtor
#define Bits128 16
#define Bits192 24
#define Bits256 32
#if 0
static unsigned char AesSbox[16*16]=
{// populate the Sbox matrix
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
/*0*/ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
/*1*/ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
/*2*/ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
/*3*/ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
/*4*/ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
/*5*/ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
/*6*/ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
/*7*/ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
/*8*/ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
/*9*/ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
/*a*/ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
/*b*/ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
/*c*/ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
/*d*/ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
/*e*/ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
/*f*/ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};
static unsigned char AesiSbox[16*16]=
{
// populate the iSbox matrix
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
/*0*/ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
/*1*/ 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
/*2*/ 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
/*3*/ 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
/*4*/ 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
/*5*/ 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
/*6*/ 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
/*7*/ 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
/*8*/ 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
/*9*/ 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
/*a*/ 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
/*b*/ 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
/*c*/ 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
/*d*/ 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
/*e*/ 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
/*f*/ 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
};
static unsigned char AesRcon[11*4]=
{
0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00,
0x1b, 0x00, 0x00, 0x00,
0x36, 0x00, 0x00, 0x00
};
#endif
extern unsigned char AesSbox[16*16];
extern unsigned char AesiSbox[16*16];
extern unsigned char AesRcon[11*4];
class Aes // Advanced Encryption Standard
{
public:
~Aes();
Aes();
Aes(int keySize, unsigned char* keyBytes);
unsigned char State[4][4];
void Cipher(unsigned char* input, unsigned char* output); // encipher 16-bit input
void InvCipher(unsigned char* input, unsigned char* output); // decipher 16-bit input
private:
int Nb; // block size in 32-bit words. Always 4 for AES. (128 bits).
int Nk; // key size in 32-bit words. 4, 6, 8. (128, 192, 256 bits).
int Nr; // number of rounds. 10, 12, 14.
unsigned char key[32];
unsigned char w[16*15];
void SetNbNkNr(int keySize);
void AddRoundKey(int round); //轮密钥加
void SubBytes(); //S盒字节代换
void InvSubBytes(); //逆S盒字节代换
void ShiftRows(); //行移位
void InvShiftRows();
void MixColumns(); //列混淆
void InvMixColumns();
unsigned char gfmultby01(unsigned char b);
unsigned char gfmultby02(unsigned char b);
unsigned char gfmultby03(unsigned char b);
unsigned char gfmultby09(unsigned char b);
unsigned char gfmultby0b(unsigned char b);
unsigned char gfmultby0d(unsigned char b);
unsigned char gfmultby0e(unsigned char b);
void KeyExpansion(); //密钥扩展
unsigned char* SubWord(unsigned char* word); //密钥S盒字代换
unsigned char* RotWord(unsigned char* word); //密钥移位
};
class TAesClass
{
public:
TAesClass();
~TAesClass();
void InitializePrivateKey(DWORD KeySize,UCHAR *KeyBytes); //AES 密钥初始化
DWORD OnAesEncrypt(LPVOID InBuffer,DWORD InLength,LPVOID OutBuffer); //AES 加密数据
DWORD OnAesUncrypt(LPVOID InBuffer,DWORD InLength,LPVOID OutBuffer); //AES 解密数据
private:
Aes * m_lpAes;
};
#endif