⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core.h

📁 AUTOMGEN runtime is an open source royalty free runtime for open PLCs. By using this runtime, any ta
💻 H
字号:


// Usefull system bits and words numbers

#define SYSTEM_BIT_FIRST_SCAN 0

#define SYSTEM_BIT_INTERNAL_TABLE_OVERFLOW 9
#define SYSTEM_BIT_FAULT 10
#define SYSTEM_BIT_RUN 11
#define SYSTEM_BIT_EMERGENCY_STOP 12

#define SYSTEM_WORD_ERROR_POSITION 20
#define SYSTEM_WORD_ERROR_NUMBER 21 

// Usefulle constant for boolean states
#define TRUEFORBOOL 0x70

#undef NOFORCE // No forcing if defined

// Contect structure for execution
struct _a7int
	{
	unsigned ni;			// Number of inputs
	unsigned no;			// Number of outputs
	unsigned nb;			// Number of bits
	unsigned nt;			// Number of timers
	unsigned nc;			// Number of counters
	unsigned nm;			// Number of 16 bits words
	unsigned nf;			// Number of floating point variables
	unsigned nl;			// Number of 32 bits words
	unsigned char *pI;		// Pointer to inputs memory: one byte per input
	unsigned char *pO;		// Pointer to outputs memory: one byte per output
	unsigned char *pB;		// Pointer to bits memory: one byte per bit
	unsigned char *pT;		// Pointer to timers memory: 8 bytes per timer
	unsigned short *pC;		// Pointer to counters memory: 2 bytes per counter
	unsigned short *pM;		// Pointer to words memory: 2 bytes per word
	float *pF;				// Pointer to floats memory: 4 bytes per float
	unsigned long *pL;		// Pointer to dwords memory: 4 bytes per dword
	short ac16;				// 16 bits accumulator
	long ac32;				// 32 bits accumulator
	float acf;				// floating point accumulator
	int cf,sf,of,zf;		// arithmetic flags
	int step;				// flag "process a step" request
	int init;				// flag "initilization" request
	int run;				// flag "running"
	int freezeio;			// flag "stop I/O" refresh
	unsigned char *progmem;	// Pointer to program: AUTOMGEN pivot code
	long movcode;			// For jump processing
	unsigned char *curcode;	// Current execution address in progmem
	unsigned char *gotocode;// For jump processing
	unsigned io_i_pos,io_o_pos,io_m_pos;  // For I/O processing
	};


#define _SECURE							// Secure version
#define MAXACTIONOPCODE (0x80+55)		// Max opcode value
#define MAXADR 11						// Max adress mode for instructions
#define MAXVAR 8						// Max variable types 

// Error codes 
#define AUTOMGEN_ERR_ILLEGALACTIONOPCODE 0x8001
#define AUTOMGEN_ERR_ILLEGALACTIONADRCODE 0x8002
#define AUTOMGEN_ERR_BOOLTABLEFULL 0x8003
#define AUTOMGEN_ERR_NOPROG 0x8004
#define AUTOMGEN_ERR_ILLEGALTESTOPCODE 0x8005
#define AUTOMGEN_ERR_ILLEGALTESTADR 0x8006
#define AUTOMGEN_ERR_ILLEGALTESTVAR 0x8007
#define AUTOMGEN_ERR_ILLEGALACTIONBOOLVAR 0x8008
#define AUTOMGEN_ERR_ILLEGALACTIONBOOLSET 0x8009
#define AUTOMGEN_ERR_ILLEGALTESTTYPE 0x800a
#define AUTOMGEN_ERR_ILLEGALNUMTEST 0x800b
#define AUTOMGEN_ERR_STACKOVERFLOW 0x800c
#define AUTOMGEN_ERR_STACKUNDERFLOW 0x800c

// Internal boolean table length (for internal boolean variables processing, not the nimber of the variables)
#define BOOLTABLELEN 1024
// Stack len for sub routines calls
#define SRSTACKLEN 1024

void setvar(struct _a7int *a7int,unsigned type,unsigned num,int state,unsigned pos);
int isforced(struct _a7int *a7int,BYTE type,WORD wNum);
int setforce(struct _a7int *a7int,BYTE type,WORD wNum,int force);

void automgenintinit(struct _a7int *a7int);
void automgenintrun(struct _a7int *a7int);
void automgenintprocesssysvar(struct _a7int *a7int);






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -