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

📄 alarm.c

📁 单片机程序代码,经过很详细的测试.呵呵,硬件相关.
💻 C
📖 第 1 页 / 共 3 页
字号:
unsigned char xdata temp;
	tx_buf[0] = '$';                                                              
	tx_buf[1] = '2';                                                              
	tx_buf[2] = '1';                                                              
	tx_buf[3] = 0x46;						//送命令符F00 
	tx_buf[4] = 0x30;                                                             
	tx_buf[5] = 0x30;                                                             
	tx_buf[6] = '0';						//信息域长度31
	tx_buf[7] = '0';                                                              
	tx_buf[8] = '1';
	tx_buf[9] = 'F';
	tx_buf[10] = boardid + 0x30;			//盘号
	tx_buf[11] = '2';
	tx_buf[12] = groupid + 0x30;			//组号
	for (temp = 0; temp <= 6; temp++){
		report_check_TU(boardid,7 * (groupid - 1) + temp + 1,13 + temp * 4);	//调用支路函数
	}
	tx_buf[41] = '*';
	tx_buf_pointer = 0;	                                     
	while(tx_buf[tx_buf_pointer] != '*'){                        
		SBUF = tx_buf[tx_buf_pointer];                       
		while(tx_done == 0);                                 
		tx_done = 0;                                         
		tx_buf_pointer++;                                    
	}                                                            
	SBUF = tx_buf[tx_buf_pointer];          //发送最后一个字符'*'
	while(tx_done == 0);                                         
	tx_done = 0;
}
	
void report_check_EOS(unsigned char board){
//上报Eos盘的告警帧
unsigned char xdata i;
unsigned char xdata temp;

	tx_buf[0] = '$';                                                              
	tx_buf[1] = '2';                                                              
	tx_buf[2] = '1';                                                              
	tx_buf[3] = 0x46;					//送命令符F00 
	tx_buf[4] = 0x30;                                                             
	tx_buf[5] = 0x30;                                                             
	tx_buf[6] = '0';					//信息域长度为9
	tx_buf[7] = '0';
	tx_buf[8] = '0';
	tx_buf[9] = '9';
	tx_buf[10] = board + 0x30;			//盘号
	tx_buf[11] = '3';
	tx_buf[12] = '0';					//组号
	for (i = 0; i < 3; i++){
		temp = check_alarm_Eos[board - 1][i] >> 4;
		if (temp > 9)
			tx_buf[13 + 2 * i] = temp + 0x37;
		else tx_buf[13 + 2 * i] = temp + 0x30;
		temp = check_alarm_Eos[board - 1][i] & 0x0F;
		if (temp > 9)
			tx_buf[14 + 2 * i] = temp + 0x37;
		else tx_buf[14 + 2 * i] = temp + 0x30;
	}
	tx_buf[19] = '*';
	tx_buf_pointer = 0;	                                     
	while(tx_buf[tx_buf_pointer] != '*'){                        
		SBUF = tx_buf[tx_buf_pointer];                       
		while(tx_done == 0);                                 
		tx_done = 0;                                         
		tx_buf_pointer++;                                    
	}                                                            
	SBUF = tx_buf[tx_buf_pointer];          //发送最后一个字符'*'
	while(tx_done == 0);                                         
	tx_done = 0;
}

void report_alarm(void){
//F00每秒发送告警函数
unsigned char xdata num;

//发送MCB光口1的中断帧
	if (frame_flg_work[0] != 0 | frame_flg_before[0] != 0){					//如当前和上一秒告警不为0
		report_int_mcb0();													//发送告警
	}
	frame_flg_before[0] = frame_flg_work[0];								//将当前告警状态存为上一秒告警状态
//发送MCB光口2的中断帧
	if (frame_flg_work[1] != 0 | frame_flg_before[1] != 0){
		report_int_mcb1();
	}
	frame_flg_before[1] = frame_flg_work[1];
//发送OTB光口1的中断帧
	if (start_flg[0] == 0){
		if (frame_flg_work[2] != 0 | frame_flg_before[2] != 0){
			report_int_otb2();
		}
		frame_flg_before[2] = frame_flg_work[2];
//发送OTB光口2的中断帧	
		if (frame_flg_work[3] != 0 | frame_flg_before[3] != 0){
			report_int_otb3();
		}
		frame_flg_before[3] = frame_flg_work[3];
	}
//发送MCB盘的非中断告警帧
	if (frame_flg_work[4] != 0 | frame_flg_before[4] != 0){
		report_check_mcb();
	}
	frame_flg_before[4] = frame_flg_work[4];
//发送OTB盘的非中断告警帧
	if (start_flg[0] == 0){
		if (frame_flg_work[5] != 0 | frame_flg_before[5] != 0){
			report_check_otb();
		}
		frame_flg_before[5] = frame_flg_work[5];
	}
//发送2M盘1的1~7支路帧
	if (start_flg[1] == 0){
		frame_flg_work[6] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[6] |= check_alarm_2M[0][num][0] | check_alarm_2M[0][num][1];
		}	
		if (frame_flg_work[6] != 0 | frame_flg_before[6] !=0){
			report_check_TU_group(1,1);
		}
		frame_flg_before[6] = frame_flg_work[6];
//发送2M盘1的8~14支路帧
		frame_flg_work[7] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[7] |= check_alarm_2M[0][7 + num][0] | check_alarm_2M[0][7 + num][1];
		}
		if (frame_flg_work[7] != 0 | frame_flg_before[7] !=0){
			report_check_TU_group(1,2);
		}
		frame_flg_before[7] = frame_flg_work[7];
