📄 wio.c.bak
字号:
while(1)
{
if(g_bpflg > 0)
{
for(i = 0; i<g_bpflg; i++)
{
beep_flg = temp[i] - 1;
pszSet[1] = beep_horl[beep_flg];
pszSet[2] = beep_time[beep_flg];
for (j=0; j<beep_retimes[beep_flg]; j++)
{
WriteFile(g_hPws, pszSet, 3, &nByte, NULL);
Sleep(beep_spacetime[beep_flg]);
}
}
g_bpflg = 0;
memset(temp, 0x20, 1000);
}
else
{
Sleep(1);
}
}//end while
}
/* -------------------------------- */
/* Function: */
/* nBeepSet */
/* Parameter: */
/* int n */
/* the flag of Beep */
/* int retimes */
/* The number of repetitions*/
/* int horl */
/* high or low Beep */
/* int beeptime */
/* the time of Beep */
/* int spacetime */
/* The interval of time between two beeps
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.9.27 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
nBeepSet(int n, int retimes, int horl, int beeptime, int spacetime)
{
n = n - 1;
beep_retimes[n] = retimes;
beep_horl[n] = horl;
beep_time[n] = beeptime;
beep_spacetime[n]= spacetime*10;
return 0;
}
/* -------------------------------- */
/* Function: */
/* BeepInit */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.7.25 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int BeepInit()
{
BeepThread = CreateThread(NULL, 0, bThread, 0, 0, NULL);
return 0;
}
/* -------------------------------- */
/* Function: */
/* Beep */
/* Parameter: */
/* int nTimes */
/* the times 0f 25 millisecond*/
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int Beep(int nTimes)
{
// n_flg = nTimes - 1;
// nTimes = nTimes * 25;
temp[g_bpflg] = nTimes;
g_bpflg++;
if(g_bpflg > 10)
{
g_bpflg = 0;
}
return 0;
}
/*int Beep(int nTimes)
{
DWORD nByte = 0;
char pszSetOn[] = "SetSpeakerOn";
char pszSetOff[] = "SetSpeakerOff";
nTimes = nTimes * 20;
WriteFile(g_hPws, pszSetOn, dim(pszSetOn), &nByte, NULL);
Sleep(nTimes);
WriteFile(g_hPws, pszSetOff, dim(pszSetOff), &nByte, NULL);
Sleep(50);
return 0;
}*/
/* -------------------------------- */
/* Function: */
/* SBar_Open */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int SBar_Open()
{
DWORD nByte = 0;
// char pszOpen[] = "SetUARTOn";
int pszOpen[5];
int rtAPI;
pszOpen[0] = 2;
pszOpen[1] = 0;
pszOpen[2] = 1;
pszOpen[3] = 0x00;
rtAPI = WriteFile(g_hPws, pszOpen, 3, &nByte, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* SBar_Close */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int SBar_Close()
{
DWORD nByte = 0;
// char pszClose[] = "SetUARTOff";
int pszClose[5];
int rtAPI;
pszClose[0] = 2;
pszClose[1] = 0;
pszClose[2] = 0;
pszClose[3] = 0x00;
rtAPI = WriteFile(g_hPws, pszClose, 3, &nByte, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* BLiteAllow */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.9.21 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int BLiteAllow()
{
DWORD nByte = 0;
// char pszAllow[] = "SetLightAllow";
int pszAllow[5];
int rtAPI;
pszAllow[0] = 1;
pszAllow[1] = 1;
pszAllow[2] = 1;
pszAllow[3] = 0x00;
rtAPI = WriteFile(g_hPws, pszAllow, 3, &nByte, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* BLiteLimit */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.9.21 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int BLiteLimit()
{
DWORD nByte = 0;
// char pszLimit[] = "SetLightLimit";
int pszLimit[5];
int rtAPI;
pszLimit[0] = 1;
pszLimit[1] = 1;
pszLimit[2] = 0;
pszLimit[3] = 0x00;
rtAPI = WriteFile(g_hPws, pszLimit, 3, &nByte, NULL);
if (!rtAPI)
{
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* BackLite */
/* Parameter: */
/* int nStatus */
/* 1---- on */
/* 0---- off */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int BackLite(int nStatus)
{
DWORD nByte = 0;
// char pszLiteOn[] = "SetBackLightOn";
// char pszLiteOff[] = "SetBackLightOff";
int pszLiteOn[5];
int pszLiteOff[5];
int rtAPI;
pszLiteOn[0] = 1;
pszLiteOn[1] = 0;
pszLiteOn[2] = 1;
pszLiteOn[3] = 0x00;
pszLiteOff[0] = 1;
pszLiteOff[1] = 0;
pszLiteOff[2] = 0;
pszLiteOff[3] = 0x00;
if (nStatus == 1)
{
if (g_LiteStatus == 0)
{
rtAPI = WriteFile(g_hPws, pszLiteOn, 3, &nByte, NULL);
if (!rtAPI)
{
return -1;
}
g_LiteStatus = 1;
}
return 0;
}
if (nStatus == 0)
{
if (g_LiteStatus == 1)
{
rtAPI = WriteFile(g_hPws, pszLiteOff, 3, &nByte, NULL);
if (!rtAPI)
{
return -1;
}
g_LiteStatus = 0;
}
backliteflg = 0;
return 0;
}
return -1;
}
/* -------------------------------- */
/* Function: */
/* DispClr */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int DispClr()
{
int cmd[2];
int rtAPI;
DWORD num = 0;
cmd[0] = 2;
cmd[1] = 0;
WaitForSingleObject (hMutex, INFINITE);
rtAPI = WriteFile(hDspIns, cmd, 2, &num, NULL);
if (!rtAPI)
{
return -1;
}
ReleaseMutex(hMutex);
return 0;
}
/* -------------------------------- */
/* Function: */
/* DateGet */
/* Parameter: */
/* AD1DATE *date */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int DateGet(AD1DATE *date)
{
SYSTEMTIME SysTime;
GetSystemTime(&SysTime);
(*date).year = SysTime.wYear;
(*date).month = SysTime.wMonth;
(*date).dayofweek = SysTime.wDayOfWeek;
(*date).day = SysTime.wDay;
return 0;
}
/* -------------------------------- */
/* Function: */
/* TimeGet */
/* Parameter: */
/* AD1DATE *time */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int TimeGet(AD1TIME *time)
{
SYSTEMTIME SysTime;
GetSystemTime(&SysTime);
(*time).hour = SysTime.wHour;
(*time).minute = SysTime.wMinute;
(*time).second = SysTime.wSecond;
(*time).centisec = SysTime.wMilliseconds;
return 0;
}
/* -------------------------------- */
/* Function: */
/* DateSet */
/* Parameter: */
/* AD1DATE *date */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int DateSet(AD1DATE *date)
{
SYSTEMTIME SysTime;
GetSystemTime(&SysTime);
SysTime.wYear = (*date).year;
SysTime.wMonth = (*date).month;
SysTime.wDay = (*date).day;
SetSystemTime(&SysTime);
return 0;
}
/* -------------------------------- */
/* Function: */
/* TimeSet */
/* Parameter: */
/* AD1DATE *time */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int TimeSet(AD1TIME *time)
{
SYSTEMTIME SysTime;
GetSystemTime(&SysTime);
SysTime.wYear = SysTime.wYear;
SysTime.wMonth = SysTime.wMonth;
SysTime.wDay = SysTime.wDay;
SysTime.wHour = (*time).hour;
SysTime.wMinute = (*time).minute;
SysTime.wSecond = (*time).second;
SetSystemTime(&SysTime);
return 0;
}
/* -------------------------------- */
/* Function: */
/* EnterInteger */
/* Parameter: */
/* int x column position */
/* int y row position */
/* int min */
/* the minimum accepted */
/* int max */
/* the maximum accepted
/* int *value */
/* integer value to edit */
/* or enter */
/* char paramlist[] */
/* parameter list for entry */
/* Return Value */
/* int */
/* Author: */
/* Zhang Jun */
/* Date: */
/* 2005.7.13 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
#define ESC 0x74
#define RETURN 0x0d
#define LEFT 0x7d
#define CLEAR 0x73
int EnterInteger(int x, int y, int min, int max, int *value, char paramlist[])
{
int cx;
int rtc;
int len;
int loop;
int reng;
int state;
int inputflg;
char edit[26];
char wok[4];
char rdchr;
inputflg = 0;
reng =0;
loop = 0;
*value = 0;
memset(edit, 0x20, 26);
edit[25] = 0x00;
strncpy(edit, paramlist, 24);
memset(wok, 0x20, 4);
wok[4] = 0x00;
// rtc = strncmp(paramlist, " Year = [ ] ",24);
if (min > 999)
{
rtc = 0;
}
cx = x;
CrsrPut(x, y);
CrsrMake(1);
while(loop == 0)
{
rdchr = KbdRead();
switch (rdchr)
{
case ESC:
CrsrMake(0);
return 0;
break;
case RETURN:
if(inputflg == 0)
{
Beep(3);
}
else
{
strncpy(wok, &edit[x-reng+1], reng);
if(reng!=0 && reng >= 1)
{
state = atoi(wok);
if(state >= min && state <= max)
{
*value = state;
loop=1;
}
else
{
Beep(3);
}
}
}
break;
case LEFT:
if(cx < x)
{
reng = reng - 1;
wok[reng] = 0x20;
cx++;
memset(edit, 0x20, 26);
strncpy(edit, paramlist, 24);
strncpy(&edit[cx+1], wok, reng);
}
else
{
Beep(3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -