NsIec104.h
资源名称:iec104.rar [点击查看]
上传用户:liao421
上传日期:2013-01-30
资源大小:11k
文件大小:6k
源码类别:
其他嵌入式/单片机内容
开发平台:
C/C++
- #define NS_IEC_104_YK_BASE_PORT 16
- #define NS_IEC104_YK_PERMIT_TIME 16
- #define NS_IEC_104_TOTAL_YX_TIMES 9
- #define NS_IEC_104_ONCE_YX 120
- #define NS_IEC_104_ONCE_YX_BYTES 120/8
- #define NS_IEC_104_TOTAL_YC_TIMES 16
- #define NS_IEC_104_ONCE_YC 32
- #define NS_IEC_104_TOTAL_YM_TIMES 8
- #define NS_IEC_104_ONCE_YM 16
- #define NS_IEC_104_MIN_LENGTH 6
- #define NS_IEC_104_HEAD 0x68
- #define NS_IEC_104_STARTDT 0x04
- #define NS_IEC_104_STOPDT 0x10
- #define NS_IEC_104_TESTFR 0x40
- #define NS_IEC_104_QCC_POSITION 15
- #define NS_IEC_104_TIME_POSITION 15
- #define NS_IEC_104_REASONBYTE 2
- #define NS_IEC_104_ASDUADDRESSBYTE 2
- #define NS_IEC_104_INFORMATIONBYTE 3
- /* Location Which Bytes In Receive Buffer */
- #define NS_STARTREASON 8
- #define NS_STARTASDUADDRESS 10
- #define NS_STARTINFORMATION 12
- #define NS_STARTQUALIFIER 15
- #define NS_IEC_104_GROUP_BYTE 15
- #define NS_IEC104_GROUP_BEGIN 21
- #define NS_IEC104_GROUP_END 36
- #define NS_IEC104_YX_START_OBJECT 0x01
- #define NS_IEC104_YC_START_OBJECT 0x701
- #define NS_IEC104_YCYX_OBJECT_INDEX 0x80
- #define NS_IEC104_SENDBUFFER 256
- #define NS_IEC104_RECEIVEBUFFER 128
- #define NS_CONNECTED 0x02
- #define NS_DISCONNECTED 0x20
- #define NS_IEC104_PERMIT_TIME 30
- #define NS_IEC104_MAX_K 12
- #define NS_IEC104_MAX_W 8
- #define NS_IEC104_MAX_GROUP 30
- #define NS_IEC104_MAX_YC 512
- #define NS_IEC104_CHANGE_YC_CYCLE 16
- #define NS_IEC104_ONCE_YC_COUNT 32
- typedef struct NS_IEC_104_NS_
- {
- struct sockaddr_in ServerAddress;
- int NsNewSocketId;
- unsigned char LinkState;
- unsigned long LinkValidTime;
- unsigned char Card;
- short Port;
- unsigned char ReceiveBuffer[NS_IEC104_RECEIVEBUFFER];
- unsigned char SendBuffer[NS_IEC104_SENDBUFFER];
- short SendLength;
- short ReceiveLength;
- unsigned short ReceiveIndex;
- short ReceiveIndexLength;
- unsigned char ApciCode;
- unsigned char TransmitReason[2];
- unsigned char CommonAsduAddress[2];
- unsigned char InformationObject[4];
- unsigned char FormatType;
- unsigned char UCommand;
- unsigned char ReceiveHimNumber[2];
- unsigned short SendMeNumber;
- unsigned short ApduLength;
- unsigned char AsduType;
- unsigned char AsduQualifier;
- unsigned char Qcc;
- unsigned char FreezeSign;
- unsigned char PulseGroup;
- unsigned char TimeSave[8];
- unsigned char Table;
- unsigned short HasSendNumber;
- unsigned short NeedSendNumber;
- unsigned short LeftSendNumber;
- unsigned short K;
- unsigned short W;
- unsigned short ReceiveYkId;
- unsigned char YkCellAction;
- unsigned short YkCellNumber;
- unsigned short YkKgNumber;
- unsigned char YkNowState;
- unsigned short MediaNumber;
- unsigned char YkError;
- unsigned char YkYtType;
- unsigned char YkStartSign;
- unsigned long YkStartTime;
- unsigned short SystemState;
- unsigned char DataBuff[160];
- unsigned char SetTimeFlag;
- unsigned char GroupSendBuffer[NS_IEC104_MAX_GROUP][NS_IEC104_SENDBUFFER];
- unsigned short GroupSendLength[NS_IEC104_MAX_GROUP];
- short YcLastValue[NS_IEC104_MAX_YC];
- unsigned char YcNap[NS_IEC104_MAX_YC];
- unsigned char YcChangeCycle;
- unsigned short YcLibIndex;
- unsigned short YcChangeCount;
- unsigned char CosSign;
- unsigned char NetRunSign;
- unsigned char SetNetSign;
- unsigned char TableNo;
- /*unsigned short XYxNum;
- unsigned short XYmNum;*/
- unsigned short XYcNum;
- unsigned short XYcCycleNum;
- }NS_IEC104_MAIN;
- #define NS_IEC104_USE_CYCLE 5
- static NS_SEND_TIME_NAP NsIec104Cycle[NS_IEC104_USE_CYCLE];
- static unsigned short NsIec104Nap[NS_IEC104_USE_CYCLE]={/*5*/120,15,20,25,30};