EMS,硬件设计文件以及软件功能验证程序
This commit is contained in:
21
3.Document/青海能高储能EMS工程/上位机工程/quxian/Makefile
Normal file
21
3.Document/青海能高储能EMS工程/上位机工程/quxian/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
CC = 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
95
3.Document/青海能高储能EMS工程/上位机工程/quxian/main.c
Normal file
95
3.Document/青海能高储能EMS工程/上位机工程/quxian/main.c
Normal file
@@ -0,0 +1,95 @@
|
||||
#include <math.h>
|
||||
#include "script.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
//<2F><>ʼ<EFBFBD><CABC>
|
||||
|
||||
int nMaxIndex= readFile();
|
||||
if (CreateRam(0,nMaxIndex)<1)
|
||||
return;
|
||||
|
||||
int i,Number;
|
||||
int StationNumber;
|
||||
static int station[2] = {0,285};//0<>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>285<38><35><EFBFBD>۱<EFBFBD><DBB1>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>۱<EFBFBD><DBB1><EFBFBD><EFBFBD><EFBFBD>
|
||||
static temp1_index =8000; //<2F>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
while(1){
|
||||
|
||||
Number=(int)GetSysItem(142)-1;
|
||||
StationNumber=(int)GetSysItem(143)-1;
|
||||
|
||||
if(StationNumber==0)
|
||||
{
|
||||
for (i=0;i<=31;i++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>31<33><31><EFBFBD><EFBFBD>
|
||||
{
|
||||
SetItemValue(0,temp1_index+i,GetItemValue(0,Number*31+i+station[StationNumber]));
|
||||
}
|
||||
//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
|
||||
SetSysItem( 78 , Number*31+9+station[StationNumber]);//Pa
|
||||
SetSysItem( 79 , Number*31+10+station[StationNumber]);//Pb
|
||||
SetSysItem( 80 , Number*31+11+station[StationNumber]);//Pc
|
||||
SetSysItem( 81 , Number*31+12+station[StationNumber]);//P
|
||||
|
||||
//<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
||||
SetSysItem( 94 , Number*31+9+station[StationNumber]);//Pa
|
||||
SetSysItem( 95 , Number*31+10+station[StationNumber]);//Pb
|
||||
SetSysItem( 96 , Number*31+11+station[StationNumber]);//Pc
|
||||
SetSysItem( 97 , Number*31+12+station[StationNumber]);//P
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(StationNumber==1)
|
||||
{
|
||||
for (i=0;i<116;i++)//<2F>۱<EFBFBD><DBB1><EFBFBD><EFBFBD><EFBFBD>116<31><36><EFBFBD><EFBFBD>
|
||||
{
|
||||
|
||||
SetItemValue(0,temp1_index+i,GetItemValue(0,Number*116+i+station[StationNumber]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
waitForMillisec(2000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
95
3.Document/青海能高储能EMS工程/上位机工程/quxian/main.c~
Normal file
95
3.Document/青海能高储能EMS工程/上位机工程/quxian/main.c~
Normal file
@@ -0,0 +1,95 @@
|
||||
#include <math.h>
|
||||
#include "script.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
//<2F><>ʼ<EFBFBD><CABC>
|
||||
|
||||
int nMaxIndex= readFile();
|
||||
if (CreateRam(0,nMaxIndex)<1)
|
||||
return;
|
||||
|
||||
int i,Number;
|
||||
int StationNumber;
|
||||
static int station[2] = {0,285};//0<>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>285<38><35><EFBFBD>۱<EFBFBD><DBB1>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>۱<EFBFBD><DBB1><EFBFBD><EFBFBD><EFBFBD>
|
||||
static temp1_index =8000; //<2F>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
while(1){
|
||||
|
||||
Number=(int)GetSysItem(142)-1;
|
||||
StationNumber=(int)GetSysItem(143)-1;
|
||||
|
||||
if(StationNumber==0)
|
||||
{
|
||||
for (i=0;i<=31;i++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>31<33><31><EFBFBD><EFBFBD>
|
||||
{
|
||||
SetItemValue(0,temp1_index+i,GetItemValue(0,Number*31+i+station[StationNumber]));
|
||||
}
|
||||
//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
|
||||
SetSysItem( 78 , Number*31+9+station[StationNumber]);//Pa
|
||||
SetSysItem( 79 , Number*31+10+station[StationNumber]);//Pb
|
||||
SetSysItem( 80 , Number*31+11+station[StationNumber]);//Pc
|
||||
SetSysItem( 81 , Number*31+12+station[StationNumber]);//P
|
||||
|
||||
//<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
||||
SetSysItem( 94 , Number*31+9+station[StationNumber]);//Pa
|
||||
SetSysItem( 95 , Number*31+10+station[StationNumber]);//Pb
|
||||
SetSysItem( 96 , Number*31+11+station[StationNumber]);//Pc
|
||||
SetSysItem( 97 , Number*31+12+station[StationNumber]);//P
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(StationNumber==1)
|
||||
{
|
||||
for (i=0;i<116;i++)//<2F>۱<EFBFBD><DBB1><EFBFBD><EFBFBD><EFBFBD>116<31><36><EFBFBD><EFBFBD>
|
||||
{
|
||||
|
||||
SetItemValue(0,temp1_index+i,GetItemValue(0,Number*116+i+station[StationNumber]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
waitForMillisec(2000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
3.Document/青海能高储能EMS工程/上位机工程/quxian/script
Normal file
BIN
3.Document/青海能高储能EMS工程/上位机工程/quxian/script
Normal file
Binary file not shown.
404
3.Document/青海能高储能EMS工程/上位机工程/quxian/script.c
Normal file
404
3.Document/青海能高储能EMS工程/上位机工程/quxian/script.c
Normal file
@@ -0,0 +1,404 @@
|
||||
#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
|
||||
}
|
||||
|
||||
//gaowf 2016.7.25
|
||||
char CreateRam(int iStationNum, int nMaxIndex)
|
||||
{
|
||||
//qDebug( "createram %d", iStationNum );
|
||||
#ifdef OS_WIN
|
||||
char chRamName[30] ;
|
||||
if(iStationNum == 0)
|
||||
strcpy( chRamName, "RAMRT" );
|
||||
else
|
||||
sprintf(chRamName, "%s%d", "RAMRT", iStationNum);
|
||||
|
||||
if ( lpMapAddress ) UnmapViewOfFile( lpMapAddress );
|
||||
if ( hMapFile ) CloseHandle( hMapFile );
|
||||
|
||||
HANDLE hFile = (HANDLE) 0xFFFFFFFF ;
|
||||
|
||||
int iSize2 ;
|
||||
|
||||
nMaxDataNum = nMaxIndex+1;
|
||||
iSize2 = sizeof( StructStation) + MAX_SYSITEM * sizeof( double ) ;
|
||||
iSize2 += sizeof(StructData)*(nMaxIndex+1);
|
||||
|
||||
hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, (LPCTSTR)chRamName);
|
||||
if(!hMapFile)
|
||||
hMapFile = CreateFileMapping( hFile, NULL, PAGE_READWRITE, 0, iSize2 , (LPCTSTR)chRamName );
|
||||
if ( hMapFile == NULL ){
|
||||
char chMsg[100];
|
||||
strcpy( chMsg, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ" );
|
||||
::MessageBox( NULL, (LPCTSTR)chMsg , NULL, MB_OK );
|
||||
lpMapAddress = NULL;
|
||||
return 0;
|
||||
}
|
||||
lpMapAddress = MapViewOfFile( hMapFile,FILE_MAP_ALL_ACCESS,0,0,0 );
|
||||
pSysItem = ( double * )lpMapAddress ;
|
||||
pStation = ( StructStation * )( ( double * )lpMapAddress + MAX_SYSITEM ) ;
|
||||
DataValue = (StructData *)(pStation + 1);
|
||||
#endif
|
||||
|
||||
#ifdef OS_UNIX
|
||||
int shmid ;
|
||||
void *shmptr ;
|
||||
|
||||
int iSize2=0;
|
||||
nMaxDataNum = nMaxIndex+1;
|
||||
iSize2 = sizeof( StructStation) + MAX_SYSITEM * sizeof( double ) ;
|
||||
iSize2 += sizeof(StructData)*(nMaxIndex+1);
|
||||
|
||||
if((shmid = shmget( SHMDBKEYRTRAM_RT , iSize2 , SHM_MODE ) ) < 0 ){
|
||||
printf("shmget error");
|
||||
return 0 ;
|
||||
}
|
||||
shmptr = shmat( shmid, 0, 0 ) ;
|
||||
//qDebug("shmat %d", shmptr );
|
||||
|
||||
if ( shmptr == (void*) -1 ) {
|
||||
//qDebug( "shmat error" );
|
||||
return 0 ;
|
||||
}
|
||||
//qDebug ( "shared memory attached" );
|
||||
pSysItem = ( double * )shmptr ;
|
||||
pStation = ( StructStation * )( ( double * )shmptr + MAX_SYSITEM );
|
||||
DataValue = (StructData *)(pStation + 1);
|
||||
|
||||
#endif
|
||||
pStation->iVersion = 1 ;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//<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 >= nMaxDataNum )
|
||||
return 0;
|
||||
else
|
||||
return 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 >= nMaxDataNum )
|
||||
return 0;
|
||||
else
|
||||
return &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 >= nMaxDataNum )
|
||||
return 0;
|
||||
else
|
||||
return 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 >= nMaxDataNum ) return ;
|
||||
|
||||
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 >= nMaxDataNum ) return ;
|
||||
|
||||
DataValue[id].bAlarm = bAlarm ;
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
//<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 ;
|
||||
}
|
||||
127
3.Document/青海能高储能EMS工程/上位机工程/quxian/script.h
Normal file
127
3.Document/青海能高储能EMS工程/上位机工程/quxian/script.h
Normal file
@@ -0,0 +1,127 @@
|
||||
#ifndef SCRIPT_H
|
||||
#define SCRIPT_H
|
||||
|
||||
#define OS_UNIX
|
||||
|
||||
#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 <sys/stat.h>
|
||||
#include <dirent.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;
|
||||
|
||||
|
||||
StructStation * pStation ;
|
||||
StructData *DataValue;
|
||||
double * pSysItem;
|
||||
int nMaxDataNum;
|
||||
|
||||
char bEmbed;
|
||||
int OpenRamRt();//<2F><EFBFBD><F2BFAAB9><EFBFBD>
|
||||
char CreateRam(int iStationNum, int nMaxIndex);
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user