EMS,硬件设计文件以及软件功能验证程序
This commit is contained in:
21
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/Makefile
Normal file
21
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
CC = arm-linux-gcc
|
||||
|
||||
edit: main.o script.o
|
||||
|
||||
$(CC) -o script main.o script.o
|
||||
|
||||
main.o: main.c script.h
|
||||
|
||||
$(CC) -c main.c
|
||||
|
||||
script.o: script.c script.h
|
||||
|
||||
$(CC) -c script.c
|
||||
|
||||
clean:
|
||||
rm main.o script.o
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11216
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/initqtouchvar.c
Normal file
11216
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/initqtouchvar.c
Normal file
File diff suppressed because it is too large
Load Diff
11309
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/initqtouchvar.h
Normal file
11309
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/initqtouchvar.h
Normal file
File diff suppressed because it is too large
Load Diff
343
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/main.c
Normal file
343
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/main.c
Normal file
@@ -0,0 +1,343 @@
|
||||
#include <math.h>
|
||||
#include "script.h"
|
||||
|
||||
//<2F><>_INDEXΪQTouch<63>ж<EFBFBD>Ӧ<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>
|
||||
#define GF_TP_INDEX 105
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9>ʣ<EFBFBD><CAA3><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cal_Total_Load_Power<65><72>
|
||||
#define FH_TP_INDEX 1
|
||||
//<2F>е<EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD>ѹ
|
||||
#define SD_AV_INDEX 0
|
||||
//<2F>е<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD>ѹ
|
||||
#define SD_BV_INDEX 1
|
||||
//<2F>е<EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ѹ
|
||||
#define SD_CV_INDEX 2
|
||||
//<2F><><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD>ѹ
|
||||
#define CF_AV_INDEX 31
|
||||
//<2F><><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD>ѹ
|
||||
#define CF_BV_INDEX 32
|
||||
//<2F><><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ѹ
|
||||
#define CF_CV_INDEX 33
|
||||
//<2F><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>澯
|
||||
#define BMS_DLOW1_INDEX 767
|
||||
//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
||||
#define BMS_JC_INDEX 6
|
||||
//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
||||
#define BMS_JF_INDEX 7
|
||||
//<2F>е<EFBFBD><D0B5><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD>״̬
|
||||
#define SD_JXKGSTATE_INDEX 26
|
||||
//<2F><EFBFBD><F1B7A2BD>߿<EFBFBD><DFBF><EFBFBD>״̬
|
||||
#define CF_JXKGSTATE_INDEX 57
|
||||
//PCS<43><53><EFBFBD><EFBFBD>ģʽ
|
||||
#define PCS_RMODE_INDEX 3768
|
||||
|
||||
//PCS<43><53>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
#define PCS_START_H 10 //ʱ
|
||||
#define PCS_START_M 11 //<2F><>
|
||||
|
||||
//<2F><><EFBFBD>Ƶ<EFBFBD>λ
|
||||
//<2F>е<EFBFBD><D0B5><EFBFBD><EFBFBD>߿<EFBFBD><DFBF>ؿ<EFBFBD><D8BF>Ƶ<EFBFBD>
|
||||
#define SD_JXKG_INDEX 29
|
||||
//<2F><EFBFBD><F1B7A2BD>߿<EFBFBD><DFBF>ؿ<EFBFBD><D8BF>Ƶ<EFBFBD>
|
||||
#define CF_JXKG_INDEX 60
|
||||
//PCS<43><53><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>Ƶ<EFBFBD>
|
||||
#define PCS_RMODEKC_INDEX 582
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>
|
||||
#define PV_PKC1_INDEX 3544
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>
|
||||
#define PV_PKC2_INDEX 3633
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>
|
||||
#define PV_PKC3_INDEX 3722
|
||||
|
||||
|
||||
|
||||
int readFile() {
|
||||
char s[] = "/home/ctstor/ctfiles/maxvarindex";
|
||||
//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
int fd = open(s, O_RDONLY);
|
||||
|
||||
if(fd == -1) {
|
||||
printf("error is %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
printf("sucess fd = %d\n", fd);
|
||||
char buf[100];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
int a=3999;
|
||||
//read<61><64><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
while(read(fd, buf, sizeof(buf) - 1) > 0) {
|
||||
printf("%s\n", buf);
|
||||
char * str=buf;
|
||||
printf("%s-----\n", str);
|
||||
|
||||
sscanf(str,"%d",&a);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
}
|
||||
printf("%d---===--\n", a);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ǹر<C7B9>
|
||||
close(fd);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>㶨<EFBFBD><E3B6A8>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>
|
||||
double dTLoadP=0;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double dVMaxP = 0;
|
||||
//<2F>е<EFBFBD><D0B5><EFBFBD>ѹ״̬
|
||||
char cSDVN = 2;
|
||||
//<2F><EFBFBD>ѹ״̬
|
||||
char cCFVN = 2;
|
||||
|
||||
//<2F><><EFBFBD>㸺<EFBFBD><E3B8BA><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>
|
||||
//<2F><><EFBFBD>߹<EFBFBD>9<EFBFBD><39>·+<2B><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE>
|
||||
double cal_Total_Load_Power()
|
||||
{
|
||||
double dTLoadP = GetItemValue(0,136)+GetItemValue(0,167)+GetItemValue(0,198)+GetItemValue(0,229)+GetItemValue(0,260)+GetItemValue(0,291)+GetItemValue(0,322)+GetItemValue(0,353)+GetItemValue(0,384)+GetItemValue(0,415)+GetItemValue(0,446);
|
||||
/////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
||||
//<2F><><EFBFBD>Ӹ<EFBFBD><D3B8><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>
|
||||
|
||||
/////////////////////////////
|
||||
return dTLoadP;
|
||||
}
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>е<EFBFBD><D0B5><EFBFBD>ѹ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>0<EFBFBD><30>ʧ<EFBFBD>磬1<E7A3AC><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
//0<><30>ʧ<EFBFBD>磬<EFBFBD><E7A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
char check_SDV_Normal()
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||
double dAv = GetItemValue(0,SD_AV_INDEX);
|
||||
double dBv = GetItemValue(0,SD_BV_INDEX);
|
||||
double dCv = GetItemValue(0,SD_CV_INDEX);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ѹ>184<38><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if((dAv>184) && (dBv>184) && (dCv>184))
|
||||
return 1;
|
||||
//<2F><><EFBFBD><EFBFBD>ѹ<184<38><34>ʧ<EFBFBD><CAA7>
|
||||
if((dAv<184) && (dBv<184) && (dCv<184))
|
||||
return 0;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return 2;
|
||||
}
|
||||
//<2F><EFBFBD><F1B7A2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>´<EFBFBD><C2B4><EFBFBD>
|
||||
//<2F>ж<EFBFBD><D0B6>е<EFBFBD><D0B5><EFBFBD>ѹ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>0<EFBFBD><30>ʧ<EFBFBD>磬1<E7A3AC><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char check_CFV_Normal()
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||
double dAv = GetItemValue(0,CF_AV_INDEX);
|
||||
double dBv = GetItemValue(0,CF_BV_INDEX);
|
||||
double dCv = GetItemValue(0,CF_CV_INDEX);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ѹ>184<38><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if((dAv>184) && (dBv>184) && (dCv>184))
|
||||
return 1;
|
||||
//<2F><><EFBFBD><EFBFBD>ѹ<184<38><34>ʧ<EFBFBD><CAA7>
|
||||
if((dAv<184) && (dBv<184) && (dCv<184))
|
||||
return 0;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return 2;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void PVJR_Logic()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>2<EFBFBD><32>3<EFBFBD><33><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>
|
||||
double dPv1 = GetItemValue(0, PV_PKC1_INDEX);
|
||||
double dPv2 = GetItemValue(0, PV_PKC2_INDEX);
|
||||
double dPv3 = GetItemValue(0, PV_PKC3_INDEX);
|
||||
|
||||
//<2F><><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ȣ<EFBFBD>
|
||||
//3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>ǰռ<C7B0>ȼ<EFBFBD><C8BC><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨<EFBFBD><E8B6A8>ֵ<EFBFBD><D6B5>
|
||||
double dFactor = dTLoadP/dVMaxP;
|
||||
|
||||
int nPv1Set = dPv1*dFactor;
|
||||
int nPv2Set = dPv2*dFactor;
|
||||
int nPv3Set = dPv3*dFactor;
|
||||
char chSend1[200] = {0};
|
||||
sprintf(chSend1, "%d", nPv1Set);
|
||||
char chSend2[200] = {0};
|
||||
sprintf(chSend2, "%d", nPv2Set);
|
||||
char chSend3[200] = {0};
|
||||
sprintf(chSend3, "%d", nPv3Set);
|
||||
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
SetKcData(0, PV_PKC1_INDEX, chSend1);
|
||||
SetKcFlag(0,1);
|
||||
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
SetKcData(0, PV_PKC2_INDEX, chSend2);
|
||||
SetKcFlag(0,1);
|
||||
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
SetKcData(0, PV_PKC3_INDEX, chSend3);
|
||||
SetKcFlag(0,1);
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void BM_Logic()
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD>״̬<D7B4><CCAC>1<EFBFBD>ϣ<EFBFBD>0<EFBFBD><30>
|
||||
char cSDJXState = GetItemValue(0, SD_JXKGSTATE_INDEX);
|
||||
if(cSDJXState == 1){
|
||||
//<2F><><EFBFBD>ߺ<EFBFBD>բ<EFBFBD><D5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶԹ<C8B6><D4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>븺<EFBFBD><EBB8BA><EFBFBD>ܹ<EFBFBD><DCB9>ʣ<EFBFBD>
|
||||
if(dVMaxP > dTLoadP){
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>轵<EFBFBD><E8BDB5>
|
||||
PVJR_Logic();
|
||||
}
|
||||
}
|
||||
else if(cSDJXState == 0){
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
//<2F><><EFBFBD>ƽ<EFBFBD><C6BD>ߺ<EFBFBD>բ
|
||||
SetKcData(0, SD_JXKG_INDEX, "1 0");
|
||||
SetKcFlag(0,1);
|
||||
}
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void LM_Logic()
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD>״̬<D7B4><CCAC>1<EFBFBD>ϣ<EFBFBD>0<EFBFBD><30>
|
||||
char cSDJXState = GetItemValue(0, SD_JXKGSTATE_INDEX);
|
||||
//<2F><>ȡ<EFBFBD><EFBFBD><F1B7A2BD>߿<EFBFBD><DFBF><EFBFBD>״̬<D7B4><CCAC>1<EFBFBD>ϣ<EFBFBD>0<EFBFBD><30>
|
||||
char cCFJXState = GetItemValue(0, CF_JXKGSTATE_INDEX);
|
||||
//<2F><>ȡBMS<4D><53><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
char cBMSJCState = GetItemValue(0, BMS_JC_INDEX);
|
||||
//BMS<4D><53><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>澯
|
||||
char cBMSLow1State = GetItemValue(0, BMS_DLOW1_INDEX);
|
||||
//////////////////////////////////////////////////
|
||||
//PCS<43><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>
|
||||
//0:<3A>ر<EFBFBD>
|
||||
//1:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//2:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//3:<3A><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>
|
||||
//4:<3A><><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>
|
||||
//5:<3A><><EFBFBD><EFBFBD><EEB2A2>
|
||||
//6:<3A><><EFBFBD><EFBFBD>
|
||||
//7:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char cPCSState = GetItemValue(0, PCS_RMODE_INDEX);
|
||||
//////////////////////////////////////////////////
|
||||
int nCurH = GetSysItem(3);
|
||||
int nCurM = GetSysItem(4);
|
||||
int nPcsStartH = GetItemValue(0, PCS_START_H);
|
||||
int nPcsStartM = GetItemValue(0, PCS_START_M);
|
||||
if(cSDJXState == 0){
|
||||
printf("cSDJXState==0");
|
||||
//<2F><><EFBFBD>߷<EFBFBD>բ<EFBFBD><D5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶԹ<C8B6><D4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>븺<EFBFBD><EBB8BA><EFBFBD>ܹ<EFBFBD><DCB9>ʣ<EFBFBD>
|
||||
if(dVMaxP > dTLoadP){
|
||||
//<2F><>BMS<4D><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EMS<4D><53><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(cBMSJCState == 1){ //ʵ<><CAB5>ֵ<EFBFBD><D6B5>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>轵<EFBFBD><E8BDB5>
|
||||
PVJR_Logic();
|
||||
}
|
||||
}
|
||||
else if(dVMaxP < dTLoadP){
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F1B7A2BD>ߵ<EFBFBD>ѹ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>粻<EFBFBD><E7B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EMS<4D><53><EFBFBD><EFBFBD>PCSͣ<53><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պϲ<CFB2><F1B7A2BD>߿<EFBFBD><DFBF><EFBFBD>
|
||||
if(cCFVN == 0){//<2F><EFBFBD>ѹʧѹ
|
||||
if(cCFJXState == 0){ //<2F><EFBFBD><F1B7A2BD>ߴ<EFBFBD><DFB4>ڷ<EFBFBD>բ״̬
|
||||
//<2F><><EFBFBD>յ<EFBFBD>BMS<4D><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>澯<EFBFBD><E6BEAF>ʱ<EFBFBD><CAB1>
|
||||
//<2F><><EFBFBD><EFBFBD>PCSͣ<53><CDA3>
|
||||
if(cBMSLow1State == 1){
|
||||
if(cPCSState != 0){
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>PCSͣ<53><CDA3> д0xAAAA
|
||||
SetKcData(0, PCS_RMODEKC_INDEX, "43690");
|
||||
SetKcFlag(0,1);
|
||||
}
|
||||
//PCSͣ<53><CDA3><EFBFBD>ɸ<F3A3ACBF><C9B8><EFBFBD><EFBFBD>趨<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(cPCSState == 0){
|
||||
//<2F><>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD>PCS<43><53><EFBFBD><EFBFBD>
|
||||
if(nPcsStartH == nCurH && nPcsStartM == nCurM){
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>PCS<43><53><EFBFBD><EFBFBD> д0x5555
|
||||
SetKcData(0, PCS_RMODEKC_INDEX, "21845");
|
||||
SetKcFlag(0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(cCFJXState == 1){//<2F><EFBFBD><F1B7A2BD>ߴ<EFBFBD><DFB4>ں<EFBFBD>բ״̬
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
//<2F><><EFBFBD>Ʋ<C6B2><F1B7A2BD>߷<EFBFBD>բ
|
||||
SetKcData(0, CF_JXKG_INDEX, "0 1");
|
||||
SetKcFlag(0,1);
|
||||
}
|
||||
}
|
||||
else if(cCFVN == 1){//<2F><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||
if(cCFJXState == 0){
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
//<2F><><EFBFBD>Ʋ<C6B2><F1B7A2BD>ߺ<EFBFBD>բ
|
||||
SetKcData(0, CF_JXKG_INDEX, "1 0");
|
||||
SetKcFlag(0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(cSDJXState == 1){
|
||||
while(GetKcFlag(0) == 1){
|
||||
waitForMillisec(10);
|
||||
}
|
||||
//<2F><><EFBFBD>ƽ<EFBFBD><C6BD>߷<EFBFBD>բ
|
||||
SetKcData(0, SD_JXKG_INDEX, "0 1");
|
||||
SetKcFlag(0,1);
|
||||
}
|
||||
}
|
||||
|
||||
int main( )
|
||||
{
|
||||
//<2F><>ʼ<EFBFBD><CABC>
|
||||
printf("start");
|
||||
//int nMaxIndex= readFile();
|
||||
if (OpenRamRt()<1)
|
||||
return;
|
||||
while (1) {
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>
|
||||
dTLoadP = cal_Total_Load_Power();
|
||||
//<2F><>ȡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ѹ״̬
|
||||
cSDVN = check_SDV_Normal();
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ״̬
|
||||
cCFVN = check_CFV_Normal();
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>
|
||||
dVMaxP = GetItemValue(0, GF_TP_INDEX);
|
||||
if(cSDVN == 0){
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LM_Logic();
|
||||
printf("aaa");
|
||||
}
|
||||
else if(cSDVN == 1){
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BM_Logic();
|
||||
}
|
||||
waitForMillisec(10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
3
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/os.h
Normal file
3
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/os.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#if !defined( OS_UNIX )
|
||||
#define OS_UNIX
|
||||
#endif
|
||||
BIN
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/script
Normal file
BIN
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/script
Normal file
Binary file not shown.
337
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/script.c
Normal file
337
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/script.c
Normal file
@@ -0,0 +1,337 @@
|
||||
#include "script.h"
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD>
|
||||
int OpenRamRt()
|
||||
{
|
||||
#ifdef OS_WIN
|
||||
char chRamName[30] ;
|
||||
HANDLE hFile;
|
||||
HANDLE hMapFile = 0;
|
||||
LPVOID lpMapAddress = 0;
|
||||
strcpy( chRamName, "RAMRT" );
|
||||
|
||||
if ( lpMapAddress ) UnmapViewOfFile( lpMapAddress );
|
||||
if ( hMapFile ) CloseHandle( hMapFile );
|
||||
|
||||
hFile = (HANDLE) 0xFFFFFFFF ;
|
||||
|
||||
hMapFile = CreateFileMapping( hFile, NULL, PAGE_READWRITE, 0, STATION_SIZE , (LPCTSTR)chRamName );
|
||||
if ( hMapFile == NULL ){
|
||||
lpMapAddress = NULL;
|
||||
return 0;
|
||||
}
|
||||
lpMapAddress = MapViewOfFile( hMapFile,FILE_MAP_ALL_ACCESS,0,0,0 );
|
||||
pSysItem = ( double * )lpMapAddress ;
|
||||
pStation = ( StructStation * )( ( double * )lpMapAddress + MAX_SYSITEM ) ;
|
||||
return 1 ;
|
||||
#endif
|
||||
|
||||
#ifdef OS_UNIX
|
||||
int shmid ;
|
||||
void *shmptr ;
|
||||
|
||||
if((shmid = shmget( SHMDBKEYRTRAM_RT , STATION_SIZE , SHM_MODE ) ) < 0 ){
|
||||
return 0 ;
|
||||
}
|
||||
shmptr = shmat( shmid, 0, 0 ) ;
|
||||
|
||||
if ( shmptr == (void*) -1 ) {
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
pSysItem = ( double * )shmptr ;
|
||||
pStation = ( StructStation * )( ( double * )shmptr + MAX_SYSITEM );
|
||||
return 1 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
void waitForMillisec(int millisec)
|
||||
{
|
||||
#ifdef OS_WIN
|
||||
Sleep(millisec);
|
||||
#endif
|
||||
|
||||
#ifdef OS_UNIX
|
||||
usleep(millisec*1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
//<2F><>ȡʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>Ӧid<69><64><EFBFBD><EFBFBD>ֵ
|
||||
double GetItemValue( int iStationid , int id )
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
if ( id >= MAX_NUM )
|
||||
return 0;
|
||||
else
|
||||
return pStation1->DataValue[ id ].dValue ;
|
||||
}
|
||||
|
||||
//<2F><>ȡʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>Ӧid<69><64><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
StructData* GetItem(int iStationid,int id)
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
if ( id >= MAX_NUM )
|
||||
return 0;
|
||||
else
|
||||
return &pStation1->DataValue[ id ] ;
|
||||
}
|
||||
|
||||
//<2F><>ȡʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>Ӧid<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
char GetItemChangeState( int iStationid, int id )
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
if ( id >= MAX_NUM )
|
||||
return 0;
|
||||
else
|
||||
return pStation1->DataValue[ id ].bChangeState ;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>Ӧid<69><64><EFBFBD><EFBFBD>ֵ
|
||||
void SetItemValue( int iStationid , int id , double dValue )
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
if ( id >= MAX_NUM ) return ;
|
||||
|
||||
pStation1->DataValue[id].dValue = dValue ;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
StructKcData *GetKcData( int iStationid )
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid ;
|
||||
|
||||
return &pStation1->DataKC;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>־<EFBFBD><D6BE>״̬
|
||||
int GetKcFlag( int iStationid )
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid ;
|
||||
|
||||
return pStation1->DataKCFlag;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>Ӧid<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
void SetDataState(int iStationid, int id, char bAlarm , char bChangeState)
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
if ( id >= MAX_NUM ) return ;
|
||||
|
||||
pStation1->DataValue[id].bAlarm = bAlarm ;
|
||||
pStation1->DataValue[id].bChangeState = bChangeState ;
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
void SetKcFlag(int iStationid, int flag)
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
pStation1->DataKCFlag = flag;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ÿ<EFBFBD><C3BF>ƴ<EFBFBD> noΪ<6F><CEAA><EFBFBD>ݵ<EFBFBD>id<69><64>data<74>·<EFBFBD><C2B7><EFBFBD>Ϣ
|
||||
void SetKcData(int iStationid, int no , char *data)
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
pStation1->DataKC.kcNo = no;
|
||||
// pStation1->DataKC.dataKC = data;
|
||||
memset(&pStation1->DataKC.dataKC,0,sizeof(pStation1->DataKC.dataKC));
|
||||
memcpy(pStation1->DataKC.dataKC, data, strlen(data));
|
||||
printf("dataKc = %s\n, data = %s\n",pStation1->DataKC.dataKC, data);
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void SetKcClear(int iStationid,int flag)
|
||||
{
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
if(!flag){
|
||||
char data[200] = {0} ;
|
||||
pStation1->DataKCFlag = flag ;
|
||||
strcpy(pStation1->DataKC.dataKC,data);
|
||||
}
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ö<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>Žṹ<C5BD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
void SetStruct(int iNum,char *chMsg)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
strcpy(pStation1->chStruct[iNum],chMsg);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ýṹ<C3BD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void SetStructNum(int iStructNum)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
pStation1->StructNum = iStructNum;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
void SetStructUp(int iNum,char *chMsg)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
strcpy(pStation1->chStructUp[iNum],chMsg);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void SetStructUpNum(int iStructNum)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
pStation1->StructUpNum = iStructNum;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
void SetStructDown(int iNum, char *chMsg)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
strcpy(pStation1->chStructDown[iNum],chMsg);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void SetStructDownNum(int iProg ,int iNum)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
pStation1->StructDownProg = iProg;
|
||||
pStation1->StructDownNum = iNum;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ӦiNum<75>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
char * GetStruct(int iNum)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->chStruct[iNum];
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
int GetStructNum()
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->StructNum;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ӦiNum<75>ϴ<EFBFBD><CFB4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
char *GetStructUp(int iNum)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->chStructUp[iNum];
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ϴ<EFBFBD><CFB4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
int GetStructUpNum()
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->StructUpNum;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ӦiNum<75>´<EFBFBD><C2B4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ
|
||||
char *GetStructDown(int iNum)
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->chStructDown[iNum];
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>´<EFBFBD><C2B4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
int GetStructDownNum()
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->StructDownNum;
|
||||
}
|
||||
|
||||
int GetStructDownProgId()
|
||||
{
|
||||
int iStationid = 0 ;
|
||||
if( bEmbed ) iStationid = 0 ;
|
||||
StructStation * pStation1 ;
|
||||
pStation1 = pStation + iStationid;
|
||||
|
||||
return pStation1->StructDownProg;
|
||||
}
|
||||
|
||||
//<2F><>ȡϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
double GetSysItem(int id)
|
||||
{
|
||||
return *( pSysItem + id ) ;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
void SetSysItem( int id , double dValue)
|
||||
{
|
||||
*( pSysItem + id ) = dValue ;
|
||||
}
|
||||
119
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/script.h
Normal file
119
3.Document/青海能高储能EMS工程/下位机工程/script_nenggao - 副本/script.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef SCRIPT_H
|
||||
#define SCRIPT_H
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef OS_UNIX
|
||||
#include <sys/mman.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
#include <asm/ioctls.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef OS_WIN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#define SHM_MODE (SHM_R | SHM_W | IPC_CREAT)
|
||||
|
||||
#ifdef OS_WIN
|
||||
#define MAX_NUM 12000
|
||||
#endif
|
||||
|
||||
#ifdef OS_UNIX
|
||||
#define MAX_NUM 4000
|
||||
#endif
|
||||
|
||||
#define MAX_SYSITEM 200
|
||||
#define MAX_STRUCT 5
|
||||
#define MAX_STRUCT_DOWN 5
|
||||
#define MAX_STRUCT_UP 5
|
||||
|
||||
#ifdef OS_WIN
|
||||
#define STATION_SIZE 200000 //һ<><D2BB>վ<EFBFBD><D5BE><EFBFBD><EFBFBD>ռ<EFBFBD>õĴ<C3B5>С200000 bytes δʹ<CEB4>õĿռ<C4BF><D5BC><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
#endif
|
||||
|
||||
#ifdef OS_UNIX
|
||||
#define SHMDBKEYRTRAM_RT 1829503351 //811047
|
||||
#define STATION_SIZE 70000
|
||||
#endif
|
||||
|
||||
typedef struct _StructData
|
||||
{
|
||||
double dValue ;
|
||||
char chState ; //ʵʱ<CAB5><CAB1>״ֵ̬
|
||||
char bAlarm ;
|
||||
char bChangeState ;
|
||||
char bVisible;
|
||||
}StructData;
|
||||
|
||||
typedef struct _StructKcData
|
||||
{
|
||||
int kcNo;
|
||||
char dataKC[200];
|
||||
}StructKcData;
|
||||
|
||||
//<2F><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>ݿ<EFBFBD>
|
||||
typedef struct _StructStation
|
||||
{
|
||||
int iVersion;
|
||||
StructData DataValue[ MAX_NUM ];
|
||||
int DataKCFlag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ
|
||||
StructKcData DataKC; //<2F><><EFBFBD><EFBFBD><EFBFBD>ṹ
|
||||
int StructNum; //<2F>澯<EFBFBD>ṹ<EFBFBD><E1B9B9>ʶ
|
||||
char chStruct[MAX_STRUCT][200]; //<2F>澯<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||
int StructUpNum ; //<2F>ϴ<EFBFBD><CFB4>ṹ<EFBFBD><E1B9B9>ʶ
|
||||
char chStructUp[MAX_STRUCT_UP][200] ; //<2F>ϴ<EFBFBD><CFB4>ṹ<EFBFBD><E1B9B9>
|
||||
int StructDownNum; //<2F>´<EFBFBD><C2B4>ṹ<EFBFBD><E1B9B9>ʶ
|
||||
int StructDownProg; //<2F><><EFBFBD><EFBFBD>id
|
||||
char chStructDown[MAX_STRUCT_DOWN][200]; //<2F>´<EFBFBD><C2B4>ṹ<EFBFBD><E1B9B9>
|
||||
}StructStation;
|
||||
|
||||
|
||||
double * pSysItem;
|
||||
StructStation * pStation ;
|
||||
char bEmbed;
|
||||
int OpenRamRt();//<2F><EFBFBD><F2BFAAB9><EFBFBD>
|
||||
double GetItemValue( int iStationid, int id ) ;
|
||||
char GetItemChangeState( int iStationid, int id ) ;
|
||||
void SetItemValue( int iStationid , int id , double dValue ) ;
|
||||
StructKcData * GetKcData(int iStationid);
|
||||
int GetKcFlag(int iStationid);
|
||||
StructData* GetItem(int iStationid,int id);
|
||||
|
||||
double GetSysItem( int id );
|
||||
char * GetStruct(int iNum);
|
||||
int GetStructNum();
|
||||
char * GetStructDown(int iNum);
|
||||
int GetStructDownNum();
|
||||
int GetStructDownProgId();
|
||||
int GetStructUpNum();
|
||||
char * GetStructUp(int iNum);
|
||||
|
||||
void SetDataState(int iStationid, int id , char bAlarm , char bChangeState);
|
||||
void SetSysItem( int id , double dValue);
|
||||
|
||||
void SetStruct(int iNum, char *chMsg);
|
||||
void SetStructNum(int iStructNum);
|
||||
void SetStructDown(int iNum, char *chMsg);
|
||||
void SetStructDownNum(int iProg ,int iNum);
|
||||
void SetStructUpNum(int iStructNum);
|
||||
void SetStructUp(int iNum,char *chMsg);
|
||||
void SetKcFlag(int iStationid,int flag);
|
||||
void SetKcData(int iStationid, int no,char *data);
|
||||
void SetKcClear(int iStationid,int flag);
|
||||
void waitForMillisec(int millisec);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
SOURCES += main.c/
|
||||
script.c
|
||||
HEADERS += script.h/
|
||||
os.h
|
||||
WINLIBS +=
|
||||
LINLIBS +=
|
||||
Reference in New Issue
Block a user