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

📄 framemodule.c

📁 该程序完成了c8051外围电路的驱动和串口协议的编写。希望能给大家学习51单片机带来帮助
💻 C
📖 第 1 页 / 共 5 页
字号:











		uchChannelStatus |= (uchTempData[uchChannel - 1] << 6); 
	}
	else
	{
		uchChannelStatus = 0x20;   //Disable状态时上报的所有状态为初始态
	}

	return uchChannelStatus;						   
}

//-----------------------------------------------------------------------
//函数名称: void CaculateTripleStatus(unsigned char uchChannel)
//功    能:根据软件和硬件的倍增状态计算倍增数值
//输入参数:无
//返    回:无
//完成日期:6/21/2007
//-----------------------------------------------------------------------
void CaculateTripleStatus(unsigned char uchChannel)
{	
	switch(All.Para.Ch[uchChannel - 1].uiChType)
	{
		case 13:	
		case 14:
		case 15:
		case 16:
		case 17:
		case 18:
		case 21:	  
			if (MainModule.uchHWTripleStatus == 0)
			{			
				MainModule.uchTripleStatus[uchChannel - 1] = All.Para.uiTripValue[uchChannel - 1];
			}
			else
			{
				MainModule.uchTripleStatus[uchChannel - 1] = 0;
			}		
					
/*			if (MainModule.uchSoftTripleTotalStatus == 0x01)	   //tong
			{
				MainModule.uchTripleStatus[uchChannel - 1] = 1;
			}
			else if (MainModule.uchSoftTripleTotalStatus == 0x02)
			{
				MainModule.uchTripleStatus[uchChannel - 1] = 2;
			}	*/						 	
	
			break;
		case 22:	//HHH
		case 28:	
			MainModule.uchTripleStatus[uchChannel - 1] = 0;
			break;
		default:
			break;		
	}
}

//-----------------------------------------------------------------------
//函数名称: unsigned char JudgeTripleStatus(void)
//功    能:判断倍增状态
//输入参数:通道号
//返    回:状态值
//完成日期:6/21/2007
//-----------------------------------------------------------------------
unsigned char JudgeTripleStatus(unsigned char uchChannel)
{
	if (MainModule.uchTripleStatus[uchChannel - 1] == 0)
	{
		return 0;				 //no triplestatus
	}
	else
	{
		return 1;
	}
}

//--------------------------------------------------------------------------------------------------
//函数名称:void JudgeModuleStatus(void)
//功    能:判断模块运行,config,测试和标定的状态
//输入参数:无
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void JudgeModuleStatus(void)
{	
	if ((MainModule.uchModuleFlag == 0x01) || (MainModule.uchHWConfigStatus == 0))
	{
		MainModule.uchModuleStatus = 0x01;
		if (MainModule.uchModuleStatusChange == 1)
		{
			SampleStartControl();
			MainModule.uchModuleStatusChange = 0;
		}
		
	}
	else if ((MainModule.uchModuleFlag == 0x02) && (MainModule.uchHWConfigStatus == 1))	
	{
		MainModule.uchModuleStatus = 0x02;
		SetModuleStatusCOMM(1);
		MainModule.uchModuleStatusChange = 1;
		
		return;
	}
	else if ((MainModule.uchModuleFlag == 0x03) && (MainModule.uchHWConfigStatus == 1))
	{
		MainModule.uchModuleStatus = 0x03;
		SampleStopControl();
		MainModule.uchModuleStatusChange = 1;		
	}
	else if ((MainModule.uchModuleFlag == 0x04) && (MainModule.uchHWConfigStatus == 1))
	{
		MainModule.uchModuleStatus = 0x04;
		SampleStartControl();
		MainModule.uchModuleStatusChange = 1;		
	}
	else 
	{
		MainModule.uchModuleStatus = 0x01;				//默认运行状态		
	}		  	
	SetModuleStatusCOMM(0);		//除了Config状态,其余状态不能配置系统参数
}	   	

