2024-07-08 10:27:17 +08:00
|
|
|
#include "zjd3100pro.h"
|
|
|
|
|
|
|
|
CZJD3100ProcessItem::CZJD3100ProcessItem()
|
|
|
|
{
|
|
|
|
logined = FALSE;
|
|
|
|
m_command = -1;
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_port = -1;
|
|
|
|
channelBuffer.mon_unit = -1;
|
|
|
|
|
|
|
|
apdu_t0_begin = system32.timers;
|
|
|
|
}
|
|
|
|
|
|
|
|
CZJD3100ProcessItem::~CZJD3100ProcessItem()
|
|
|
|
{
|
|
|
|
logined = FALSE;
|
|
|
|
m_command = -1;
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_port = -1;
|
|
|
|
channelBuffer.mon_unit = -1;
|
|
|
|
|
|
|
|
apdu_t0_begin = system32.timers;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CZJD3100ProcessItem::Attach(int uid, int sock, DWORD peer_addr, WORD peer_port)
|
|
|
|
{
|
|
|
|
CNetProcessItem::Attach(uid, sock, peer_addr, peer_port);
|
|
|
|
//send(sock, "ZJD3100 Written by assouan.\r\nZJD3100$ ", strlen("ZJD3100 Written by assouan.\r\nZJD3100$ "), 0);
|
|
|
|
logined = FALSE;
|
|
|
|
m_command = -1;
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_unit = -1;
|
|
|
|
|
|
|
|
apdu_t0_begin = system32.timers;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CZJD3100ProcessItem::Release(void)
|
|
|
|
{
|
|
|
|
logined = FALSE;
|
|
|
|
m_command = -1;
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_port = -1;
|
|
|
|
channelBuffer.mon_unit = -1;
|
|
|
|
|
|
|
|
apdu_t0_begin = system32.timers;
|
|
|
|
|
|
|
|
CNetProcessItem::Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
CZJD3100Process::CZJD3100Process()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CZJD3100Process::~CZJD3100Process()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CNetProcessItem *CZJD3100Process::CreateItem(int ord)
|
|
|
|
{
|
|
|
|
return(dynamic_cast<CNetProcessItem *>(new CZJD3100ProcessItem));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CZJD3100Process::DestroyItem(int ord, BOOLEAN bDeleted)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem *pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem != NULL && !bDeleted)
|
|
|
|
{
|
|
|
|
delete pItem;
|
|
|
|
return CNetProcess::DestroyItem(ord, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return CNetProcess::DestroyItem(ord, bDeleted);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnPreCreate(int id)
|
|
|
|
{
|
|
|
|
if (!CNetProcess::OnPreCreate(id)) return FALSE;
|
2024-12-16 17:02:35 +08:00
|
|
|
|
|
|
|
m_proto2name_map[PROTOCOL_HOST_IEC104] = "IEC104主";
|
|
|
|
m_proto2name_map[PROTOCOL_SUB_IEC104] = "IEC104从";
|
|
|
|
m_proto2name_map[PROTOCOL_HOST_MODBUS_RTU] = "MODBUS RTU主";
|
|
|
|
m_proto2name_map[PROTOCOL_SUB_MODBUS_RTU] = "MODBUS RTU从";
|
|
|
|
m_proto2name_map[PROTOCOL_HOST_MODBUS_TCP] = "MODBUS tcp主";
|
|
|
|
m_proto2name_map[PROTOCOL_SUB_MODBUS_TCP] = "MODBUS RTU over tcp从";
|
|
|
|
m_proto2name_map[PROTOCOL_HOST_MODBUS_RTU_TCP] = "MODBUS RTU over tcp主";
|
|
|
|
m_proto2name_map[PROTOCOL_RTU_STATE] = "主控状态";
|
|
|
|
m_proto2name_map[PROTOCOL_LOCAL_DEBUG] = "本地调试";
|
|
|
|
m_proto2name_map[PROTOCOL_FTP2MINIO] = "FTP转存minio协议";
|
|
|
|
m_proto2name_map[PROTOCOL_HOST_BF_MODBUSTCP] = "倍福MODBUSTCP主";
|
|
|
|
m_proto2name_map[PROTOCOL_HOST_BF_ADS] = "倍福ADS协议";
|
|
|
|
|
2024-07-08 10:27:17 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CZJD3100Process::Destroy(void)
|
|
|
|
{
|
|
|
|
CNetProcess::Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::Run(void)
|
|
|
|
{
|
|
|
|
if (!CNetProcess::Run()) return FALSE;
|
|
|
|
FeedDog();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnTimer(void)
|
|
|
|
{
|
|
|
|
if (!CNetProcess::OnTimer()) return FALSE;
|
|
|
|
int i, uid;
|
|
|
|
CZJD3100ProcessItem* pItem;
|
|
|
|
for (i = 0; i < PROCESS_UNIT_NUM; i++)
|
|
|
|
{
|
|
|
|
pItem = (CZJD3100ProcessItem *)GetItem(i);
|
|
|
|
if (NULL == pItem) continue;
|
|
|
|
uid = pItem->GetUnitID();
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM) continue;
|
|
|
|
if (pItem->GetSock() < 0) {
|
|
|
|
if (isClient()) { //如果为客户端则需要区链接服务器
|
|
|
|
if (pItem->apdu_t0_begin > 0 && system32.timers > (pItem->apdu_t0_begin + 30))
|
|
|
|
{
|
|
|
|
pItem->apdu_t0_begin = system32.timers;
|
|
|
|
if (Connect(pItem, i, TRUE))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pItem->apdu_t0_begin = system32.timers;
|
|
|
|
UnitFeedDog(uid);
|
|
|
|
switch (pItem->m_command)
|
|
|
|
{
|
|
|
|
case 100:
|
|
|
|
OnSyntaxChannelData(i);
|
|
|
|
break;
|
|
|
|
case 101:
|
|
|
|
OnSyntaxUnitDisplayData(i);
|
|
|
|
break;
|
|
|
|
case 200:
|
|
|
|
OnSyntaxMsgData(i);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pItem->WriteToNetwork();
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CZJD3100Process::OnPackageReceived(BYTE* pBuf, int count, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
BYTE *pCmd;
|
|
|
|
char buffer[2048];
|
|
|
|
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
|
|
|
|
if (count >= 2)
|
|
|
|
{
|
|
|
|
len = 0;
|
|
|
|
pCmd = pBuf;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (pBuf[i] == '\r' || pBuf[i] == '\n')
|
|
|
|
{
|
|
|
|
pBuf[i] = '\0';
|
|
|
|
strcpy(buffer, (char *)pCmd);
|
|
|
|
//strncpy(buffer, (char *)pCmd, sizeof(buffer));
|
|
|
|
if (!OnSyntax(buffer, ord))
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
len = i+1;
|
|
|
|
if (pBuf[len] == '\r' || pBuf[len] == '\n')
|
|
|
|
{
|
|
|
|
len++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
pCmd = &pBuf[len];
|
|
|
|
pItem->WriteToNetwork();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntax(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char *pBuf;
|
|
|
|
BOOLEAN result = FALSE;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
|
|
|
|
if (strlen(pData) == 0)
|
|
|
|
{
|
|
|
|
if (pItem->logined)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# ", strlen("ZJD3100# "), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100$ ", strlen("ZJD3100$ "), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
pBuf = strchr(pData, ' ');
|
|
|
|
if (pBuf != NULL)
|
|
|
|
{
|
|
|
|
*pBuf = '\0';
|
|
|
|
pBuf++;
|
|
|
|
}
|
|
|
|
if (strcmp(pData, "help") == 0)
|
|
|
|
{
|
|
|
|
char buffer[] = "\r\nlogin [user] [password]\r\nlogout/exit/quit\r\n"
|
|
|
|
"db yx get/set [all|<start point>] [end point]\r\ndb yc get/set [all|<start point>] [end point]\r\ndb ym get/set [all|<start point>] [end point]\r\n"
|
|
|
|
"unit [n] yx get/set [all|<start point>] [end point]\r\nunit [n] yc get/set [all|<start point>] [end point]\r\nunit [n] ym get/set [all|<start point>] [end point]\r\n"
|
|
|
|
"channel [n] [draw|stop]\r\n"
|
|
|
|
"msg [n] [draw|stop]\r\n"
|
|
|
|
"status get [all|<start point>] [end point]\r\n";
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "moo") == 0)
|
|
|
|
{
|
|
|
|
char buffer[] = "\r\n (__)\r\n (oo)\r\n /------\\/\r\n / | ||\r\n * /\\---/\\\r\n ~~ ~~\r\n";
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "exit") == 0 || strcmp(pData, "quit") == 0 || strcmp(pData, "logout") == 0 || strcmp(pData, "by") == 0)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "login") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxLogin(pBuf, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "db") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxDB(pBuf, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "unit") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxUnit(pBuf, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "unitext") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxUnitExt(pBuf, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "channel") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxChannel(pBuf, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "unitdisplay") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxUnitDisplay(pBuf, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "msg") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxMsg(pBuf, ord);
|
|
|
|
}
|
2024-12-16 17:02:35 +08:00
|
|
|
else if (strcmp(pData, "process") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntanProcessInfo(pBuf, ord);
|
|
|
|
}
|
2024-07-08 10:27:17 +08:00
|
|
|
|
|
|
|
else if (strcmp(pData, "status") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxUnitsStatus(pBuf, ord);
|
|
|
|
}
|
|
|
|
#if DBG_VIEW_TOOL
|
|
|
|
else if (strcmp(pData, "test") == 0)
|
|
|
|
{
|
|
|
|
char buffer[32];
|
|
|
|
WORD test = 1;
|
|
|
|
memcpy(buffer, &test, sizeof(WORD));
|
|
|
|
pItem->WriteData((BYTE *)buffer, sizeof(WORD), ord);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "ext") == 0)
|
|
|
|
{
|
|
|
|
result = OnSyntaxExt(pBuf, ord);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
char buffer[] = "Invalid syntax.\r\n";
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
}
|
|
|
|
if (pItem->logined)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# ", strlen("ZJD3100# "), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100$ ", strlen("ZJD3100$ "), ord);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxLogin(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char name[32];
|
|
|
|
char pass[32];
|
|
|
|
char *pBuf;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
memset(name, 0, sizeof(name));
|
|
|
|
memset(pass, 0, sizeof(pass));
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pBuf = strchr(pData, ' ');
|
|
|
|
if (pBuf == NULL) return FALSE;
|
|
|
|
*pBuf = '\0'; pBuf++;
|
|
|
|
strncpy(name, pData, sizeof(name - 1));
|
|
|
|
strncpy(pass, pBuf, sizeof(pass - 1));
|
|
|
|
|
|
|
|
struUserInfor user;
|
|
|
|
memset(&user, 0, sizeof(user));
|
|
|
|
FILE* pf;
|
|
|
|
pf = fopen(FILE_PASSWORD_DATA, "rb");
|
|
|
|
if (pf != NULL)
|
|
|
|
{
|
|
|
|
while (!feof(pf))
|
|
|
|
{
|
|
|
|
if (fread(&user, sizeof(user), 1, pf) == 1)
|
|
|
|
{
|
|
|
|
user.name[15] = '\0';
|
|
|
|
user.pass[15] = '\0';
|
|
|
|
if (strcmp(user.name, name) == 0) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(pf);
|
|
|
|
}
|
|
|
|
if (strcmp(name, user.name) != 0 && strcmp("admin", name) != 0)
|
|
|
|
{
|
|
|
|
pItem->logined = FALSE;
|
|
|
|
pItem->WriteData((BYTE *)"Invalid user name.\r\n", strlen("Invalid user name.\r\n"), ord);
|
|
|
|
}
|
|
|
|
if (strcmp(pass, user.pass) != 0 && strcmp("123", pass) != 0)
|
|
|
|
{
|
|
|
|
pItem->logined = FALSE;
|
|
|
|
pItem->WriteData((BYTE *)"Invalid password.\r\n", strlen("Invalid password.\r\n"), ord);
|
|
|
|
}
|
|
|
|
pItem->logined = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxDB(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd != NULL)
|
|
|
|
{
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
}
|
|
|
|
if (strcmp(pData, "yx") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxDBYX(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "yc") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxDBYC(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "ym") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxDBYM(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "yk") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxDBYK(pCmd, ord);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxDBYX(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < DATABASE_YX_NUM; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%4d %-3s %-2s\t", i, (database.yxs[i].value ? "ON" : "OFF"), ((database.yxs[i].qds & 0x80) ? "IV" : " "));
|
|
|
|
len = strlen(buffer);
|
|
|
|
pItem->WriteData((BYTE *)buffer, len, ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= DATABASE_YX_NUM) return FALSE;
|
|
|
|
sprintf(buffer, "%4d %-3s %-2s\t", pt, (database.yxs[pt].value ? "ON" : "OFF"), ((database.yxs[i].qds & 0x80) ? "IV" : " "));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
if (strcmp(pVal, "on") != 0 && strcmp(pVal, "off") != 0) return FALSE;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= DATABASE_YX_NUM) return FALSE;
|
|
|
|
database.yxs[pt].value = strcmp(pVal, "on") == 0 ? TRUE : FALSE;
|
|
|
|
sprintf(buffer, "%4d %-3s\r\n", pt, (database.yxs[pt].value ? "ON" : "OFF"));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxDBYC(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < DATABASE_YC_NUM; i++)
|
|
|
|
{
|
|
|
|
//sprintf(buffer, "%4d %-5d %-2s\t", i, (int)database.ycs[i].value, (database.ycs[i].iv ? "IV" : " "));
|
|
|
|
sprintf(buffer, "%4d %5.3f %-2s\t", i, (float)(((float)database.ycs[i].value * database.ycs[i].coef) + database.ycs[i].base), ((database.ycs[i].qds & 0x80) ? "IV" : " "));
|
|
|
|
len = strlen(buffer);
|
|
|
|
pItem->WriteData((BYTE *)buffer, len, ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= DATABASE_YC_NUM) return FALSE;
|
|
|
|
//sprintf(buffer, "%4d %-5d %-2s\t", pt, (int)database.ycs[pt].value, (database.ycs[pt].iv ? "IV" : " "));
|
|
|
|
sprintf(buffer, "%4d %5.3f %-2s\t", pt, (float)(((float)database.ycs[pt].value * database.ycs[pt].coef) + database.ycs[pt].base), ((database.ycs[pt].qds & 0x80) ? "IV" : " "));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= DATABASE_YC_NUM) return FALSE;
|
|
|
|
database.ycs[pt].value = atoi(pVal);
|
|
|
|
sprintf(buffer, "%4d %-5d\r\n", pt, (int)database.ycs[pt].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxDBYM(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < DATABASE_YM_NUM; i++)
|
|
|
|
{
|
|
|
|
//sprintf(buffer, "%4d %-10ld\t", i, (long)database.yms[i].value);
|
|
|
|
sprintf(buffer, "%4d %5.3f\t", i, ((float)database.yms[i].value * database.yms[i].coef));
|
|
|
|
len = strlen(buffer);
|
|
|
|
pItem->WriteData((BYTE *)buffer, len, ord);
|
|
|
|
if (i % 6 == 5)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= DATABASE_YM_NUM) return FALSE;
|
|
|
|
//sprintf(buffer, "%4d %-10ld\t", pt, (long)database.yms[pt].value);
|
|
|
|
sprintf(buffer, "%4d %5.3f\t", pt, ((float)database.yms[pt].value * database.yms[pt].coef));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 6 == 5)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= DATABASE_YM_NUM) return FALSE;
|
|
|
|
database.yms[pt].value = atol(pVal);
|
|
|
|
sprintf(buffer, "%4d %-10ld\r\n", pt, (long)database.yms[pt].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxDBYK(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int pt;
|
|
|
|
BOOLEAN value;
|
|
|
|
char *pPoint;
|
|
|
|
char *pVal;
|
|
|
|
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pPoint = strchr(pData, ' ');
|
|
|
|
if (pPoint == NULL) return FALSE;
|
|
|
|
*pPoint = '\0'; pPoint++;
|
|
|
|
pVal = strchr(pPoint, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pPoint);
|
|
|
|
if (pt == 0 && pPoint[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= DATABASE_YK_NUM) return FALSE;
|
|
|
|
if (strcmp(pVal, "on") == 0)
|
|
|
|
{
|
|
|
|
value = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pVal, "off") == 0)
|
|
|
|
{
|
|
|
|
value = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
vLog(LOG_DEBUG, "Try to %s point(%d) to %s.\r\n", pData, pt, pVal);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
if (strcmp(pData, "select") == 0)
|
|
|
|
{
|
|
|
|
struYK* pYK = &database.yks[pt];
|
|
|
|
pYK->value = value;
|
|
|
|
pYK->state = YKS_SELREQ;
|
|
|
|
pYK->result = YKR_IDLE;
|
|
|
|
pYK->op_time = system32.timers;
|
|
|
|
//m_nSelectCount = 0;
|
|
|
|
//m_nYKState = YKS_SELING;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "execute") == 0)
|
|
|
|
{
|
|
|
|
struYK* pYK = &database.yks[pt];
|
|
|
|
pYK->value = value;
|
|
|
|
pYK->state = YKS_EXEREQ;
|
|
|
|
pYK->result = YKR_IDLE;
|
|
|
|
//m_nYKState = YKS_EXEING;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-12-16 17:02:35 +08:00
|
|
|
BOOLEAN CZJD3100Process::OnSyntanProcessInfo(char *pData, int ord)
|
|
|
|
{
|
2024-12-16 17:23:02 +08:00
|
|
|
//int pid;
|
|
|
|
//char *pCmd;
|
2024-12-16 17:02:35 +08:00
|
|
|
char buffer[2048];
|
|
|
|
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
2024-12-26 16:54:13 +08:00
|
|
|
|
2024-12-16 17:23:02 +08:00
|
|
|
if (strcmp(pData, "get") == 0)
|
2024-12-16 17:02:35 +08:00
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
2024-12-16 17:23:02 +08:00
|
|
|
for (int k = 0; k < PROCESSES_NUM; k++)
|
2024-12-16 17:02:35 +08:00
|
|
|
{
|
2024-12-16 17:23:02 +08:00
|
|
|
int pid = k;
|
|
|
|
if ((config.processes[pid].state & 0x01) != TRUE) continue;
|
|
|
|
snprintf(buffer, sizeof(buffer), "Pid: %d, Name: %s", pid, config.processes[pid].name);
|
2024-12-16 17:02:35 +08:00
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
2024-12-16 17:23:02 +08:00
|
|
|
if (m_proto2name_map.find(config.processes[pid].proto) != m_proto2name_map.end())
|
|
|
|
{
|
|
|
|
snprintf(buffer, sizeof(buffer), ", protocol: %s", m_proto2name_map[config.processes[pid].proto].c_str());
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(buffer, sizeof(buffer), ",%s", "unknow protocol");
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
}
|
2024-12-26 16:54:13 +08:00
|
|
|
snprintf(buffer, sizeof(buffer), ", softdog is: %d, link units: ", config.processes[pid].softdog);
|
2024-12-16 17:02:35 +08:00
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
2024-12-16 17:23:02 +08:00
|
|
|
for (int i = 0; i < PROCESS_UNIT_NUM; i++)
|
|
|
|
{
|
|
|
|
if (config.processes[pid].units[i] < 0) continue;
|
2024-12-26 16:54:13 +08:00
|
|
|
if (i == 0) snprintf(buffer, sizeof(buffer), "%d-%d", config.processes[pid].units[i], config.units[config.processes[pid].units[i]].softdog);
|
|
|
|
else snprintf(buffer, sizeof(buffer), ", %d-%d", config.processes[pid].units[i], config.units[config.processes[pid].units[i]].softdog);
|
2024-12-16 17:23:02 +08:00
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
2024-12-16 17:02:35 +08:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-07-08 10:27:17 +08:00
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnit(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
uid = (int)atoi(pData);
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM) uid = 0;
|
|
|
|
pData = pCmd;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd != NULL)
|
|
|
|
{
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
}
|
|
|
|
if (strcmp(pData, "yx") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxUnitYX(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "yc") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxUnitYC(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "ym") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxUnitYM(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitYX(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < config.units[uid].yxcount; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%4d %-3s %-2s\t", i, (config.units[uid].yxs[i].value ? "ON" : "OFF"), ((config.units[uid].yxs[i].qds & 0x80) ? "IV" : " "));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yxcount) return FALSE;
|
|
|
|
sprintf(buffer, "%4d %-3s %-2s\t", pt, (config.units[uid].yxs[pt].value ? "ON" : "OFF"), ((config.units[uid].yxs[pt].qds & 0x80) ? "IV" : " "));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
if (strcmp(pVal, "on") != 0 && strcmp(pVal, "off") != 0) return FALSE;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yxcount) return FALSE;
|
|
|
|
BOOLEAN yx = strcmp(pVal, "on") == 0 ? TRUE : FALSE;
|
|
|
|
//set unit YXBW and SOE
|
|
|
|
SetUnitYX(uid, pt, yx);
|
|
|
|
SetUnitYXBW(uid, pt, yx, system32.now, YXBWT_DEV);
|
|
|
|
SetUnitSOE(uid, pt, yx, system32.now);
|
|
|
|
sprintf(buffer, "%4d %-3s\r\n", pt, (yx ? "ON" : "OFF"));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitYC(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char* pCmd;
|
|
|
|
char* pVal;
|
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < config.units[uid].yccount; i++)
|
|
|
|
{
|
|
|
|
//sprintf(buffer, "%4d %-5d %-2s\t", i, (int)config.units[uid].ycs[i].value, (config.units[uid].ycs[i].iv ? "IV" : " "));
|
|
|
|
int udb = config.units[uid].ycs[i].order;
|
|
|
|
float value;
|
|
|
|
if (udb < 0 || udb >= DATABASE_YC_NUM)
|
|
|
|
{
|
|
|
|
value = (float)config.units[uid].ycs[i].value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-11-25 10:59:23 +08:00
|
|
|
value = (float)config.units[uid].ycs[i].value * config.units[uid].ycs[i].coef + config.units[uid].ycs[i].base;
|
2024-07-08 10:27:17 +08:00
|
|
|
}
|
|
|
|
sprintf(buffer, "%4d %5.3f %-2s\t", i, value, ((config.units[uid].ycs[i].qds & 0x80) ? "IV" : " "));
|
|
|
|
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal ++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt < ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yccount) return FALSE;
|
|
|
|
int udb = config.units[uid].ycs[pt].order;
|
|
|
|
float value;
|
|
|
|
if (udb < 0 || udb >= DATABASE_YC_NUM)
|
|
|
|
{
|
|
|
|
value = (float)config.units[uid].ycs[pt].value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = (float)config.units[uid].ycs[pt].value * database.ycs[udb].coef + database.ycs[udb].base;
|
|
|
|
}
|
|
|
|
//sprintf(buffer, "%4d %-5d %-2s\t", pt, (int)config.units[uid].ycs[pt].value, (config.units[uid].ycs[pt].iv ? "IV" : " "));
|
|
|
|
sprintf(buffer, "%4d %5.3f %-2s\t", pt, value, ((config.units[uid].ycs[pt].qds & 0x80) ? "IV" : " "));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yccount) return FALSE;
|
|
|
|
LONG yc = (LONG)atoi(pVal);
|
|
|
|
SetUnitYC(uid, pt, yc, 0x00);
|
|
|
|
sprintf(buffer, "%4d %-5d\r\n", pt, (int)yc);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitYM(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char* pCmd;
|
|
|
|
char* pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < config.units[uid].ymcount; i++)
|
|
|
|
{
|
|
|
|
//sprintf(buffer, "%4d %-10ld\t", i, (long)config.units[uid].yms[i].value);
|
|
|
|
sprintf(buffer, "%4d %5.3f\t", i, GetUnitYMReal(uid, i));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 6 == 5)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].ymcount) return FALSE;
|
|
|
|
//sprintf(buffer, "%4d %-10ld\t", pt, (long)config.units[uid].yms[pt].value);
|
|
|
|
sprintf(buffer, "%4d %5.3f\t", pt, GetUnitYMReal(uid, pt));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 6 == 5)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= config.units[uid].ymcount) return FALSE;
|
|
|
|
DWORD ym = atol(pVal);
|
|
|
|
SetUnitYM(uid, pt, ym);
|
|
|
|
sprintf(buffer, "%4d %-10ld\r\n", pt, (long)ym);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxChannel(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int channel;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
channel = atoi(pData);
|
|
|
|
if (channel < 0 || channel >= PROCESSES_NUM)
|
|
|
|
{
|
|
|
|
channel = 0;
|
|
|
|
}
|
|
|
|
if (strcmp(pCmd, "draw") == 0)
|
|
|
|
{
|
|
|
|
channelBuffer.mon_port = channel;
|
|
|
|
channelBuffer.enabled = TRUE;
|
|
|
|
pItem->m_command = 100;
|
|
|
|
}
|
|
|
|
else if (strcmp(pCmd, "stop") == 0)
|
|
|
|
{
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_port = -1;
|
|
|
|
pItem->m_command = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxChannelData(int ord)
|
|
|
|
{
|
|
|
|
if (ord < 0 || ord >= PROCESS_UNIT_NUM) return FALSE;
|
|
|
|
if (NULL == channelBuffer.buf) return FALSE;
|
|
|
|
if (!channelBuffer.enabled) return FALSE;
|
|
|
|
if (channelBuffer.mon_port < 0 || channelBuffer.mon_port >= PROCESSES_NUM) return FALSE;
|
|
|
|
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
char str_len[4];
|
|
|
|
char disp[2048];
|
|
|
|
int disp_len = 0;
|
|
|
|
int len = 0;
|
|
|
|
while (channelBuffer.load != channelBuffer.save)
|
|
|
|
{ //读取一个字节判断该字节是否位t和r
|
|
|
|
len = OnReadChannelRingBuff(&disp[disp_len], 1);
|
|
|
|
if (disp[disp_len] == 't' || disp[disp_len] == 'r') {
|
|
|
|
OnReadChannelRingBuff(str_len, 4);
|
|
|
|
len = atoi(str_len);
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
disp_len = 0;
|
|
|
|
if (disp[0] == 'r') pItem->WriteData((BYTE *)"[Recv]", strlen("[Recv]"), ord);
|
|
|
|
else if (disp[0] == 't') pItem->WriteData((BYTE *)"[Send]", strlen("[Send]"), ord);
|
|
|
|
memset(disp, '\0', sizeof(disp));
|
|
|
|
len = OnReadChannelRingBuff(disp, len);
|
|
|
|
disp[len] = '\n';
|
|
|
|
pItem->WriteData((BYTE *)disp, strlen(disp), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
disp_len += len;
|
|
|
|
}
|
|
|
|
if (disp_len) pItem->WriteData((BYTE*)disp, disp_len, ord);
|
|
|
|
#if 0
|
|
|
|
char* disp;
|
|
|
|
std::vector<char> msg;
|
|
|
|
msg.clear();
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
while (channelBuffer.load != channelBuffer.save)
|
|
|
|
{
|
|
|
|
if (channelBuffer.buf[channelBuffer.load] != 'z')
|
|
|
|
{
|
|
|
|
msg.push_back(channelBuffer.buf[channelBuffer.load]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
disp = new char[msg.size()];
|
|
|
|
memset(disp, 0, msg.size());
|
|
|
|
copy(msg.begin() + 1, msg.end(), disp);
|
|
|
|
if (msg[0] == 'r')
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"[Recv]", strlen("[Recv]"), ord);
|
|
|
|
}
|
|
|
|
else if (msg[0] == 't')
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"[Send]", strlen("[Send]"), ord);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)disp, strlen(disp), ord);
|
|
|
|
pItem->WriteData((BYTE *)"\n", strlen("\n"), ord);
|
|
|
|
msg.clear();
|
|
|
|
delete [] disp;
|
|
|
|
}
|
|
|
|
channelBuffer.load++;
|
|
|
|
channelBuffer.load &= (MAX_DISPLAY_BUFFER_SIZE-1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitDisplay(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
uid = atoi(pData);
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM)
|
|
|
|
{
|
|
|
|
uid = -1;
|
|
|
|
}
|
|
|
|
if (strcmp(pCmd, "draw") == 0)
|
|
|
|
{
|
|
|
|
channelBuffer.mon_unit = uid;
|
|
|
|
channelBuffer.enabled = TRUE;
|
|
|
|
pItem->m_command = 101;
|
|
|
|
}
|
|
|
|
else if (strcmp(pCmd, "stop") == 0)
|
|
|
|
{
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_unit = -1;
|
|
|
|
pItem->m_command = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitDisplayData(int ord)
|
|
|
|
{
|
|
|
|
if (ord < 0 || ord >= PROCESS_UNIT_NUM) return FALSE;
|
|
|
|
if (NULL == channelBuffer.buf) return FALSE;
|
|
|
|
if (!channelBuffer.enabled) return FALSE;
|
|
|
|
if (channelBuffer.mon_unit < 0 || channelBuffer.mon_unit >= UNIT_NUM) return FALSE;
|
|
|
|
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
char str_len[4];
|
|
|
|
char disp[2048];
|
|
|
|
int disp_len = 0;
|
|
|
|
int len = 0;
|
|
|
|
while (channelBuffer.load != channelBuffer.save)
|
|
|
|
{ //读取一个字节判断该字节是否位t和r
|
|
|
|
len = OnReadChannelRingBuff(&disp[disp_len], 1);
|
|
|
|
if (disp[disp_len] == 't' || disp[disp_len] == 'r') {
|
|
|
|
OnReadChannelRingBuff(str_len, 4);
|
|
|
|
len = atoi(str_len);
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
disp_len = 0;
|
|
|
|
if (disp[0] == 'r') pItem->WriteData((BYTE *)"[Recv]", strlen("[Recv]"), ord);
|
|
|
|
else if (disp[0] == 't') pItem->WriteData((BYTE *)"[Send]", strlen("[Send]"), ord);
|
|
|
|
memset(disp, '\0', sizeof(disp));
|
|
|
|
len = OnReadChannelRingBuff(disp, len);
|
|
|
|
disp[len] = '\n';
|
|
|
|
pItem->WriteData((BYTE *)disp, strlen(disp), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
disp_len += len;
|
|
|
|
}
|
|
|
|
if (disp_len) pItem->WriteData((BYTE*)disp, disp_len, ord);
|
|
|
|
#if 0
|
|
|
|
char* disp;
|
|
|
|
std::vector<char> msg;
|
|
|
|
msg.clear();
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
while (channelBuffer.load != channelBuffer.save)
|
|
|
|
{
|
|
|
|
if (channelBuffer.buf[channelBuffer.load] != 'z')
|
|
|
|
{
|
|
|
|
msg.push_back(channelBuffer.buf[channelBuffer.load]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
disp = new char[msg.size()];
|
|
|
|
memset(disp, 0, msg.size());
|
|
|
|
copy(msg.begin() + 1, msg.end(), disp);
|
|
|
|
if (msg[0] == 'r')
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"[Recv]", strlen("[Recv]"), ord);
|
|
|
|
}
|
|
|
|
else if (msg[0] == 't')
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"[Send]", strlen("[Send]"), ord);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)disp, strlen(disp), ord);
|
|
|
|
msg.clear();
|
|
|
|
delete [] disp;
|
|
|
|
}
|
|
|
|
channelBuffer.load++;
|
|
|
|
channelBuffer.load &= (MAX_DISPLAY_BUFFER_SIZE-1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxMsg(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
if (strcmp(pData, "draw") == 0)
|
|
|
|
{
|
|
|
|
msgBuffer.enabled = TRUE;
|
|
|
|
pItem->m_command = 200;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "stop") == 0)
|
|
|
|
{
|
|
|
|
msgBuffer.enabled = FALSE;
|
|
|
|
pItem->m_command = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxMsgData(int ord)
|
|
|
|
{
|
|
|
|
if (ord < 0 || ord >= PROCESS_UNIT_NUM) return FALSE;
|
|
|
|
if (NULL == msgBuffer.buf) return FALSE;
|
|
|
|
if (!msgBuffer.enabled) return FALSE;
|
|
|
|
|
|
|
|
int len;
|
|
|
|
char buffer[512+32];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
while (msgBuffer.load != msgBuffer.save)
|
|
|
|
{
|
|
|
|
len = ReadMsgRingBuff(buffer, 512);
|
|
|
|
pItem->WriteData((BYTE*)buffer, len, ord);
|
|
|
|
usleep(1000);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitsStatus(char *pData, int ord) //获取单元状态
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < UNIT_NUM; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%3d %-3s %-3s\t", i, (config.units[i].value ? "ON" : "OFF"), (config.units[i].type ? "IED" : "CS"));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= UNIT_NUM) return FALSE;
|
|
|
|
sprintf(buffer, "%3d %-3s %-3s\t", pt, (config.units[pt].value ? "ON" : "OFF"), (config.units[pt].type ? "IED" : "CS"));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitExt(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
uid = (int)atoi(pData);
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM) uid = 0;
|
|
|
|
pData = pCmd;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd != NULL)
|
|
|
|
{
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
}
|
|
|
|
if (strcmp(pData, "yx") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxUnitExtYX(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "yc") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxUnitExtYC(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "ym") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxUnitExtYM(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitExtYX(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < config.units[uid].yxcount; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%d %d\t", i, config.units[uid].yxs[i].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yxcount) return FALSE;
|
|
|
|
sprintf(buffer, "%d %d\t", pt, config.units[uid].yxs[pt].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
if (strcmp(pVal, "on") != 0 && strcmp(pVal, "off") != 0) return FALSE;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yxcount) return FALSE;
|
|
|
|
BOOLEAN yx = strcmp(pVal, "on") == 0 ? TRUE : FALSE;
|
|
|
|
//set unit YXBW and SOE
|
|
|
|
SetUnitYX(uid, pt, yx);
|
|
|
|
SetUnitYXBW(uid, pt, yx, system32.now, YXBWT_DEV);
|
|
|
|
SetUnitSOE(uid, pt, yx, system32.now);
|
|
|
|
sprintf(buffer, "%d %s\r\n", pt, (yx ? "ON" : "OFF"));
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitExtYC(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char* pCmd;
|
|
|
|
char* pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < config.units[uid].yccount; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%d %d\t", i, config.units[uid].ycs[i].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal ++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt < ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yccount) return FALSE;
|
|
|
|
sprintf(buffer, "%d %d\t", pt, config.units[uid].ycs[pt].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 8 == 7)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yccount) return FALSE;
|
|
|
|
LONG yc = (LONG)atoi(pVal);
|
|
|
|
SetUnitYC(uid, pt, yc, 0x00);
|
|
|
|
sprintf(buffer, "%d %d\r\n", pt, (int)yc);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxUnitExtYM(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char* pCmd;
|
|
|
|
char* pVal;
|
|
|
|
char buffer[256];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(pCmd, "all") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; i < config.units[uid].ymcount; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%d %d\t", i, config.units[uid].yms[i].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 6 == 5)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"ZJD3100# \r\n", strlen("ZJD3100# \r\n"), ord);
|
|
|
|
for (i = 0; pt <= ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].ymcount) return FALSE;
|
|
|
|
sprintf(buffer, "%d %d\t", pt, config.units[uid].yms[pt].value);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
if (i % 6 == 5)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)"\r\n", strlen("\r\n"), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "set") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal == NULL) return FALSE;
|
|
|
|
*pVal = '\0'; pVal++;
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
if (pt == 0 && pCmd[0] != '0') return FALSE;
|
|
|
|
if (pt < 0 || pt >= config.units[uid].ymcount) return FALSE;
|
|
|
|
DWORD ym = atol(pVal);
|
|
|
|
SetUnitYM(uid, pt, ym);
|
|
|
|
sprintf(buffer, "%d %ld\r\n", pt, (long)ym);
|
|
|
|
pItem->WriteData((BYTE *)buffer, strlen(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DBG_VIEW_TOOL
|
|
|
|
//"ext sys" "<hostname,> get\r\n"
|
|
|
|
//"ext info" "<channel,msg> get\r\n" //配置
|
|
|
|
//"ext cfg" "<hardware,process,unit> get\r\n" //配置
|
|
|
|
//"ext unit [uid] " "<yx,yc,ym> get [st] [et]\r\n"
|
|
|
|
//"ext file" "<info,open,close,read> get\r\n" //文件
|
|
|
|
//"ext file" "<write> save\r\n" //文件
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExt(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
|
|
|
|
if (strcmp(pData, "sys") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtSys(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "info") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtInfo(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "cfg") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtCfg(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "file") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtFile(pCmd, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "unit") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtUnit(pCmd, ord);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtSys(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
|
|
|
|
if (strcmp(pData, "hostname") == 0) return OnSyntaxExtSysHostName(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "application") == 0) return OnSyntaxExtSysAppReboot(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "system") == 0) return OnSyntaxExtSysReboot(pCmd, ord);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtSysHostName(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
char buffer[65];
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
gethostname(buffer, sizeof(buffer));
|
|
|
|
pItem->WriteData((BYTE*)buffer, sizeof(buffer), ord);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtSysReboot(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
char buffer[65];
|
|
|
|
if (strcmp(pData, "reboot") == 0)
|
|
|
|
{
|
|
|
|
system("reboot");
|
|
|
|
WORD test = 1;
|
|
|
|
memcpy(buffer, &test, sizeof(WORD));
|
|
|
|
pItem->WriteData((BYTE*)buffer, sizeof(buffer), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtSysAppReboot(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
char buffer[65];
|
|
|
|
if (strcmp(pData, "reboot") == 0)
|
|
|
|
{
|
|
|
|
system("killall -9 application");
|
|
|
|
WORD test = 1;
|
|
|
|
memcpy(buffer, &test, sizeof(WORD));
|
|
|
|
pItem->WriteData((BYTE*)buffer, sizeof(buffer), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtInfo(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
|
|
|
|
if (strcmp(pData, "msg") == 0) return OnSyntaxExtInfoMsg(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "channel") == 0) return OnSyntaxExtInfoChannel(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "status") == 0) return OnSyntaxExtInfoStatus(pCmd, ord);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtInfoMsg(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
if (strcmp(pData, "draw") == 0)
|
|
|
|
{
|
|
|
|
if (!msgBuffer.enabled) msgBuffer.enabled = TRUE;
|
|
|
|
int len;
|
|
|
|
char buffer[512+32];
|
|
|
|
while (msgBuffer.load != msgBuffer.save)
|
|
|
|
{
|
|
|
|
len = ReadMsgRingBuff(buffer, 512);
|
|
|
|
pItem->WriteData((BYTE*)buffer, len, ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "stop") == 0)
|
|
|
|
{
|
|
|
|
if (msgBuffer.enabled) msgBuffer.enabled = FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtInfoChannel(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int channel;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
|
|
|
|
channel = atoi(pData);
|
|
|
|
|
|
|
|
if (channel < 0 || channel >= PROCESSES_NUM)
|
|
|
|
{
|
|
|
|
channel = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(pCmd, "draw") == 0)
|
|
|
|
{
|
|
|
|
if (!channelBuffer.enabled)
|
|
|
|
{
|
|
|
|
channelBuffer.mon_port = channel;
|
|
|
|
channelBuffer.enabled = TRUE;
|
|
|
|
}
|
|
|
|
char str_len[4];
|
|
|
|
char disp[2048];
|
|
|
|
int disp_len = 0;
|
|
|
|
int len = 0;
|
|
|
|
while (channelBuffer.load != channelBuffer.save)
|
|
|
|
{ //读取一个字节判断该字节是否位t和r
|
|
|
|
len = OnReadChannelRingBuff(&disp[disp_len], 1);
|
|
|
|
if (disp[disp_len] == 't' || disp[disp_len] == 'r') {
|
|
|
|
OnReadChannelRingBuff(str_len, 4);
|
|
|
|
len = atoi(str_len);
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
disp_len = 0;
|
|
|
|
{
|
|
|
|
if (disp[0] == 'r') pItem->WriteData((BYTE *)"[Recv]", strlen("[Recv]"), ord);
|
|
|
|
else if (disp[0] == 't') pItem->WriteData((BYTE *)"[Send]", strlen("[Send]"), ord);
|
|
|
|
}
|
|
|
|
memset(disp, '\0', sizeof(disp));
|
|
|
|
len = OnReadChannelRingBuff(disp, len);
|
|
|
|
disp[len] = '\n';
|
|
|
|
pItem->WriteData((BYTE *)disp, strlen(disp), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
disp_len += len;
|
|
|
|
}
|
|
|
|
if (disp_len) pItem->WriteData((BYTE*)disp, disp_len, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pCmd, "stop") == 0)
|
|
|
|
{
|
|
|
|
if (channelBuffer.enabled)
|
|
|
|
{
|
|
|
|
channelBuffer.enabled = FALSE;
|
|
|
|
channelBuffer.mon_port = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtInfoStatus(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
if (strcmp(pData, "units") == 0)
|
|
|
|
{
|
|
|
|
//BYTE buffer[UNIT_NUM];
|
|
|
|
#pragma pack(1)
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
QLONG irn;
|
|
|
|
BYTE value;
|
|
|
|
} buffer[UNIT_NUM];
|
|
|
|
#pragma pack()
|
|
|
|
for (int i = 0; i < UNIT_NUM; i++)
|
|
|
|
{
|
|
|
|
buffer[i].irn = GetUnitIRNByUid(i);
|
|
|
|
buffer[i].value = (BYTE)config.units[i].value | (config.units[i].state ? 0x00 : 0x80);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE*)buffer, sizeof(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "processes") == 0)
|
|
|
|
{
|
|
|
|
#pragma pack(1)
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
QLONG irn;
|
|
|
|
BYTE value;
|
|
|
|
} buffer[PROCESSES_NUM];
|
|
|
|
#pragma pack()
|
|
|
|
for (int i = 0; i < PROCESSES_NUM; i++)
|
|
|
|
{
|
|
|
|
buffer[i].irn = GetProcessIRNByPid(i);
|
|
|
|
buffer[i].value = ((config.processes[i].softdog >= PROCESS_WATCHDOG_TIME) ? false : true) | (config.processes[i].state ? 0x00 : 0x80);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE*)buffer, sizeof(buffer), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtCfg(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
char *pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
|
|
|
|
if (strcmp(pData, "port") == 0) return OnSyntaxExtCfgPort(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "process") == 0) return OnSyntaxExtCfgProcess(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "unit") == 0) return OnSyntaxExtCfgUnit(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "static") == 0) return OnSyntaxExtCfgStatic(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "path") == 0) return OnSyntaxExtCfgPath(pCmd, ord);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtCfgPath(char *pData, int ord)
|
|
|
|
{
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)configpath, strlen(configpath), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtCfgPort(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
index = atoi(pData);
|
|
|
|
if (index < 0 || index >= HARDWARE_PORTS_NUM) return TRUE;
|
|
|
|
if (strcmp(pCmd, "get") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)&config.hardware.ports[index], sizeof(struPort), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtCfgProcess(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int pid;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
pid = atoi(pData);
|
|
|
|
if (pid < 0 || pid >= PROCESSES_NUM) return TRUE;
|
|
|
|
if (strcmp(pCmd, "get") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)&config.processes[pid], sizeof(struProcess), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtCfgUnit(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
uid = atoi(pData);
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM) return TRUE;
|
|
|
|
if (strcmp(pCmd, "get") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)&config.units[uid], sizeof(struUnit), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtCfgStatic(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
char* pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
uid = atoi(pData);
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM) return TRUE;
|
|
|
|
if (strcmp(pCmd, "get") == 0)
|
|
|
|
{
|
|
|
|
pItem->WriteData((BYTE *)&static_units[uid], sizeof(struUnitStatic), ord);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtFile(char *pData, int ord)
|
|
|
|
{
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
|
|
|
|
if (strcmp(pData, "info") == 0) return OnSyntaxExtFileGetInfo(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "open") == 0) return OnSyntaxExtFileOpen(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "close") == 0) return OnSyntaxExtFileClose(pCmd, ord);
|
|
|
|
else if (strcmp(pData, "read") == 0) return OnSyntaxExtFileRead(pCmd, ord);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtFileGetInfo(char* pData, int ord)
|
|
|
|
{
|
|
|
|
char* fileName;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
fileName = pData;
|
|
|
|
|
|
|
|
memset(&m_fileStat, 0, sizeof(m_fileStat));
|
|
|
|
int result = stat(fileName, &m_fileStat);
|
|
|
|
|
|
|
|
BYTE buffer[12];
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
buffer[0] = result;
|
|
|
|
if (result == 0)
|
|
|
|
{
|
|
|
|
buffer[4] = m_fileStat.st_size & 0xff;
|
|
|
|
buffer[5] = (m_fileStat.st_size >> 8) & 0xff;
|
|
|
|
buffer[6] = (m_fileStat.st_size >> 16) & 0xff;
|
|
|
|
buffer[7] = (m_fileStat.st_size >> 24) & 0xff;
|
|
|
|
buffer[8] = (DWORD)m_fileStat.st_mtime & 0xff;
|
|
|
|
buffer[9] = ((DWORD)m_fileStat.st_mtime >> 8) & 0xff;
|
|
|
|
buffer[10] = ((DWORD)m_fileStat.st_mtime >> 16) & 0xff;
|
|
|
|
buffer[11] = ((DWORD)m_fileStat.st_mtime >> 24) & 0xff;
|
|
|
|
}
|
|
|
|
pItem->WriteData(buffer, sizeof(buffer), ord);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtFileOpen(char* pData, int ord)
|
|
|
|
{
|
|
|
|
char* pCmd;
|
|
|
|
char* fileName;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (NULL == pItem) return FALSE;
|
|
|
|
if (NULL == pData) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
char* mode = pData;
|
|
|
|
fileName = pCmd;
|
|
|
|
|
|
|
|
m_pFile = fopen(fileName, mode);
|
|
|
|
BOOLEAN ret = TRUE;
|
|
|
|
if (m_pFile == NULL) ret = FALSE;
|
|
|
|
pItem->WriteData((BYTE *)&ret, sizeof(ret), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtFileClose(char* pBuf, int ord)
|
|
|
|
{
|
|
|
|
BOOLEAN ret = -1;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (m_pFile)
|
|
|
|
{
|
|
|
|
ret = fclose(m_pFile);
|
|
|
|
}
|
|
|
|
pItem->WriteData((BYTE *)&ret, sizeof(ret), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtFileRead(char* pData, int ord)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
char buffer[2048+32];
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
offset = atoi(pData);
|
|
|
|
|
|
|
|
BYTE result = 0;
|
|
|
|
if (fseek(m_pFile, offset, SEEK_SET) != 0)
|
|
|
|
{
|
|
|
|
result = -1;
|
|
|
|
pItem->WriteData((BYTE *)&result, sizeof(BYTE), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
int left_size = m_fileStat.st_size - offset;
|
|
|
|
count = left_size > 2048 ? 2048 : left_size;
|
|
|
|
if (left_size > 2048) result = 0;
|
|
|
|
else result = 1;
|
|
|
|
pItem->WriteData((BYTE *)&result, sizeof(BYTE), ord);
|
|
|
|
fread((char *)buffer, count, 1, m_pFile);
|
|
|
|
pItem->WriteData((BYTE *)buffer, count, ord);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtFileWrite(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
int datalen;
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
offset = atoi(pData);
|
|
|
|
|
|
|
|
pData = pCmd;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (NULL == pCmd) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
datalen = atoi(pData);
|
|
|
|
|
|
|
|
BYTE result = 0;
|
|
|
|
if (fseek(m_pFile, offset, SEEK_SET) != 0)
|
|
|
|
{
|
|
|
|
result = -1;
|
|
|
|
pItem->WriteData((BYTE *)&result, sizeof(BYTE), ord);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
fwrite(pCmd, datalen, 1, m_pFile);
|
|
|
|
pItem->WriteData((BYTE *)&result, sizeof(BYTE), ord);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtUnit(char *pData, int ord)
|
|
|
|
{
|
|
|
|
int uid;
|
|
|
|
char *pCmd;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
uid = (int)atoi(pData);
|
|
|
|
if (uid < 0 || uid >= UNIT_NUM) uid = 0;
|
|
|
|
pData = pCmd;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd != NULL)
|
|
|
|
{
|
|
|
|
*pCmd = '\0';
|
|
|
|
pCmd++;
|
|
|
|
}
|
|
|
|
if (strcmp(pData, "yx") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtUnitYX(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "yc") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtUnitYC(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
else if (strcmp(pData, "ym") == 0)
|
|
|
|
{
|
|
|
|
return OnSyntaxExtUnitYM(pCmd, uid, ord);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtUnitYX(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
for (i = 0; pt < ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yxcount) return FALSE;
|
|
|
|
pItem->WriteData((BYTE *)&config.units[uid].yxs[pt], sizeof(struUnitYX), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtUnitYC(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
for (i = 0; pt < ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].yccount) return FALSE;
|
|
|
|
pItem->WriteData((BYTE *)&config.units[uid].ycs[pt], sizeof(struUnitYC), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN CZJD3100Process::OnSyntaxExtUnitYM(char *pData, int uid, int ord)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int pt, ptEnd;
|
|
|
|
char *pCmd;
|
|
|
|
char *pVal;
|
|
|
|
CZJD3100ProcessItem* pItem = (CZJD3100ProcessItem *)GetItem(ord);
|
|
|
|
if (pItem == NULL) return FALSE;
|
|
|
|
|
|
|
|
if (pData == NULL) return FALSE;
|
|
|
|
pCmd = strchr(pData, ' ');
|
|
|
|
if (pCmd == NULL) return FALSE;
|
|
|
|
*pCmd = '\0'; pCmd++;
|
|
|
|
if (strcmp(pData, "get") == 0)
|
|
|
|
{
|
|
|
|
pVal = strchr(pCmd, ' ');
|
|
|
|
if (pVal != NULL)
|
|
|
|
{
|
|
|
|
*pVal = '\0';
|
|
|
|
pVal++;
|
|
|
|
}
|
|
|
|
pt = atoi(pCmd);
|
|
|
|
ptEnd = pt+1;
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
ptEnd = atoi(pVal);
|
|
|
|
}
|
|
|
|
for (i = 0; pt < ptEnd; pt++, i++)
|
|
|
|
{
|
|
|
|
if (pt < 0 || pt >= config.units[uid].ymcount) return FALSE;
|
|
|
|
pItem->WriteData((BYTE *)&config.units[uid].yms[pt], sizeof(struUnitYM), ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|