//发送2M盘1的15~21支路帧
		frame_flg_work[8] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[8] |= check_alarm_2M[0][14 + num][0] | check_alarm_2M[0][14 + num][1];
		}
		if (frame_flg_work[8] != 0 | frame_flg_before[8] !=0){
			report_check_TU_group(1,3);
		}
		frame_flg_before[8] = frame_flg_work[8];
	}
//发送2M盘2的1~7支路帧
	if (start_flg[2] == 0){
		frame_flg_work[9] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[9] |= check_alarm_2M[1][num][0] | check_alarm_2M[1][num][1];
		}
		if (frame_flg_work[9] != 0 | frame_flg_before[9] !=0){
			report_check_TU_group(2,1);
		}
		frame_flg_before[9] = frame_flg_work[9];
//发送2M盘2的8~14支路帧
		frame_flg_work[10] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[10] |= check_alarm_2M[1][7 + num][0] | check_alarm_2M[1][7 + num][1];
		}
		if (frame_flg_work[10] != 0 | frame_flg_before[10] !=0){
			report_check_TU_group(2,2);
		}
		frame_flg_before[10] = frame_flg_work[10];
//发送2M盘2的15~21支路帧
		frame_flg_work[11] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[11] |= check_alarm_2M[1][14 + num][0] | check_alarm_2M[1][14 + num][1];
		}
		if (frame_flg_work[11] != 0 | frame_flg_before[11] !=0){
			report_check_TU_group(2,3);
		}
		frame_flg_before[11] = frame_flg_work[11];
	}
//发送2M盘3的1~7支路帧
	if (start_flg[3] == 0){
		frame_flg_work[12] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[12] |= check_alarm_2M[2][num][0] | check_alarm_2M[2][num][1];
		}
		if (frame_flg_work[12] != 0 | frame_flg_before[12] !=0){
			report_check_TU_group(3,1);
		}
		frame_flg_before[12] = frame_flg_work[12];
//发送2M盘3的8~14支路帧	
		frame_flg_work[13] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[13] |= check_alarm_2M[2][7 + num][0] | check_alarm_2M[2][7 + num][1];
		}
		if (frame_flg_work[13] != 0 | frame_flg_before[13] !=0){
			report_check_TU_group(3,2);
		}
		frame_flg_before[13] = frame_flg_work[13];
//发送2M盘3的15~21支路帧	
		frame_flg_work[14] = 0;
		for (num = 0; num <= 6; num++){
			frame_flg_work[14] |= check_alarm_2M[2][14 + num][0] | check_alarm_2M[2][14 + num][1];
		}
		if (frame_flg_work[14] != 0 | frame_flg_before[14] !=0){
			report_check_TU_group(3,3);
		}
		frame_flg_before[14] = frame_flg_work[14];
	}

//发送Eos盘的告警帧
	for (num = 0; num < 3; num++){
		if (start_flg_EOS[num + 1] == 0){
			frame_flg_work_eos[num] |= check_alarm_Eos[num][0] | check_alarm_Eos[num][1] | check_alarm_Eos[num][2];
			if (frame_flg_work_eos[num] != 0 | frame_flg_before_eos[num] != 0)
		 		report_check_EOS(num + 1);
			frame_flg_before_eos[num] = frame_flg_work_eos[num];
		}
	}
}


unsigned char alarm_led(struct cmd_para_save *set_alarm_led){
//C66告警灯管理命令
unsigned char xdata temp;
unsigned char xdata return_value;

	commandid = 0x00433636;
	temp = set_alarm_led -> alarm_led_value;

	switch(temp){
		case 0: XBYTE[0xBC00] = 0x01;
				XBYTE[0xC000] = 0x01;
				return_value = 0;
				break;
		case 1:
		case 2: XBYTE[0xBC00] = 0;
				return_value = 0;
				break;
		case 3:
		case 4: XBYTE[0xC000] = 0;
				return_value = 0;
				break;
		case 5: XBYTE[0xBC00] = 1;
				return_value = 0;
				break;
		case 6: XBYTE[0xC000] = 1;
				return_value = 0;
				break;
		default:return_value = 2;
				break;
	}

	SetResRdyTbl(1);
	return (return_value);
}	

⌨️ 快捷键说明

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