请高手指点一下,帮我解释一下这个程序
//***************************************************************************//----------------------------标准功能模块-----------------------------------
//--------------------------用户标准功能模块---------------------------------
//--------------包括:数字量、模拟量、RAM、PWM、串口以及CAN通信--------------
//----------------------------2008.04.12-------------------------------------
//***************************************************************************
#include "main.h"
unsigned char RS_NotWork_Count=0;
//*****************************************************
// @Function void F_Process_IO_Input(void)
// ----------------------------------------------------
// @Description IO输入数据处理函数定义
//*****************************************************
void F_Process_IO_Input(void)
{
}
//****************************************************
// @Function void F_Process_Serial_Input(void)
// ---------------------------------------------------
// @Description 串口输入数据处理函数定义
//****************************************************
void F_Process_Serial_Input(void)
{
}
//****************************************************
// @Function void F_Process_CAN_Input(void)
// ---------------------------------------------------
// @Description CAN输入数据处理函数定义
//****************************************************
void F_Process_CAN_Input(void)
{
}
//***************************************************
// @Function void F_Process_ADC_Input(void)
// --------------------------------------------------
// @Description ADC输入数据处理函数定义
//***************************************************
void F_Process_ADC_Input(void)
{
}
//***************************************************
// @Function void F_Process_RAM_Input(void)
// --------------------------------------------------
// @Description RAM输入数据处理函数定义
//***************************************************
void F_Process_RAM_Input(void)
{
}
//*************************************************
// @Function void F_Process_IO_Output(void)
// ------------------------------------------------
// @Description IO输出数据处理函数定义
//*************************************************
void F_Process_IO_Output(void)
{
}
//****************************************************
// @Function void F_Process_Serial_Output(void)
// ---------------------------------------------------
// @Description 串口输出数据处理函数定义
//****************************************************
void F_Process_Serial_Output(void)
{
}
//*************************************************
// @Function void F_Process_CAN_Output(void)
// ------------------------------------------------
// @Description CAN输出数据处理函数定义
//*************************************************
void F_Process_CAN_Output(void)
{
}
//****************************************************
// @Function void F_Process_Data_Logic();
// ---------------------------------------------------
// @Description 控制逻辑运算函数定义
//****************************************************
void F_Process_ModeLogic(void)
{
unsigned char ID,NodeEnable;
for(ID=0;ID<4;ID++)
{
GA_char_CAN_Sending[ID][0][0]=0x33;
GA_char_CAN_Sending[ID][1][0]=0x55;
GA_char_CAN_Sending[ID][2][0]=0x77;
}
G_CAN_NodeNum=GA_char_RAM_Reading[58]+1;
G_RS_Error=(GA_char_RAM_Reading[1]&0x40)==0x40;
NodeEnable=GA_char_RAM_Reading[3]&0x0F;
if(GA_char_RS_Work[0]==0xAA&&GA_char_RS_Work[1]==0x55)
{
RS_NotWork_Count=0;
G_RS_NotWork=0;
}
else
RS_NotWork_Count++;
if(RS_NotWork_Count>50)
{
G_RS_NotWork=1;
RS_NotWork_Count=50;
}
GA_char_RS_Work[0]=0;
GA_char_RS_Work[1]=0;
for(ID=0;ID<G_CAN_NodeNum;ID++) //GD_CAN_NodeNum
{
GA_char_RAM_Writing[ID*42+0]=GA_char_CAN_Reception[ID][0][3];
GA_char_RAM_Writing[ID*42+1]=GA_char_CAN_Reception[ID][0][1];
GA_char_RAM_Writing[ID*42+2]=GA_char_CAN_Reception[ID][5][7];
GA_char_RAM_Writing[ID*42+3]=GA_char_CAN_Reception[ID][5][2];
GA_char_RAM_Writing[ID*42+4]=GA_char_CAN_Reception[ID][5][3];
GA_char_RAM_Writing[ID*42+5]=GA_char_CAN_Reception[ID][5][4];
GA_char_RAM_Writing[ID*42+6]=GA_char_CAN_Reception[ID][5][5];
GA_char_RAM_Writing[ID*42+7]=GA_char_CAN_Reception[ID][5][6];
GA_char_RAM_Writing[ID*42+8]=GA_char_CAN_Reception[ID][0][2];
GA_char_RAM_Writing[ID*42+9]=GA_char_CAN_Reception[ID][0][4];
GA_char_RAM_Writing[ID*42+10]=GA_char_CAN_Reception[ID][0][5];
GA_char_RAM_Writing[ID*42+11]=GA_char_CAN_Reception[ID][0][6];
GA_char_RAM_Writing[ID*42+12]=GA_char_CAN_Reception[ID][0][7];
GA_char_RAM_Writing[ID*42+13]=GA_char_CAN_Reception[ID][1][1];
GA_char_RAM_Writing[ID*42+14]=GA_char_CAN_Reception[ID][1][2];
GA_char_RAM_Writing[ID*42+15]=GA_char_CAN_Reception[ID][1][3];
GA_char_RAM_Writing[ID*42+16]=GA_char_CAN_Reception[ID][1][4];
GA_char_RAM_Writing[ID*42+17]=GA_char_CAN_Reception[ID][1][5];
GA_char_RAM_Writing[ID*42+18]=GA_char_CAN_Reception[ID][1][6];
GA_char_RAM_Writing[ID*42+19]=GA_char_CAN_Reception[ID][1][7];
GA_char_RAM_Writing[ID*42+20]=GA_char_CAN_Reception[ID][2][1];
GA_char_RAM_Writing[ID*42+21]=GA_char_CAN_Reception[ID][2][2];
GA_char_RAM_Writing[ID*42+22]=GA_char_CAN_Reception[ID][2][3];
GA_char_RAM_Writing[ID*42+23]=GA_char_CAN_Reception[ID][2][4];
GA_char_RAM_Writing[ID*42+24]=GA_char_CAN_Reception[ID][2][5];
GA_char_RAM_Writing[ID*42+25]=GA_char_CAN_Reception[ID][2][6];
GA_char_RAM_Writing[ID*42+26]=GA_char_CAN_Reception[ID][2][7];
GA_char_RAM_Writing[ID*42+27]=GA_char_CAN_Reception[ID][3][1];
GA_char_RAM_Writing[ID*42+28]=GA_char_CAN_Reception[ID][3][2];
GA_char_RAM_Writing[ID*42+29]=GA_char_CAN_Reception[ID][3][3];
GA_char_RAM_Writing[ID*42+30]=GA_char_CAN_Reception[ID][3][4];
GA_char_RAM_Writing[ID*42+31]=GA_char_CAN_Reception[ID][3][5];
GA_char_RAM_Writing[ID*42+32]=GA_char_CAN_Reception[ID][3][6];
GA_char_RAM_Writing[ID*42+33]=GA_char_CAN_Reception[ID][3][7];
GA_char_RAM_Writing[ID*42+34]=GA_char_CAN_Reception[ID][4][1];
GA_char_RAM_Writing[ID*42+35]=GA_char_CAN_Reception[ID][4][2];
GA_char_RAM_Writing[ID*42+36]=GA_char_CAN_Reception[ID][4][3];
GA_char_RAM_Writing[ID*42+37]=GA_char_CAN_Reception[ID][4][4];
GA_char_RAM_Writing[ID*42+38]=GA_char_CAN_Reception[ID][4][5];
GA_char_RAM_Writing[ID*42+39]=GA_char_CAN_Reception[ID][4][6];
GA_char_RAM_Writing[ID*42+40]=GA_char_CAN_Reception[ID][4][7];
GA_char_RAM_Writing[ID*42+41]=GA_char_CAN_Reception[ID][5][1];
if(G_CAN_Input_error&(0x01<<ID)) //CAN故障
{
GA_char_RAM_Writing[ID*42+9]|=0x01;//主控-就地CAN故障
GA_char_RAM_Writing[ID*42+27]|=0x80; //智能节点1 CAN 故障
GA_char_RAM_Writing[ID*42+29]|=0x80; //智能节点2 CAN 故障
GA_char_RAM_Writing[ID*42+31]|=0x80; //智能节点3 CAN 故障
GA_char_RAM_Writing[ID*42+33]|=0x80; //智能节点4 CAN 故障
GA_char_RAM_Writing[ID*42+35]|=0x80; //智能节点5 CAN 故障
GA_char_RAM_Writing[ID*42+37]|=0x80; //智能节点6 CAN 故障
GA_char_RAM_Writing[ID*42+39]|=0x80; //智能节点7 CAN 故障
GA_char_RAM_Writing[ID*42+41]|=0x80; //智能节点8 CAN 故障
}
GA_char_RAM_Writing[ID*6+168]=GA_char_CAN_Reception[ID][6][1];
GA_char_RAM_Writing[ID*6+169]=GA_char_CAN_Reception[ID][6][2]&0x07;
GA_char_RAM_Writing[ID*6+170]=GA_char_CAN_Reception[ID][6][3];
GA_char_RAM_Writing[ID*6+171]=GA_char_CAN_Reception[ID][6][4];
GA_char_RAM_Writing[ID*6+172]=GA_char_CAN_Reception[ID][6][5];
GA_char_RAM_Writing[ID*6+173]=GA_char_CAN_Reception[ID][6][6];
}
for(ID=0;ID<G_CAN_NodeNum;ID++) //GD_CAN_NodeNum
{
GA_char_CAN_Sending[ID][0][1]=GA_char_RAM_Reading[2];
GA_char_CAN_Sending[ID][0][4]=0x00;
GA_char_CAN_Sending[ID][0][4]=(unsigned char)((GA_char_RAM_Reading[0]-1)&0x07);
if(GA_char_RAM_Reading[1]&0x01)
GA_char_CAN_Sending[ID][0][4]|=0x20;
else
GA_char_CAN_Sending[ID][0][4]|=0x40;
if((GA_char_RAM_Reading[1]&0x02)&&(GA_char_RAM_Reading[3]&(0x01<<ID)))
GA_char_CAN_Sending[ID][0][4]|=0x10;
if((GA_char_RAM_Reading[1]&0x04)||(GA_char_RAM_Reading[1]&0x08))
GA_char_CAN_Sending[ID][0][4]|=0x08;
GA_char_CAN_Sending[ID][0][5]=0x00;
if(GA_char_RAM_Reading[1]&0x20)
GA_char_CAN_Sending[ID][0][5]|=0x10;
if((GA_char_RAM_Reading[54]==0x55)&&(GA_char_RAM_Reading[55]==0xAA))
GA_char_CAN_Sending[ID][0][5]|=0x05;
if((GA_char_RAM_Reading[56]==0x55)&&(GA_char_RAM_Reading[57]==0xAA))
GA_char_CAN_Sending[ID][0][5]|=0x06;
if(GA_char_RAM_Reading[0]==0)
GA_char_CAN_Sending[ID][0][5]|=0x80;
if(GA_char_RAM_Reading[1]&0x80)
GA_char_CAN_Sending[ID][0][4]|=0x80;
else
GA_char_CAN_Sending[ID][0][4]&=0x7F;
GA_char_CAN_Sending[ID][0][3]=GA_char_RAM_Reading[ID*12+4];
if((GA_char_RAM_Reading[52]==0x55)&&(GA_char_RAM_Reading[53]==0xAA))
GA_char_CAN_Sending[ID][0][3]|=0xC0;
else
GA_char_CAN_Sending[ID][0][3]&=0x3F;
GA_char_CAN_Sending[ID][2][2]&=0xF8;
if((GA_char_RAM_Reading[59]==0x55)&&(GA_char_RAM_Reading[60]==0xAA))
GA_char_CAN_Sending[ID][2][2]|=0x05;
if((GA_char_RAM_Reading[61]==0x55)&&(GA_char_RAM_Reading[62]==0xAA))
GA_char_CAN_Sending[ID][2][2]|=0x06;
GA_char_CAN_Sending[ID][0][2]=GA_char_RAM_Reading[ID*12+5];
GA_char_CAN_Sending[ID][0][6]=GA_char_RAM_Reading[ID*12+6];
GA_char_CAN_Sending[ID][0][7]=GA_char_RAM_Reading[ID*12+7];
GA_char_CAN_Sending[ID][1][1]=GA_char_RAM_Reading[ID*12+8];
GA_char_CAN_Sending[ID][1][2]=GA_char_RAM_Reading[ID*12+9];
GA_char_CAN_Sending[ID][1][3]=GA_char_RAM_Reading[ID*12+10];
GA_char_CAN_Sending[ID][1][4]=GA_char_RAM_Reading[ID*12+11];
GA_char_CAN_Sending[ID][1][5]=GA_char_RAM_Reading[ID*12+12];
GA_char_CAN_Sending[ID][1][6]=GA_char_RAM_Reading[ID*12+13];
GA_char_CAN_Sending[ID][1][7]=GA_char_RAM_Reading[ID*12+14];
GA_char_CAN_Sending[ID][2][1]=GA_char_RAM_Reading[ID*12+15];
if(G_RS_Error||G_RS_NotWork)
GA_char_CAN_Sending[ID][0][5]|=0x08;
//485 not work
if(G_RS_NotWork)
{
GA_char_CAN_Sending[ID][0][1]&=0x00;
GA_char_CAN_Sending[ID][0][3]&=0xC0;
GA_char_CAN_Sending[ID][0][5]|=0x80;
}
}
//故障显示
DP0H=0x3F;
for(ID=G_CAN_NodeNum;ID<4;ID++) //GD_CAN_NodeNum
P0H|=(0x01<<ID);
for(ID=0;ID<G_CAN_NodeNum;ID++) //GD_CAN_NodeNum
{
if(GA_char_RAM_Writing[ID*42+9]&0x01)
P0H&=(~(0x01<<ID));
else
{
switch(ID)
{
case 0:
P0H_P0=!P0H_P0;
break;
case 1:
P0H_P1=!P0H_P1;
break;
case 2:
P0H_P2=!P0H_P2;
break;
case 3:
P0H_P3=!P0H_P3;
break;
}
}
}
if(G_RS_Error||G_RS_NotWork)
P0H_P4=0;
else
P0H_P4=!P0H_P4;
if(G_RS_NotWork)
P0H_P5=0;
else
P0H_P5=!P0H_P5;
}
//