📄 userinterface.c
字号:
if(protectivefunction[17][0] != '-')
{
pftable[index].field = CHZ;
pftable[index].data = CHZp;
pftable[index].items = 5;
index++;
}
if(protectivefunction[18][0] != '-')
{
pftable[index].field = BZT;
pftable[index].data = BZTp;
pftable[index].items = 3;
index++;
}
pftable[index].field = FH;
pftable[index].items = 1;
return;
}
/*
*****************************************************************************************************************
* 函数名称: void settingsProcess();
* 功能描述: 根据配置情况,显示保护定值界面;
* 参数: 没有;
* 返回值: 没有;
* 使用变量: #define PROTECTFUNC_NUM 0x13
* typedef struct{
* INT8U (*field)[22];
* INT8U (*data)[7];
* INT8U items;
* }PFT;
* PFT pftable[PROTECTFUNC_NUM];
* 参考变量: INT8U protectivefunction[19][4];
*****************************************************************************************************************
*/
void settingsProcess()
{
INT16U msg;
INT8U *err;
BOOLEAN loop = TRUE;
INT8U head,headpos;
INT8U rear,rearpos;
BOOLEAN empty = FALSE;
BOOLEAN cancontinue = FALSE;
initpftable();
if(pftable[0].items == 1) // the pftable is an empty table;
{
head = rear = 0;
headpos = rearpos = 0; // indicating protective functions not configured,
empty = TRUE; // and table is empty;
displaySettings(head,headpos,rear,rearpos);
}
else // the pftable is not an empty table;
{
head = 0;
headpos = 1;
getDownPage(&head,&headpos,&rear,&rearpos); // get 12 or less than 12 items
displaySettings(head,headpos,rear,rearpos); // to display;
}
for(;loop == TRUE;)
{
msg = getMessage(err);
switch(msg)
{
case MSG_RIGHT:
if(empty != TRUE)
{
if(rearpos < pftable[rear].items) //adjust head an headpos value
{ // to display next page;
head = rear;
headpos = rearpos + 1;
cancontinue = TRUE;
}
else
{
if(pftable[rear+1].items != 1)
{
head = rear+1;
headpos = 1;
cancontinue = TRUE;
}
}
if(cancontinue == TRUE)
{
getDownPage(&head,&headpos,&rear,&rearpos);
displaySettings(head,headpos,rear,rearpos);
cancontinue = FALSE;
}
}
break;
case MSG_LEFT:
if(empty != TRUE)
{
if(headpos > 1)
{
rear = head;
rearpos = headpos - 1;
cancontinue = TRUE;
}
else
{
if(head > 0)
{
rear = head - 1;
rearpos = pftable[rear].items;
cancontinue = TRUE;
}
}
if(cancontinue == TRUE)
{
getUpPage(&head,&headpos,&rear,&rearpos);
displaySettings(head,headpos,rear,rearpos);
cancontinue = FALSE;
}
}
break;
case MSG_ENTER:
loop = FALSE;
break;
default:
doNothing();
}
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: void displaySettings();
* 功能描述: 更新显示保护定值显示界面的内容;
* 参数: 没有;
* 返回值: 没有;
* 使用变量: typedef struct{
* INT8U (*field)[22];
* INT8U (*data)[7];
* INT8U items;
* }PFT;
* PFT pftable[PROTECTFUNC_NUM];
*****************************************************************************************************************
*/
void displaySettings(INT8U head,INT8U headpos,INT8U rear,INT8U rearpos)
{
INT8U index;
INT8U buffer[22];
if((headpos == 0)&&(rearpos == 0))
{
printString(18,70,6,13,0,"保护功能未配置",TRUE);
flushBuffer();
}
else
{
for(index = 0; index < 12; index++)
{
buffer[0] = '\0';
strCat(pftable[head].field[headpos - 1],buffer);
if(headpos == 1)
{
strInsert(pftable[head].data[headpos - 1]+3,buffer,17);
}
else
{
if(pftable[head].data[headpos - 1][3] == '.')
{
strInsert(pftable[head].data[headpos - 1],buffer,12);
}
else
{
strInsert(pftable[head].data[headpos - 1]+3,buffer,15);
}
}
printString(0,index*13 + 2,6,13,0,buffer,TRUE);
if(headpos < pftable[head].items)
{
headpos++;
if((head == rear)&&(headpos > rearpos))
{
break;
}
}
else
{
if(head < rear)
{
head++;
headpos = 1;
}
else
{
break;
}
}
}
flushBuffer();
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: BOOLEAN getDownPage(INT8U *phead,INT8U *pheadpos,INT8U *prear,
* INT8U *prearpos);
* 功能描述: 该函数用于从pftable表中找用于显示的12项(也可以少于12项);
* 注意,调用的时候参数*phead,*pheadpos值一定要确保正确;
* 参数: phead和prear为pftable表中的索引;
* pheadpos和prearpos为保护功能项里面的索引;
* 返回值: 没有;
* 使用变量: typedef struct{
* INT8U (*field)[22];
* INT8U (*data)[7];
* INT8U items;
* }PFT;
* PFT pftable[PROTECTFUNC_NUM];
*****************************************************************************************************************
*/
void getDownPage(INT8U *phead,INT8U *pheadpos,INT8U *prear,INT8U *prearpos)
{
INT8U index = 0;
*prear = *phead;
*prearpos = *pheadpos;
do{
if((*prearpos) < pftable[*prear].items)
{
(*prearpos)++;
}
else
{
if(pftable[(*prear) + 1].items != 1)
{
(*prear)++;
(*prearpos) = 1;
}
else
{
break;
}
}
index++;
}while(index < 11);
return;
}
/*
*****************************************************************************************************************
* 函数名称: BOOLEAN getUpPage(INT8U *phead,INT8U *pheadpos,INT8U *prear,
* INT8U *prearpos);
* 功能描述: 该函数用于从pftable表中找用于显示的12项(也可以少于12项);
* 注意,调用的时候参数prear和prearpos值一定要确保正确;
* 参数: phead和prear为pftable表中的索引;
* pheadpos和prearpos为保护功能项里面的索引;
* 返回值: 没有;
* 使用变量: typedef struct{
* INT8U (*field)[22];
* INT8U (*data)[7];
* INT8U items;
* }PFT;
* PFT pftable[PROTECTFUNC_NUM];
*****************************************************************************************************************
*/
void getUpPage(INT8U *phead,INT8U *pheadpos,INT8U *prear,INT8U *prearpos)
{
INT8U index = 0;
*phead = *prear;
*pheadpos = *prearpos;
do{
if((*pheadpos) > 1)
{
(*pheadpos)--;
}
else
{
if((*phead) >= 1)
{
(*phead)--;
(*pheadpos) = pftable[*phead].items;
}
else
{
break;
}
}
index++;
}while(index < 11);
return;
}
/*
*****************************************************************************************************************
* 函数名称: void coordinationLogicProcess();
* 功能描述: 对梯形图逻辑界面的消息进行处理并显示;
* 参数: 没有;
* 返回值: 没有;
*****************************************************************************************************************
*/
void coordinationLogicProcess()
{
INT16U msg;
INT8U *err;
BOOLEAN loop = TRUE;
displayCoordinationLogic();
for(;loop == TRUE;)
{
msg = getMessage(err);
switch(msg)
{
case MSG_RIGHT:
break;
case MSG_LEFT:
break;
case MSG_ENTER:
loop = FALSE;
break;
default:
doNothing();
}
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: void displayCoordinationLogic();
* 功能描述: 更新显示梯形图逻辑界面的内容;
* 参数: 没有;
* 返回值: 没有;
*****************************************************************************************************************
*/
void displayCoordinationLogic()
{
printString(20,70,6,13,0,"Not implemented",TRUE);
flushBuffer();
return;
}
/*
*****************************************************************************************************************
* 函数名称: void breakerStatisticInforProcess();
* 功能描述: 对断路器统计信息的消息进行处理并显示;
* 参数: 没有;
* 返回值: 没有;
*****************************************************************************************************************
*/
void breakerStatisticInforProcess()
{
INT8U totalitems = 10;
INT8U itemhead = 1;
INT8U itemrear = 10;
INT16U msg;
INT8U *err;
BOOLEAN loop = TRUE;
displayBreakerStatisticInfor(itemhead,itemrear,TRUE);
for(;loop == TRUE;)
{
msg = getMessage(err);
switch(msg)
{
case MSG_ENTER:
loop = FALSE;
break;
case MSG_TIME:
displayBreakerStatisticInfor(itemhead,itemrear,FALSE);
break;
default:
doNothing();
}
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: void displayBreakerStatisticInfor(INT8U itemhead,INT8U itemrear,
* BOOLEAN paintAll);
* 功能描述: 更新显示断路器统计信息显示界面;
* 参数: itemhead指示界面显示的第一项内容;
* itemrear指示界面显示的最后一项内容;
* paintAll指示显示界面是否需要重画;
* 返回值: 没有;
*****************************************************************************************************************
*/
void displayBreakerStatisticInfor(INT8U itemhead,INT8U itemrear,BOOLEAN paintAll)
{
INT8U index;
INT8U buffer[22];
if(paintAll == TRUE) // 重画显示界面;
{
for(index = 0; index < 10; index++)
{
buffer[0] = '\0';
strCat(breakerstatisticinforitems[index],buffer);
strInsert(breakerstatisticinfor[index],buffer,10);
printString(6,index*13,6,13,0,buffer,TRUE);
}
flushBuffer();
}
else // 更新显示项的内容;
{
for(index = 0; index < 10; index++)
{
printString(66,index*13,6,13,0,breakerstatisticinfor[index],FALSE);
}
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: void testInforProcess();
* 功能描述: 对调试信息显示界面的消息进行处理并显示;
* 参数: 没有;
* 返回值: 没有;
*****************************************************************************************************************
*/
void testInforProcess()
{
INT8U totalitems = 10;
INT8U itemhead = 1;
INT8U itemrear = 10;
INT16U msg;
INT8U *err;
BOOLEAN loop = TRUE;
displayTestInfor(itemhead,itemrear,TRUE);
for(;loop == TRUE;)
{
msg = getMessage(err);
switch(msg)
{
case MSG_ENTER:
loop = FALSE;
break;
case MSG_TIME:
displayTestInfor(itemhead,itemrear,FALSE);
break;
default:
doNothing();
}
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: void displayTestInfor(INT8U itemhead,INT8U itemrear,BOOLEAN paintAll);
* 功能描述: 更新显示调试信息界面的内容;
* 参数: itemhead指示界面显示的第一项内容;
* itemrear指示界面显示的最后一项内容;
* paintAll指示显示界面是否需要重画;
* 返回值: 没有;
*****************************************************************************************************************
*/
void displayTestInfor(INT8U itemhead,INT8U itemrear,BOOLEAN paintAll)
{
INT8U index;
INT8U buffer[22];
if(paintAll == TRUE) // 重画调试信息界面的内容;
{
for(index = 0; index < 10; index++)
{
buffer[0] = '\0';
strCat(testinforitems[index],buffer);
strCat(" ",buffer);
strCat(testinfor[index],buffer);
printString(6,index*13,6,13,0,buffer,TRUE);
}
flushBuffer();
}
else // 更新显示数据项的内容;
{
for(index = 0; index < 10; index++)
{
printString(84,index*13,6,13,0,testinfor[index],FALSE);
}
}
return;
}
/*
*****************************************************************************************************************
* 函数名称: void selfCheckProcess();
* 功能描述: 对自检信息显示界面的消息进行处理并显示;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -