Files
FireAlarmCtrlCn/MyCode/Gui/DeviceDymPrm.cpp
2026-04-06 19:02:09 +08:00

1165 lines
34 KiB
C++

#include "DeviceDymPrm.h"
#include "gvalue.h"
#include "gType.h"
#include "GraphLow.h"
#include "GraphBase.h"
#include "MainCtl.h"
#include "RuntimeData.h"
#include "RuntimeData2.h"
#include "Runtime.h"
#include "Gui.h"
#define dDdpLvLineCount 10
#define TextTopOffSet 6
const char cType[12] = {" 类型"};
const char cIndex[12] = {"编号"};
const char cCarry[12] = {"搭载"};
const char cPLoad[12] = {"已登记"};
const char cVoltage[12] = {"电压"};
const char cCurrent[12] = {"电流"};
const char cDescp[12] = {"描述"};
const char cUserCode[12] = {"用户码"};
const char cAddr[12] = {"地址"};
const char cPrm1[12] = {"参数1"};
const char cPrm2[12] = {"参数2"};
const char cPrm3[12] = {"参数3"};
const char cPrm4[12] = {"参数4"};
void TDevDymPrm::Init(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor)
{
#define CH 30 //Caption Height
unsigned short Left,Right, Top, Bottom, Width, Height, i;
Bound.SetBySize(OwnerX +x1, OwnerY +y1, aW, aH);
Left = Bound.Left +3;
Top = Bound.Top +3;
Width = aW-7;
Height = aH-7;
Right = Bound.Right -4;
Bottom = Bound.Bottom -4;
Caption.Init(Left,Top,Width, CH, 0, 0, clWhite, clMaroon);
Content.Set(Left, Top+CH, Right-20, Bottom);
VScrollBarBox.Set(Right-20 +1, Top+CH, Right, Bottom);
Color = aColor;
#undef CH
//SetFontSize(9);
RootItems.Count=0;
EpItems.Count=0;
RootItems.SelectedIndex=0;
EpItems.SelectedIndex=0;
Lv.ColHeight = 33;
Lv.TopIndex=0;
Lv.FixColTop = Content.Top;
Lv.FixColBottom = Lv.FixColTop + Lv.ColHeight -1;
Lv.ColTop[0] = Lv.FixColBottom + 1;
Lv.ColBottom[0] = Lv.ColTop[0] + Lv.ColHeight -1;
Lv.ColLeft[0] = 1;
Lv.ColRight[0] = Lv.ColWidth[0] +1;
for(i=1; i<12; i++){
Lv.ColTop[i] = Lv.ColTop[i -1] + Lv.ColHeight;
Lv.ColBottom[i] = Lv.ColBottom[i-1] + Lv.ColHeight;
}
PathX = 0;
RootItems.Selected_dType = dgTYPE_PORT; //dRootDevTypeMin;
RootItems.ActiveLineNum =0;
RootItems.TopIndex =0;
EpItems.Selected_dType = dgTYPE_SMOKE_DETECTOR_I;//dEpDevTypeMin;
EpItems.ActiveLineNum =0;
EpItems.TopIndex =0;
FixColColor = clMedGray;
FixColTextColor = clNearWhite;
TextColor = clNearBlack;
SelectedColor = clBlue;
SelectedTextColor = clNearWhite;
Caption.Border.Color = clGray;
VScrollBar.Color = clFrmFace;
VScrollBar.RibbonColor = clGray;
//PercentBar.SetColor(clBlue, clGray);
//ClearPath();
Caption.Color = clMaroon;
Caption.TextColor = clNearWhite;
}
void TDevDymPrm::SetListColWidth(int w0, int w1, int w2, int w3, int w4,int w5, int w6, int w7, int w8, int w9, int w10, int w11, int w12, int w13)
{
//0.Image, 1,dType, 2.UserCode, 3.Id, 4.Updata, 5.Prm1, 6.Prm2, 7.Prm3, 8.Prm4
unsigned int i;
Lv.ColWidth[0] = w0;
Lv.ColWidth[1] = w1;
Lv.ColWidth[2] = w2;
Lv.ColWidth[3] = w3;
Lv.ColWidth[4] = w4;
Lv.ColWidth[5] = w5;
Lv.ColWidth[6] = w6;
Lv.ColWidth[7] = w7;
Lv.ColWidth[8] = w8;
Lv.ColWidth[9] = w9;
Lv.ColWidth[10] = w10;
Lv.ColWidth[11] = w11;
Lv.ColWidth[12] = w12;
Lv.ColWidth[13] = w13;
Lv.ColLeft[0] = Content.Left +1;
Lv.ColRight[0] = Lv.ColLeft[0] + w0;
for(i=1; i<14; i++){
Lv.ColLeft[i] = Lv.ColRight[i-1] +1;
Lv.ColRight[i] = Lv.ColLeft[i] + Lv.ColWidth[i];
}
}
void TDevDymPrm::SetFontSize(int size)
{
FontSize = size;
FontHeight = GetFontHeight(FontSize);
}
void TDevDymPrm::RenderBackGround(void)
{
RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, Color);
}
void TDevDymPrm::RenderBackGround(unsigned int aClr)
{
RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, aClr);
}
void TDevDymPrm::DrawSelf(void)
{
unsigned int x, y, x2, y2, w, h;
VertLineRender(Bound.Left, Bound.Top, Bound.Height -1, 0xFFFFFFFF);
VertLineRender(Bound.Right -1, Bound.Top +1, Bound.Height -2, 0xFF808080);
VertLineRender(Bound.Right, Bound.Top, Bound.Height, 0xFF404040);
HorizLineRender(Bound.Left, Bound.Top, Bound.Width - 1, 0xFFFFFFFF);
HorizLineRender(Bound.Left +1, Bound.Bottom -1, Bound.Width - 2, 0xFF808080);
HorizLineRender(Bound.Left, Bound.Bottom, Bound.Width, 0xFF404040);
x = Bound.Left +2 ;
x2 = Bound.Right -2;
y = Bound.Top +2;
y2 = Bound.Bottom - 2;
w = Bound.Width -4;
h = Bound.Height - 4;
VertLineRender (x, y, h-1, 0xFF808080);
HorizLineRender (x, y, w-1, 0xFF808080);
VertLineRender (x+1, y+1, h-2, 0xFF404040);
HorizLineRender (x+1, y+1, w-2, 0xFF404040);
VertLineRender (x2-1, y+1, h-2, 0xFFD4D0C8);
HorizLineRender (x+1, y2-1, w-2, 0xFFD4D0C8);
VertLineRender (x2, y, h, 0xFFFFFFFF);
HorizLineRender (x, y2, w, 0xFFFFFFFF);
//Fill Rect Box
RenderContent();
}
void TDevDymPrm::RenderContent(void)
{
#define FixColColor clMedGray
#define OddColor clNearMoneyGreen
unsigned int x,y, y2, clr;
unsigned int aTopIndex, aSelectedIndex, aCol;
if(PathX == 0){
aTopIndex = RootItems.TopIndex;
aSelectedIndex = RootItems.SelectedIndex;
}else{
aTopIndex = EpItems.TopIndex;
aSelectedIndex = EpItems.SelectedIndex;
}
aCol = aSelectedIndex - aTopIndex;
RectFillRender(Content.Left, Lv.FixColTop, Content.Right, Lv.FixColBottom, FixColColor);
y = Lv.FixColBottom + 1;
for(x=0; x<dDdpLvLineCount; x++){
y2 = y + Lv.ColHeight - 1;
if(y2 > Content.Bottom)y2 = Content.Bottom;
if(x == aCol){
RectFillRender(Content.Left, y, Content.Right, y2, clBlue);
}else{
if(x & 1){
RectFillRender(Content.Left, y, Content.Right, y2, OddColor);
}else{
RectFillRender(Content.Left, y, Content.Right, y2, Color);
}
}
y = y2 + 1;
if(y>Content.Bottom)break;
}
}
void TDevDymPrm::DrawCaption(void)
{
Caption.Show();
}
void TDevDymPrm::DrawVertScrollBar(void)
{
int RibbonHeight;
int RibbonBottom;
int RibbonTop;
int UpRemain;
int DownRemain;
float f1,f2,f3,f4;
if(EpItems.Count <= dDdpLvLineCount){
RibbonTop = VScrollBarBox.Top+1;
RibbonBottom = VScrollBarBox.Bottom - 1;
RibbonHeight = VScrollBarBox.Height - 2;
}else{
//get RibbonHeight
f1 = static_cast<float>(dDdpLvLineCount);
f2 = static_cast<float>(EpItems.Count);
f3 = static_cast<float>(VScrollBarBox.Height);
f4 = f1/f2*f3;
RibbonHeight = static_cast<int>(f4) ;
if(RibbonHeight > VScrollBarBox.Height) RibbonHeight = VScrollBarBox.Height;
if(RibbonHeight < 10) RibbonHeight = 10;
f2 = f4/f1; //Get One Item Height
//get RibbonCenter
UpRemain = EpItems.TopIndex;
DownRemain = EpItems.Count - EpItems.TopIndex - dDdpLvLineCount;
if(UpRemain < DownRemain){
f1 = UpRemain;
RibbonTop = static_cast<int>(f1*f2) + VScrollBarBox.Top + 1;
RibbonBottom = RibbonTop + RibbonHeight;
if( RibbonBottom > (VScrollBarBox.Bottom -1) )RibbonBottom = VScrollBarBox.Bottom - 1;
}else{
f1 = DownRemain;
RibbonBottom = VScrollBarBox.Bottom - static_cast<int>(f1*f2);
RibbonTop = RibbonBottom - RibbonHeight;
if( RibbonTop < (VScrollBarBox.Top +1) )RibbonTop = VScrollBarBox.Top +1;
}
}
//Draw Vert ScrollBar BackGround
RectFillRender(VScrollBarBox.Left, VScrollBarBox.Top, VScrollBarBox.Right, VScrollBarBox.Bottom, VScrollBar.Color);
//Draw Vert ScrollBar Ribbon
RectFillRender(VScrollBarBox.Left, RibbonTop, VScrollBarBox.Right, RibbonBottom, VScrollBar.RibbonColor);
}
void TDevDymPrm::DrawRootDevList(void)
{
int i,j, index, BGClr, TextClr, aTop;
unsigned int idx;
switch(RootItems.Selected_dType){
case dgTYPE_POWER_SUPPLY:
DrawPowerSpply();
break;
case dgTYPE_BATTERY:
DrawBattery();
break;
case dgTYPE_COMM_GRAPH:
DrawGraphCtl();
break;
case dgTYPE_COMM_CAN:
DrawCommCan();
break;
case dgTYPE_COMM_MULTI:
DrawCommCan();
break;
case dgTYPE_LCD_BOARD:
DrawLcdBoard();
break;
case dgTYPE_KEY_BOARD_1:
case dgTYPE_KEY_BOARD_2:
DrawKeyBoard();
break;
case dgTYPE_MOTHER_BOARD:
DrawMotherBoard();
break;
case dgTYPE_HAND_CTL:
DrawHandPad();
break;
case dgTYPE_DIRECT_CTL:
DrawDirectCtl();
break;
case dgTYPE_PORT:
DrawPort();
break;
}
}
void TDevDymPrm::DrawEpDevList(void)
{
switch(EpItems.Selected_dType){
case dgTYPE_SMOKE_DETECTOR_I:
case dgTYPE_SMOKE_DETECTOR_II :
DrawSmokeDet(); //Req 1, IR Raw Data; 2, Blue Raw Data;
break;
case dgTYPE_TEMPE_DETECTOR_I:
DrawTempeDet(); //Req 1, Tempe in Celsius degree; 2, Raw Data;
break;
case dgTYPE_SMOKE_TEMPE_DETECTOR_I:
case dgTYPE_SMOKE_TEMPE_DETECTOR_II:
DrawSmokeTempeDet(); //Req 1, IR Raw Data; 2, Blue Raw Data; 3, Tempe in Celsius degree; 4, Raw Data;
break;
case dgTYPE_HAND_REPORT :
break;
case dgTYPE_IN_MODULE :
break;
case dgTYPE_OUT_MODULE:
break;
case dgTYPE_INOUT_MODULE:
break;
case dgTYPE_BUS_BROKE:
break;
case dgTYPE_DISPLAY_PAD_I:
break;
}
}
void TDevDymPrm::DrawList(void)
{
RenderContent();
DrawVertScrollBar();
if(PathX == 0){
DrawRootDevList();
}else
if(PathX == 1){
DrawEpDevList();
}
}
void TDevDymPrm::Show(void)
{
DrawSelf();
DrawVertScrollBar();
DrawList();
}
void TDevDymPrm::ClearPath(void)
{
unsigned int i;
for(i=0;i<256;i++){
RootItems.Dev[i] = nullptr;
EpItems.Dev[i] = nullptr;
}
RootItems.Count = 0;
RootItems.SelectedIndex = 0;
RootItems.TopIndex = 0;
EpItems.Count = 0;
EpItems.SelectedIndex = 0;
EpItems.TopIndex = 0;
}
void TDevDymPrm::ClearPath1(void)
{
unsigned int i;
for(i=0;i<256;i++){
EpItems.Dev[i] = nullptr;
}
EpItems.Count = 0;
EpItems.SelectedIndex = 0;
EpItems.TopIndex = 0;
}
void TDevDymPrm::LoadPath0Item(TRootDevice *pItem)
{
if(RootItems.Count < 256){
RootItems.Dev[RootItems.Count] = pItem;
RootItems.Count++;
}
}
void TDevDymPrm::LoadPath1Item(TEpDevice *pItem )
{
if(EpItems.Count < 256){
EpItems.Dev[EpItems.Count]= pItem;
EpItems.Count++;
}
}
void TDevDymPrm::LoadPath0(void)
{
int i;
ClearPath();
switch(RootItems.Selected_dType){
case dgTYPE_POWER_SUPPLY:
break;
case dgTYPE_BATTERY:
break;
case dgTYPE_COMM_GRAPH:
break;
case dgTYPE_COMM_CAN:
for(i=0; i<dCOMMBOARD_MAX_COUNT; i++){
if(MainCtl.fData.Split.ExistTableCommBrd[i] == 0xA5)
LoadPath0Item((TRootDevice *)(&(CommBoard[i])));
}
break;
case dgTYPE_COMM_MULTI:
break;
case dgTYPE_LCD_BOARD:
break;
case dgTYPE_KEY_BOARD_1 :
break;
case dgTYPE_KEY_BOARD_2 :
break;
case dgTYPE_MOTHER_BOARD:
for(i=0; i<dMOTHERBOARD_MAX_COUNT; i++){
if(MainCtl.fData.Split.ExistTableMotherBrd[i] == 0xA5)
LoadPath0Item((TRootDevice *)(&(MotherBoard[i])));
}
break;
case dgTYPE_HAND_CTL:
for(i=0; i<dHANDCTL_MAX_COUNT; i++){
if(MainCtl.fData.Split.ExistTableHandCtl[i] == 0xA5)
LoadPath0Item((TRootDevice *)(&(HandCtlBoard[i])));
}
break;
case dgTYPE_DIRECT_CTL:
if(MainCtl.fData.Split.DirectCtlCount > dDIRECTCTL_MAX_COUNT)MainCtl.fData.Split.DirectCtlCount = dDIRECTCTL_MAX_COUNT;
for(i=0; i<dDIRECTCTL_MAX_COUNT; i++){
if(MainCtl.fData.Split.ExistTableDirectCtl[i] == 0xA5)
LoadPath0Item((TRootDevice *)(&(DirectCtlBoard[i])));
}
break;
case dgTYPE_PORT:
if(MainCtl.fData.Split.PortCount > dPORT_MAX_COUNT )
MainCtl.fData.Split.PortCount = dPORT_MAX_COUNT;
for(i=0; i<dPORT_MAX_COUNT; i++){
if(MainCtl.fData.Split.ExistTablePort[i] == 0xA5)
LoadPath0Item((TRootDevice *)(&(Port[i])));
}
break;
}
TMyString::sFromStr("本机 ",Caption.Text );
TMyString::sAddOnStr(StrType[RootItems.Selected_dType], Caption.Text);
TMyString::sAddOnStr(" ", Caption.Text);
TMyString::sAddOn3Dg(EpItems.Count, Caption.Text);
Caption.FullRedraw();
if(RootItems.Count>0){
RootItems.SelectedIndex = 0;
Lv.SelectedCol = 0;
Lv.TopIndex = 0;
}
}
void TDevDymPrm::LoadPath1(void)
{
TRootDevice *theRDev = nullptr;
TPort *thePort;
unsigned int i, px, ex;
ClearPath1();
if( RootItems.Dev[RootItems.SelectedIndex] == nullptr ) return;
theRDev = RootItems.Dev[RootItems.SelectedIndex];
if(theRDev != nullptr){
if(theRDev->fData.Common.dType == dgTYPE_PORT){
px = theRDev->fData.Port.Id;
thePort = (TPort *)theRDev;
for(i=0; i< dEP_MAX_COUNT_PER_PORT; i++){
if(Port[px].ExistTable[i] == 0xA5)
if(EpItems.Selected_dType == EpDev[px][i].fData.Split.dType)
LoadPath1Item(&EpDev[px][ex]);
}
TMyString::sFromStr("回路",Caption.Text );
TMyString::sAddOn3Dg(theRDev->fData.Common.Id, Caption.Text);
TMyString::sAddOnStr(" ", Caption.Text);
TMyString::sAddOnStr(StrType[EpItems.Selected_dType], Caption.Text);
TMyString::sAddOnStr(" ", Caption.Text);
TMyString::sAddOn3Dg(EpItems.Count, Caption.Text);
Caption.FullRedraw();
if(EpItems.Count >0) {
EpItems.SelectedIndex = 0;
Lv.SelectedCol = 0;
Lv.TopIndex = 0;
}
}else{
}
}
switch(EpItems.Selected_dType){
case dgTYPE_SMOKE_DETECTOR_I:
case dgTYPE_SMOKE_DETECTOR_II :
case dgTYPE_TEMPE_DETECTOR_I:
case dgTYPE_SMOKE_TEMPE_DETECTOR_I:
case dgTYPE_SMOKE_TEMPE_DETECTOR_II:
case dgTYPE_HAND_REPORT :
case dgTYPE_IN_MODULE :
case dgTYPE_OUT_MODULE:
case dgTYPE_INOUT_MODULE :
case dgTYPE_BUS_BROKE:
case dgTYPE_DISPLAY_PAD_I:
break;
}
}
void TDevDymPrm::SetEditMode(unsigned int aMode)
{
}
void TDevDymPrm::SendReqCmd(void)
{
FCBusTx.WriteOneMsg(CmdBuf, 17);
}
void TDevDymPrm::DrawPowerSpply(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,60,60,60,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "电流");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "功率");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx <= RootItems.Count){
if(RootItems.Dev[idx] != nullptr){
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
void TDevDymPrm::DrawBattery(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,60,60,60,80,60,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "电流");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "容量");
TextRender_string24(Lv.ColLeft[9],aTop,TextColor, "状态");
TextRender_string24(Lv.ColLeft[10],aTop,TextColor, "寿命");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawGraphCtl(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,80,1,1,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "版本");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawCommCan(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,120,120,1,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "00通讯");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "速率");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawCommMulti(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,120,120,1,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "类型列表");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "速率列表");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawLcdBoard(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,80,80,1,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "电流");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawKeyBoard(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,60,60,1,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "键型");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "键数");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawMotherBoard(void)
{
unsigned int i,j, idx, aTop;
SetListColWidth(30,80,48,120,80,60,80,80,80,60,60,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "已挂载");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "已登记");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[9],aTop,TextColor, "电流");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
}
void TDevDymPrm::DrawHandPad(void)
{
unsigned int i,j, idx, aTop, aClr, aClr2;
SetListColWidth(30,80,48,120,60,60,80,80,160,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "电流");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "已启动");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx < RootItems.Count){
if(RootItems.Dev[idx] != nullptr){
ImageList.Render(24, RootItems.Dev[idx]->fData.Common.dType, Lv.ColLeft[0], aTop, Content.Right, Content.Bottom);
if(Lv.SelectedCol == i){
aClr = clNearWhite;
aClr2 = clGreen;
}else{
aClr = clNearBlack;
aClr2 = clBlue;
}
RootItems.Dev[idx]->PrintProperty(&Str[0],&Str[1],&Str[2]);
TextRender_string24(Lv.ColLeft[1], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[2], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[3], aTop, aClr, Str[2].Text);
TextRender_string24(Lv.ColLeft[4], aTop, aClr, "Tag0");
PercentBar.SetSize(Lv.ColLeft[5] +1, aTop +1, Lv.ColRight[5] -1, aTop +26);
PercentBar.PercentRender(DymPrm.UpdataSeconed[idx],256, DymPrm.GotUpdata[idx]);
RootItems.Dev[idx]->PrintDynamicsData(&Str[0],&Str[1],&Str[2],&Str[3],&Str[4],&Str[5],&Str[6],&Str[7]);
TextRender_string24(Lv.ColLeft[6], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[7], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[8], aTop, aClr2, Str[2].Text);
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
void TDevDymPrm::DrawDirectCtl(void)
{
unsigned int i,j, idx, aTop, aClr, aClr2;
SetListColWidth(30,80,48,120,60,60,80,80,160,1,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "电流");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "已启动");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx < RootItems.Count){
if(RootItems.Dev[idx] != nullptr){
ImageList.Render(24, RootItems.Dev[idx]->fData.Common.dType, Lv.ColLeft[0], aTop, Content.Right, Content.Bottom);
if(Lv.SelectedCol == i){
aClr = clNearWhite;
aClr2 = clGreen;
}else{
aClr = clNearBlack;
aClr2 = clBlue;
}
RootItems.Dev[idx]->PrintProperty(&Str[0],&Str[1],&Str[2]);
TextRender_string24(Lv.ColLeft[1], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[2], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[3], aTop, aClr, Str[2].Text);
TextRender_string24(Lv.ColLeft[4], aTop, aClr, "Tag0");
PercentBar.SetSize(Lv.ColLeft[5] +1, aTop +1, Lv.ColRight[5] -1, aTop +26);
PercentBar.PercentRender(DymPrm.UpdataSeconed[idx],256, DymPrm.GotUpdata[idx]);
RootItems.Dev[idx]->PrintDynamicsData(&Str[0],&Str[1],&Str[2],&Str[3],&Str[4],&Str[5],&Str[6],&Str[7]);
TextRender_string24(Lv.ColLeft[6], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[7], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[8], aTop, aClr2, Str[2].Text);
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
void TDevDymPrm::DrawPort(void)
{
unsigned int i,j, idx, aTop, aClr, aClr2;
SetListColWidth(30,80,48,120,80,60,60,60,80,60,1,1,1,1);
aTop = Lv.FixColTop ;
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "标记");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "电压");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "电流");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "已挂载");
TextRender_string24(Lv.ColLeft[9],aTop,TextColor, "温度");
if(RootItems.Count < 1)return;
idx = RootItems.TopIndex;
aTop = Lv.FixColBottom +1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx < RootItems.Count){
if(RootItems.Dev[idx] != nullptr){
ImageList.Render(24, RootItems.Dev[idx]->fData.Common.dType, Lv.ColLeft[0], aTop, Content.Right, Content.Bottom);
if(Lv.SelectedCol == i){
aClr = clNearWhite;
aClr2 = clGreen;
}else{
aClr = clNearBlack;
aClr2 = clBlue;
}
RootItems.Dev[idx]->PrintProperty(&Str[0],&Str[1],&Str[2]);
TextRender_string24(Lv.ColLeft[1], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[2], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[3], aTop, aClr, Str[2].Text);
TextRender_string24(Lv.ColLeft[4], aTop, aClr, "Tag0");
PercentBar.SetSize(Lv.ColLeft[5] +1, aTop +1, Lv.ColRight[5] -1, aTop +26);
PercentBar.PercentRender(DymPrm.UpdataSeconed[idx],256, DymPrm.GotUpdata[idx]);
RootItems.Dev[idx]->PrintDynamicsData(&Str[0],&Str[1],&Str[2],&Str[3],&Str[4],&Str[5],&Str[6],&Str[7]);
TextRender_string24(Lv.ColLeft[6], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[7], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[8], aTop, aClr2, Str[2].Text);
TextRender_string24(Lv.ColLeft[9], aTop, aClr2, Str[3].Text);
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
void TDevDymPrm::DrawSmokeDet(void)
{
//0.Image, 1,dType, 2.UserCode, 3.Id, 4.Updata, 5.Prm1, 6.Prm2, 7.Prm3, 8.Prm4
unsigned int i,j, idx, aTop, aClr, aClr2;
SetListColWidth(30,80,48,120,60,60,60,120,120,1,1,1,1,1);
aTop = Lv.FixColTop ;
if(1){
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "灵敏");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "污染");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "红外值");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "蓝光值");
if(EpItems.Count < 1)return;
idx = EpItems.TopIndex;
aTop = Lv.FixColBottom +1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx < EpItems.Count){
if(EpItems.Dev[idx] != nullptr){
ImageList.Render(24, EpItems.Dev[idx]->fData.Split.dType, Lv.ColLeft[0], aTop, Content.Right, Content.Bottom);
if(Lv.SelectedCol == i){
aClr = clNearWhite;
aClr2 = clGreen;
}else{
aClr = clNearBlack;
aClr2 = clBlue;
}
EpItems.Dev[idx]->PrintProperty(&Str[0],&Str[1],&Str[2]);
TextRender_string24(Lv.ColLeft[1], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[2], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[3], aTop, aClr, Str[2].Text);
EpItems.Dev[idx]->PrintAttribute(&Str[3],&Str[4],&Str[5],&Str[6]);
TextRender_string24(Lv.ColLeft[4], aTop, aClr, Str[3].Text);
TextRender_string24(Lv.ColLeft[5], aTop, aClr, Str[6].Text);
PercentBar.SetSize(Lv.ColLeft[6] +1, aTop +1, Lv.ColRight[6] -1, aTop +26);
PercentBar.PercentRender(DymPrm.UpdataSeconed[idx],256, DymPrm.GotUpdata[idx]);
Str[7].FromUInt4Dg(DymPrm.Value[idx][0]); // IR Value
Str[8].FromUInt4Dg(DymPrm.Value[idx][1]); // Blue Value
TextRender_string24(Lv.ColLeft[7], aTop, aClr2, Str[7].Text);
TextRender_string24(Lv.ColLeft[8], aTop, aClr2, Str[8].Text);
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
}
void TDevDymPrm::DrawTempeDet(void)
{
//0.Image, 1,dType, 2.UserCode, 3.Id, 4.Updata, 5.Prm1, 6.Prm2, 7.Prm3, 8.Prm4
unsigned int i,j, idx, aTop, aClr,aClr2;;
SetListColWidth(30,80,48,120,80,80,60,100,100,1,1,1,1,1);
aTop = Lv.FixColTop ;
if(1){
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "报警值");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "时间值");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "温度值");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "模拟值");
if(EpItems.Count < 1)return;
idx = Lv.TopIndex;
aTop = Lv.FixColBottom + 1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx < EpItems.Count){
if(EpItems.Dev[idx] != nullptr){
ImageList.Render(24, EpItems.Dev[idx]->fData.Split.dType, Lv.ColLeft[0], aTop, Content.Right, Content.Bottom);
if(Lv.SelectedCol == i){
aClr = clNearWhite;
aClr2 = clGreen;
}else{
aClr = clNearBlack;
aClr2 = clBlue;
}
EpItems.Dev[idx]->PrintProperty(&Str[0],&Str[1],&Str[2]);
TextRender_string24(Lv.ColLeft[1], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[2], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[3], aTop, aClr, Str[2].Text);
EpItems.Dev[idx]->PrintAttribute(&Str[3],&Str[4],&Str[5],&Str[6]);
TextRender_string24(Lv.ColLeft[4], aTop, aClr, Str[3].Text);
TextRender_string24(Lv.ColLeft[5], aTop, aClr, Str[5].Text);
PercentBar.SetSize(Lv.ColLeft[6] +1, aTop +1, Lv.ColRight[6] -1, aTop +26);
PercentBar.PercentRender(DymPrm.UpdataSeconed[idx],256, DymPrm.GotUpdata[idx]);
Str[7].FromUInt4Dg(DymPrm.Value[idx][0]); // Deg Value
Str[8].FromUInt4Dg(DymPrm.Value[idx][1]); // Raw Data Value
TextRender_string24(Lv.ColLeft[7], aTop, aClr2, Str[7].Text);
TextRender_string24(Lv.ColLeft[8], aTop, aClr2, Str[8].Text);
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
}
void TDevDymPrm::DrawSmokeTempeDet(void)
{
//0.Image, 1,dType, 2.UserCode, 3.Id, 4.Updata, 5.Prm1, 6.Prm2, 7.Prm3, 8.Prm4
unsigned int i,j, idx, aTop, aClr,aClr2;
SetListColWidth(30,80,48,120,60,60,60,60,60,60,60,1,1,1);
aTop = Lv.FixColTop ;
if(1){
TextRender_string24(Lv.ColLeft[1],aTop,TextColor, cUserCode);
TextRender_string24(Lv.ColLeft[2],aTop,TextColor, cIndex);
TextRender_string24(Lv.ColLeft[3],aTop,TextColor, cType);
TextRender_string24(Lv.ColLeft[4],aTop,TextColor, "灵敏");
TextRender_string24(Lv.ColLeft[5],aTop,TextColor, "报警");
TextRender_string24(Lv.ColLeft[6],aTop,TextColor, "更新");
TextRender_string24(Lv.ColLeft[7],aTop,TextColor, "红外");
TextRender_string24(Lv.ColLeft[8],aTop,TextColor, "蓝光");
TextRender_string24(Lv.ColLeft[9],aTop,TextColor, "温度");
TextRender_string24(Lv.ColLeft[10],aTop,TextColor, "模拟");
if(EpItems.Count < 1)return;
idx = EpItems.TopIndex;
aTop = Lv.FixColBottom +1;
for(i=0; i<dDdpLvLineCount; i++){
if(idx < EpItems.Count){
if(EpItems.Dev[idx] != nullptr){
ImageList.Render(24, EpItems.Dev[idx]->fData.Split.dType, Lv.ColLeft[0], aTop, Content.Right, Content.Bottom);
if(Lv.SelectedCol == i){
aClr = clNearWhite;
aClr2 = clGreen;
}else{
aClr = clNearBlack;
aClr2 = clBlue;
}
EpItems.Dev[idx]->PrintProperty(&Str[0],&Str[1],&Str[2]);
TextRender_string24(Lv.ColLeft[1], aTop, aClr, Str[0].Text);
TextRender_string24(Lv.ColLeft[2], aTop, aClr, Str[1].Text);
TextRender_string24(Lv.ColLeft[3], aTop, aClr, Str[2].Text);
EpItems.Dev[idx]->PrintAttribute(&Str[3],&Str[4],&Str[5],&Str[6]);
TextRender_string24(Lv.ColLeft[4], aTop, aClr, Str[3].Text);
TextRender_string24(Lv.ColLeft[5], aTop, aClr, Str[5].Text);
PercentBar.SetSize(Lv.ColLeft[6] +1, aTop +1, Lv.ColRight[6] -1, aTop +26);
PercentBar.PercentRender(DymPrm.UpdataSeconed[idx],256, DymPrm.GotUpdata[idx]);
Str[7].FromUInt4Dg(DymPrm.Value[idx][0]); // IR Value
Str[8].FromUInt4Dg(DymPrm.Value[idx][1]); // Blue Value
Str[9].FromUInt4Dg(DymPrm.Value[idx][2]); // Deg Value
Str[10].FromUInt4Dg(DymPrm.Value[idx][3]); // Raw Data Value
TextRender_string24(Lv.ColLeft[7], aTop, aClr2, Str[7].Text); // IR Value
TextRender_string24(Lv.ColLeft[8], aTop, aClr2, Str[8].Text); // Blue Value
TextRender_string24(Lv.ColLeft[9], aTop, aClr2, Str[9].Text); // Deg Value
TextRender_string24(Lv.ColLeft[10], aTop, aClr2, Str[10].Text); // Raw Data Value
}
}
idx++;
aTop = aTop + Lv.ColHeight;
}
}
}
void TDevDymPrm::SetActive(void)
{
Active = 1;
}
void TDevDymPrm::SetDeActive(void)
{
Active = 0;
}
void TDevDymPrm::TimeTickTask(void)
{
unsigned int i;
if(Active != 1) return;
for(i=0; i<EpItems.Count; i++){
if(DymPrm.UpdataSeconed[i] > 0) DymPrm.UpdataSeconed[i]--;
}
DrawEpDevList();
}
void TDevDymPrm::UpChange_dType(void)
{
if(PathX == 0){
RootItems.Selected_dType++;
if(RootItems.Selected_dType > dRootDevTypeMax)
RootItems.Selected_dType = dRootDevTypeMin;
LoadPath0();
}else
if(PathX == 1){
EpItems.Selected_dType++;
if(EpItems.Selected_dType > dEpDevTypeMax)
EpItems.Selected_dType = dEpDevTypeMin;
LoadPath1();
}
DrawList();
}
void TDevDymPrm::DownChange_dType(void)
{
if(PathX == 0){
if(RootItems.Selected_dType > dRootDevTypeMin){
RootItems.Selected_dType--;
}else{
RootItems.Selected_dType = dRootDevTypeMax;
}
LoadPath0();
}else
if(PathX == 1){
if(EpItems.Selected_dType > dEpDevTypeMin){
EpItems.Selected_dType--;
}else{
EpItems.Selected_dType = dEpDevTypeMax;
}
LoadPath1();
}
DrawList();
}
TGuiMsgReturn TDevDymPrm::KeyIn(unsigned char aKey)
{
int ind,i;
TGuiMsgReturn aMsg = guiMsgNone;
//Up or Down One Index___________________
if(PathX == 0){
switch(aKey){
//case VK_SELECT:
case VK_RIGHT:
UpChange_dType();
break;
case VK_LEFT:
DownChange_dType();
break;
case VK_UP:
if(RootItems.SelectedIndex > 0){
RootItems.SelectedIndex--;
if(RootItems.SelectedIndex<RootItems.TopIndex){
RootItems.TopIndex=RootItems.SelectedIndex;
}
DrawList();
Lv.SelectedCol = RootItems.SelectedIndex - RootItems.TopIndex;
}
break;
case VK_DOWN:
if( RootItems.SelectedIndex < (RootItems.Count-1) ){
RootItems.SelectedIndex++;
if( (RootItems.SelectedIndex - RootItems.TopIndex) >= dDdpLvLineCount){
RootItems.TopIndex += 1;
}
Lv.SelectedCol = RootItems.SelectedIndex - RootItems.TopIndex;
DrawList();
}
break;
case VK_EXECUTE:
PathX = 1;
EpItems.Selected_dType = dgTYPE_SMOKE_DETECTOR_I;
LoadPath1();
DrawList();
break;
case VK_RETURN:
aMsg = guiMsgReturn;
break;
case VK_F2:
//start to query
SendReqCmd();
break;
}
}else
if(PathX == 1){
switch(aKey){
case VK_RIGHT:
UpChange_dType();
break;
case VK_LEFT:
DownChange_dType();
break;
case VK_UP:
if(EpItems.SelectedIndex>0){
EpItems.SelectedIndex--;
if(EpItems.SelectedIndex<EpItems.TopIndex){
EpItems.TopIndex=EpItems.SelectedIndex;
}
Lv.SelectedCol = EpItems.SelectedIndex - EpItems.TopIndex;
DrawList();
}
break;
case VK_DOWN:
if(EpItems.SelectedIndex < (EpItems.Count -1)){
EpItems.SelectedIndex++;
if( (EpItems.SelectedIndex - EpItems.TopIndex) >= dDdpLvLineCount ){
EpItems.TopIndex += 1;
}
Lv.SelectedCol = EpItems.SelectedIndex - EpItems.TopIndex;
DrawList();
}
break;
case VK_RETURN:
PathX = 0;
LoadPath0();
DrawList();
break;
case VK_F2:
//start to query
SendReqCmd();
break;
}
}else{
PathX = 0;
LoadPath0();
DrawList();
}
return aMsg;
}