128 lines
3.1 KiB
C
128 lines
3.1 KiB
C
![]() |
#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
|