//--------------------------------------------------------------------------------------------------
//函数名称:void SetGAPZeroCountResultMain(unsigned char uchChannel, unsigned int uiGAPCountValue)
//功    能:将标定的间隙电压的AD零点值传送到框架模块中
//输入参数:通道号,计算的GAP AD值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetGAPZeroCountResultMain(unsigned char uchChannel, unsigned int uiGAPCountValue)
{
	All.Para.Channel[uchChannel - 1].uiGAPADZero = uiGAPCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetGAPFullCountResultMain(unsigned char uchChannel, unsigned int uiGAPCountValue)
//功    能:将标定的间隙电压的AD满度值送到框架中
//输入参数:通道号,计算后的DA4mA值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetGAPFullCountResultMain(unsigned char uchChannel, unsigned int uiGAPCountValue)
{
	All.Para.Channel[uchChannel - 1].uiGAPADFull = uiGAPCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetDAZeroCountResultMain(unsigned char uchChannel, unsigned int uiDACountValue)
//功    能:将标定后的DA4mA值传送到框架参数中
//输入参数:通道号,计算后的DA4mA值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetDAZeroCountResultMain(unsigned char uchChannel, unsigned int uiDACountValue)
{
	All.Para.Channel[uchChannel - 1].uiDAZero = uiDACountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetDAFullCountResultMain(unsigned char uchChannel, unsigned int uiDACountValue)
//功    能:将标定后的DA20mA值传送到框架参数中
//输入参数:通道号,计算后的DA20mA值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetDAFullCountResultMain(unsigned char uchChannel, unsigned int uiDACountValue)
{
	All.Para.Channel[uchChannel - 1].uiDAFull = uiDACountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetVibADZeroCountResultMain(unsigned char uchChannel, unsigned int uiVibADCountValue)
//功    能:将标定后的振动零点值传送到框架参数中
//输入参数:通道号,计算后的振动零点值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetVibADZeroCountResultMain(unsigned char uchChannel, unsigned int uiVibADCountValue)
{
	All.Para.Channel[uchChannel - 1].uiVibADZero = uiVibADCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetVibADFullCountResultMain(unsigned char uchChannel, unsigned int uiVibADCountValue)
//功    能:将标定后的振动满度值传送到框架参数中
//输入参数:通道号,计算后的振动满度值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetVibADFullCountResultMain(unsigned char uchChannel, unsigned int uiVibADCountValue)
{
	All.Para.Channel[uchChannel - 1].uiVibADFull = uiVibADCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetDisADZeroCountResultMain(unsigned char uchChannel, unsigned int uiDisADCountValue)
//功    能:将标定后的位置零点值传送到框架参数中
//输入参数:通道号,计算后的位置零点值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetDisADZeroCountResultMain(unsigned char uchChannel, unsigned int uiDisADCountValue)
{
	All.Para.Channel[uchChannel - 1].uiDisADZero = uiDisADCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetDisADFullCountResultMain(unsigned char uchChannel, unsigned int uiDisADCountValue)
//功    能:将标定后的位置满度值传送到框架参数中
//输入参数:通道号,计算后的位置满度值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetDisADFullCountResultMain(unsigned char uchChannel, unsigned int uiDisADCountValue)
{
	All.Para.Channel[uchChannel - 1].uiDisADFull = uiDisADCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetLittleADZeroCountResultMain(unsigned char uchChannel, unsigned int uiLittleADCountValue)
//功    能:将标定后的小量程零点值传送到框架参数中
//输入参数:通道号,计算后的小量程零点值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetLittleADZeroCountResultMain(unsigned char uchChannel, unsigned int uiLittleADCountValue)
{
	All.Para.Channel[uchChannel - 1].uiLittleRangeZero = uiLittleADCountValue;
}

//--------------------------------------------------------------------------------------------------
//函数名称:void SetLittleADFullCountResultMain(unsigned char uchChannel, unsigned int uiLittleADCountValue)
//功    能:将标定后的小量程满度值传送到框架参数中
//输入参数:通道号,计算后的小量程满度值
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void SetLittleADFullCountResultMain(unsigned char uchChannel, unsigned int uiLittleADCountValue)
{
	All.Para.Channel[uchChannel - 1].uiLittleRangeFull = uiLittleADCountValue;
}

//-----------------------------------------------------------------------
//函数名称: unsigned char JudgeBypassStatus(unsigned char uchChannel)
//功    能:判断旁路状态			          00:  no  bypass
//输入参数:通道				软件bypass命令:	  01:  Alert bypass			  没有加GAP的情况下
//返    回:无					          02:  danger bypass
//完成日期:6/21/2007				          03:  alert and danger  bypass
//                      	MainModule.uchBypassStatus	 00: all bypass 01:alert bypass  02:danger bypass
//-----------------------------------------------------------------------				 ff:no bypass
void JudgeBypassStatus(unsigned char uchChannel)
{
	if (MainModule.uchHWBypassStatus == 0) 
	{
		MainModule.uchBypassStatus[uchChannel - 1] = 0x00;		//tong
	}
	else 
	{
		if (All.Para.uiBypassFlag[uchChannel - 1] == 0x01) //|| (MainModule.uchSoftBypassTotalStatus == 0x01))
		{		
			MainModule.uchBypassStatus[uchChannel - 1] = 0x01;	
		}
		else if (All.Para.uiBypassFlag[uchChannel - 1] == 0x02) //|| (MainModule.uchSoftBypassTotalStatus == 0x02))
		{		
			MainModule.uchBypassStatus[uchChannel - 1] = 0x02;
		}
		else if (All.Para.uiBypassFlag[uchChannel - 1] == 0x03) //|| (MainModule.uchSoftBypassTotalStatus == 0x03))
		{
			MainModule.uchBypassStatus[uchChannel - 1] = 0x00;	
		}
		else  
		{
			MainModule.uchBypassStatus[uchChannel - 1] = 0xff;
		}
	}
}

//--------------------------------------------------------------------------------------------------
//函数名称:void JudgeBypassFlag(unsigned char uchChannel)
//功    能:判断Bypass状态
//输入参数:通道号
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void JudgeBypassFlag(unsigned char uchChannel)
{
	if (MainModule.uchBypassStatus[uchChannel - 1] == 0xff)
	{
		MainModule.uchBypassFlag[uchChannel - 1] = 0;	
	}
	else if ((MainModule.uchBypassStatus[uchChannel - 1] == 0x00) || (MainModule.uchBypassStatus[uchChannel - 1] == 0x01)
				|| (MainModule.uchBypassStatus[uchChannel - 1] == 0x02))
	{
		MainModule.uchBypassFlag[uchChannel - 1] = 1;	
	}
}

//--------------------------------------------------------------------------------------------------
//函数名称:void JudgeAndReportAlertEvenStatus(unsigned char uchChannel)
//功    能:判断报警事件的状态
//输入参数:通道号
//返    回:无
//完成日期:4/16/2007
//--------------------------------------------------------------------------------------------------
void JudgeAndReportAlertEvenStatus(unsigned char uchChannel)
{
	if (MainModule.uchCPUAddressFlag == 0)
	{
		;
	}
	else if (MainModule.uchCPUAddressFlag == 1)
	{												   
		uchChannel = uchChannel - 2;		
	}	
//	if ((All.Para.Ch[uchChannel - 1].uiChEnable == 1) && (MainModule.uchChannelOK[uchChannel - 1] == 0))
	if (MainModule.uchEnableStatus[uchChannel - 1] == 1)   // && (MainModule.uchChannelOK[uchChannel - 1] == 0))
	{
		if (MainModule.uchChannelAlarm[uchChannel - 1] == MainModule.uchLastChannelAlarm[uchChannel - 1])
		{
			MainModule.uchLastChannelAlarm[uchChannel - 1] = MainModule.uchChannelAlarm[uchChannel - 1];
			return;	  //无状态变化,返回,不上报报警
		}
		else 
		{
			if (MainModule.uchLastChannelAlarm[uchChannel - 1] == 0x00)
			{
				if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x02)
				{
					ReportAlertEvent(uchChannel,ENTERLOWALERTALARM);//状态有变化,上报		
				}
				else if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x03)
				{
					ReportAlertEvent(uchChannel,ENTERLOWALERTALARM);
					ReportAlertEvent(uchChannel,ENTERLOWDANGERALARM);
				}
				else if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x04)
				{
					ReportAlertEvent(uchChannel,ENTERHIGHALERTALARM);
				}
				else if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x0c)
				{
					ReportAlertEvent(uchChannel,ENTERHIGHALERTALARM);
					ReportAlertEvent(uchChannel,ENTERHIGHDANGERALARM);
				}
				else if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x01)	   //20080517
				{
					ReportAlertEvent(uchChannel,ENTERLOWDANGERALARM);
				}
				else if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x08)		//20080517
				{
					ReportAlertEvent(uchChannel,ENTERHIGHDANGERALARM);
				}			
			}
			else if (MainModule.uchLastChannelAlarm[uchChannel - 1] == 0x02)
			{
				if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x00)
				{
					ReportAlertEvent(uchChannel,QUITLOWALERTALARM);
				}
				else if (MainModule.uchChannelAlarm[uchChannel - 1] == 0x03)

⌨️ 快捷键说明

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