|
楼主 |
发表于 2010-11-29 10:48:34
|
显示全部楼层
在PLC控制器里做一个web服务器,接收IE的指令,然后传输xml格式的数据给上位机,这样上位机就可以通过IE浏览器进行状态监控了,上传一个范例。
IE浏览器监控例子ourdev_601083E6WYNV.htm(文件大小:72K) (原文件名:系统IO监测.htm)
下面是PLC的数据结构,每个指令10个Byte,前面是指令地址,后面的参数,参数有何多种形式,所以用了联合的结构
typedef struct
{
void (*call)();
union
{
struct
{
void * p1;
unsigned int a;
float b;
}abc;
struct
{
void *p1,*p2,*p3,*p4;
}math;
struct
{
void *p1,*p2,*p3;
int offset;
}cmp;
struct
{
int a,b,c;
void *p1;
}op;
}par;
}PLC_STRUCT;
typedef union
{
char plc_text[STEP_NUM*sizeof(PLC_STRUCT)]; //PLC程序文本存放区 暂定10K大小 ;
PLC_STRUCT hhcall[STEP_NUM]; //步数 暂定1000步
}HPLC;
static HPLC h;
下面的PLC的执行线程,
while(1)//plcwork always_on
{
i++;
if(plc)
{
if(i>100) //PLC循环500次的时间
{
plc_time= MS_TIMER-time;
// printf("\rtime=%ld ",plc_time);
i=0;
time=MS_TIMER;
}
count = 0;
while((h.hhcall[count].call!=NULL)) // &&(plc)
{
h.hhcall[count].call();
count++;
}
}
IO_WRITE();
yield;
} |
|