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

📄 alert_main.cpp~

📁 用linux开发的安防暴警的有关代码
💻 CPP~
📖 第 1 页 / 共 5 页
字号:
		}		cbo_device_port->item.index(cbo_device_port->item.findi(DEVICE_CNO[op_dev->device_cno]));		cbo_device_port->value(DEVICE_CNO[op_dev->device_cno]);		//endure time		cbo_local_setup_endure_time->item.clear();		for (int i=0;i<ENDURE_TIME_NUM;i++)		{			cbo_local_setup_endure_time->item.add(ENDURE_TIME[i], i);		}		cbo_local_setup_endure_time->item.index(op_dev->alert_local_endure_time);		cbo_local_setup_endure_time->value(ENDURE_TIME[op_dev->alert_local_endure_time]);		//repeat times		cbo_auto_dial_times->item.clear();		cbo_inform_center_setup_times->item.clear();		for (int i=0;i<REPEAT_TIME_NUM;i++)		{			cbo_auto_dial_times->item.add(REPEAT_TIME[i], i);			cbo_inform_center_setup_times->item.add(REPEAT_TIME[i], i);		}		cbo_auto_dial_times->item.index(op_dev->alert_auto_dial_repeat);		cbo_auto_dial_times->value(REPEAT_TIME[op_dev->alert_auto_dial_repeat]);		cbo_inform_center_setup_times->item.index(op_dev->alert_inform_center_repeat);		cbo_inform_center_setup_times->value(REPEAT_TIME[op_dev->alert_inform_center_repeat]);		//interval time		cbo_auto_dial_interval_time->item.clear();		cbo_inform_center_setup_interval_time->item.clear();		for (int i=0;i<INTERVAL_TIME_NUM;i++)		{			cbo_auto_dial_interval_time->item.add(INTERVAL_TIME[i], i);			cbo_inform_center_setup_interval_time->item.add(INTERVAL_TIME[i], i);		}		cbo_auto_dial_interval_time->item.index(op_dev->alert_auto_dial_interval_time);		cbo_auto_dial_interval_time->value(INTERVAL_TIME[op_dev->alert_auto_dial_interval_time]);		cbo_inform_center_setup_interval_time->item.index(op_dev->alert_inform_center_interval_time);		cbo_inform_center_setup_interval_time->value(INTERVAL_TIME[op_dev->alert_inform_center_interval_time]);		//拨号报警声音		cbo_auto_dial_sound->item.clear();		LoadFileNameToCombo (cbo_auto_dial_sound);		if (cbo_auto_dial_sound->item.find(op_dev->alert_auto_dial_sound)>-1)		{			cbo_auto_dial_sound->item.index(cbo_auto_dial_sound->item.find(op_dev->alert_auto_dial_sound));			cbo_auto_dial_sound->value(op_dev->alert_auto_dial_sound);		}		else		{			InformDlg("拨号报警声音文件丢失!","错误信息");			cbo_auto_dial_sound->item.index(cbo_auto_dial_sound->item.find(DIAL_TYPE_COMMON));			cbo_auto_dial_sound->value(DIAL_TYPE_COMMON);		}		//本地报警声音		cbo_local_setup_sound->item.clear();		LoadFileNameToCombo (cbo_local_setup_sound);		if (cbo_local_setup_sound->item.find(op_dev->alert_local_sound)>-1)		{			cbo_local_setup_sound->item.index(cbo_local_setup_sound->item.find(op_dev->alert_local_sound));			cbo_local_setup_sound->value(op_dev->alert_local_sound);		}		else		{			InformDlg("本地报警声音文件丢失!","错误信息");			cbo_local_setup_sound->item.index(cbo_local_setup_sound->item.find(LOCAL_TYPE_COMMON));			cbo_local_setup_sound->value(LOCAL_TYPE_COMMON);		}	}	//权限设置	if (!mode&&op_dev->device_type==DEVICE_WIRELESS)//新建无线设备	{		bt_device_wireless_register->show();		bt_device_ok->hide();	}	else	{		bt_device_wireless_register->hide();		bt_device_ok->show();	}		if (PROFILES.current_user_class==0)	{		if (mode&&op_dev->device_type==DEVICE_WIRELESS)//修改无线设备		{			cbo_alert_type->deactivate();			cbo_device_port->deactivate();		}		else		{			cbo_alert_type->activate();			cbo_device_port->activate();		}			ipt_device_name->activate();		ipt_device_position->activate();		wcbo_inform_center_para1->activate();		wcbo_inform_center_para2->activate();		cbo_inform_center_setup_times->activate();		cbo_inform_center_setup_interval_time->activate();	}	else	{		cbo_alert_type->deactivate();		cbo_device_port->deactivate();		ipt_device_name->deactivate();		ipt_device_position->deactivate();		wcbo_inform_center_para1->deactivate();		wcbo_inform_center_para2->deactivate();		cbo_inform_center_setup_times->deactivate();		cbo_inform_center_setup_interval_time->deactivate();	}}/************************************************************************************		main_window*************************************************************************************/voidcb_main_password_setup(Fl_Button *, void *){	if (!password_setup_window)		password_setup_window=(Fl_Window*)make_password_setup_window();	init_password_setup(PROFILES.current_user_class);	password_setup_window->position((SCREEN_WIDTH-password_setup_window->w())/2,90);	password_setup_window->show();}voidcb_main_record(Fl_Button *, void *){	if (!record_window)		record_window=(Fl_Window *)make_record_window();	update_record_tree (scrl_record_items);	record_window->show();	XSetSelectionOwner (fl_display, alert_run_atom, fl_xid (record_window),CurrentTime);	main_window->hide();}voidcb_main_delay_setup (Fl_Button *, void *){	int enter_time,exit_time;	if (!delay_setup_window)		delay_setup_window=(Fl_Window *)make_delay_setup_window();	if ( query_delay_parameter(&enter_time,&exit_time))	{		InformDlg ("通信失败!","错误信息");		return;	}		ipt_delay_setup_enter_delay->value(enter_time);	ipt_delay_setup_exit_delay->value(exit_time);			delay_setup_window->position((SCREEN_WIDTH-delay_setup_window->w())/2,(SCREEN_HEIGHT-delay_setup_window->h())/2);	//delay_setup_window->position((SCREEN_WIDTH-delay_setup_window->w())/2,90);	delay_setup_window->show();}voidcb_main_device_setup (Fl_Button *, void *){	if (!setup_window)		setup_window=(Fl_Window *)make_setup_window();	set_button_disable();	//update_wire_device_tree(scrl_setup_wire_device);		//update_wireless_device_tree(scrl_setup_wireless_device);		setup_window->show();	XSetSelectionOwner (fl_display, alert_run_atom, fl_xid (setup_window),CurrentTime);	main_window->hide();}voidcb_main_out_defence_on (Fl_Button *, void *){	if (arm_dearm_operation(DEFENCE_OUT))	{		refresh_defence_stat();		InformDlg ("通信失败!","错误信息");		return;	}		PROFILES.alert_defence_stat=DEFENCE_OUT;	update_main_tree (scrl_main_device);}voidcb_main_inner_defence_on (Fl_Button *, void *){	if (arm_dearm_operation(DEFENCE_INNER))	{		refresh_defence_stat();		InformDlg ("通信失败!","错误信息");		return;	}		PROFILES.alert_defence_stat=DEFENCE_INNER;	update_main_tree (scrl_main_device);}voidcb_main_defence_off(Fl_Button *, void *){	if (arm_dearm_operation(DEFENCE_OFF))	{		refresh_defence_stat();		InformDlg ("通信失败!","错误信息");		return;	}	PROFILES.alert_defence_stat=DEFENCE_OFF;	update_main_tree (scrl_main_device);}voidcb_main_exit(Fl_Button *, void *){	printf("main exit start...\n");	exit(0);}voidcb_win_main(Fl_Window *,void *){	bt_main_exit->do_callback(bt_main_exit);	}/*****************************************************************************	setup_window******************************************************************************/voidcb_setup_new(Fl_Button *, void *){	alert_device_t	*temp_device;	int device_type=0;	int index=0;	int current_dev_num=0;	index=iconbr_setup_list->value();	if (index==WIRE_SETUP)		device_type=DEVICE_WIRE;	else if (index==WIRELESS_SETUP)		device_type=DEVICE_WIRELESS;	else 		printf("Select error\n");	for (temp_device=PROFILES.dev_head;temp_device;temp_device=temp_device->next)	{		if ( temp_device->device_type==device_type )			current_dev_num++;	}	if (current_dev_num==DEVICE_CNO_NUM)	{		InformDlg ("没有可用的端口!","错误信息");		return;	}	if(!device_window)		device_window=(Fl_Window*)make_device_window();	DEVICE_EDIT_MODE=0;//添加模式	if (query_zone_parameter(device_type))	{		InformDlg ("通信失败!","错误信息");		return;	}	PROFILES.dev_temp=new alert_device_t;	for (int i=0;i<100;i++)	{		for (temp_device=PROFILES.dev_head;temp_device;temp_device=temp_device->next)		{			if (temp_device->device_id==i)				break;		}		if (!temp_device)		{			PROFILES.dev_temp->device_id=i;			break;		}	}	PROFILES.dev_temp->alert_type=0;	PROFILES.dev_temp->device_name[0]='\0';	for (int i=0;i<DEVICE_CNO_NUM;i++)	{		for (temp_device=PROFILES.dev_head;temp_device;temp_device=temp_device->next)		{			if ((temp_device->device_cno==i)&&(temp_device->device_type==device_type))				break;		}		if (!temp_device)		{			PROFILES.dev_temp->device_cno=i;			break;		}	}	PROFILES.dev_temp->device_position[0]='\0';	PROFILES.dev_temp->device_module=0;	PROFILES.dev_temp->alert_local_enable=0;	strcpy(PROFILES.dev_temp->alert_local_sound,LOCAL_TYPE_COMMON);	PROFILES.dev_temp->alert_local_endure_time=0;	PROFILES.dev_temp->alert_local_txt[0]='\0';	PROFILES.dev_temp->alert_auto_dial_enable=0;	strcpy(PROFILES.dev_temp->alert_auto_dial_sound,DIAL_TYPE_COMMON);	PROFILES.dev_temp->alert_auto_dial_repeat=0;	PROFILES.dev_temp->alert_auto_dial_interval_time=0;	PROFILES.dev_temp->alert_auto_dial_number1[0]='\0';	PROFILES.dev_temp->alert_auto_dial_number2[0]='\0';	PROFILES.dev_temp->alert_auto_dial_number3[0]='\0';	PROFILES.dev_temp->alert_auto_dial_number4[0]='\0';	PROFILES.dev_temp->alert_inform_center_enable=0;	PROFILES.dev_temp->alert_inform_center_repeat=0;	PROFILES.dev_temp->alert_inform_center_interval_time=0;	PROFILES.dev_temp->alert_inform_center_para1[0]='\0';	PROFILES.dev_temp->alert_inform_center_para2[0]='\0';		PROFILES.dev_temp->device_enable=DEVICE_ALERT_ENABLE;	PROFILES.dev_temp->device_self_alert=DEVICE_ALERT_ENABLE;	PROFILES.dev_temp->device_stat=0;	PROFILES.dev_temp->device_type=device_type;	PROFILES.dev_temp->next=NULL;	init_device_dialog(PROFILES.current_user_class,DEVICE_EDIT_MODE,PROFILES.dev_temp);	device_window->show();	XSetSelectionOwner (fl_display, alert_run_atom, fl_xid (device_window),CurrentTime);	if (setup_window)		setup_window->hide();	if (main_window)		main_window->hide();}voidcb_setup_del (Fl_Button *, void *){	char buf[256];	if (!PROFILES.dev_current)	return;	int r;	r = QuestDlg("确实要永久删除所选设备?","删除设备");	if (r)  return;//1	query_zone_parameter(PROFILES.dev_current-> device_type);	int device_enable_save=0;	device_enable_save=PROFILES.dev_current->device_enable;	PROFILES.dev_current->device_enable=0;	if (set_zone_parameter(PROFILES.dev_current))	{		PROFILES.dev_current->device_enable=device_enable_save;				InformDlg("通信失败!","错误信息");			return;	}	sprintf(buf,"%d",PROFILES.dev_current->device_id);	if (PROFILES.dev_count==1)	{		PROFILES.dev_head=NULL;		PROFILES.dev_tail=NULL;	}	else if (PROFILES.dev_current==PROFILES.dev_head)	{		PROFILES.dev_head=PROFILES.dev_head->next;		PROFILES.dev_head->pre=NULL;	}	else if(PROFILES.dev_current==PROFILES.dev_tail)	{		PROFILES.dev_tail=PROFILES.dev_tail->pre;		PROFILES.dev_tail->next=NULL;	}	else	{		PROFILES.dev_current->pre->next=PROFILES.dev_current->next;		PROFILES.dev_current->next->pre=PROFILES.dev_current->pre;	}	PROFILES.dev_count--;	delete PROFILES.dev_current;	PROFILES.dev_current=NULL;	LPREFERENCES.Clear();	LPREFERENCES.CopyFrom (&PREFERENCES);	WordList *F = LPREFERENCES.Get_wordlist ("device");	if (F->Find (buf) >= 0)	{		LPREFERENCES.Get_collection ("device")->Delete (buf);	}	sprintf (buf, "%s/%s",SETUP_DIR,"setup.ini.bak" );	PREFERENCES.Save (buf);	sprintf (buf, "%s/%s",SETUP_DIR,"setup.ini" );	LPREFERENCES.Save (buf);	PREFERENCES.Clear();	PREFERENCES.CopyFrom (&LPREFERENCES);	int index=0;	index=iconbr_setup_list->value();	if (index==WIRE_SETUP)		update_wire_device_tree(scrl_setup_wire_device);	else if (index==WIRELESS_SETUP)		update_wireless_device_tree(scrl_setup_wireless_device);	else 		printf("Select error\n");	update_main_tree (scrl_main_device);	set_button_disable();}voidcb_setup_edit (Fl_Button *, void *){	int index=0;	int device_type=0;	DEVICE_EDIT_MODE=1;//修改模式紡	if (!PROFILES.dev_current)	return;	index=iconbr_setup_list->value();	if (index==WIRE_SETUP)		device_type=WIRE;	else if (index==WIRELESS_SETUP)		device_type=WIRELESS;	else 		printf("Select error\n");	if (query_zone_parameter(device_type))	{		InformDlg ("通信失败!","错误信息");		return;	}	init_device_dialog(PROFILES.current_user_class,DEVICE_EDIT_MODE,PROFILES.dev_current);	device_window->show();	XSetSelectionOwner (fl_display, alert_run_atom, fl_xid (device_window),CurrentTime);	if (setup_window)		setup_window->hide();	if (main_window)		main_window->hide();}voidinit_user_setup (void){	DEVICE_EDIT_MODE=1;//修改模式紡	//write here	if (!PROFILES.dev_current)	return;	init_device_dialog(PROFILES.current_user_class,DEVICE_EDIT_MODE,PROFILES.dev_current);	if (query_zone_parameter(PROFILES.dev_current->device_type))	{		InformDlg ("通信失败!","错误信息");		return;	}	device_window->show();	XSetSelectionOwner (fl_display, alert_run_atom, fl_xid (device_window),CurrentTime);	if (setup_window)		setup_window->hide();	if (main_window)		main_window->hide();}voidcb_setup_comm (Fl_Button *, void *){	int fdnumber;	int read_num=0;	char buf[256];	if (!comm_window)		comm_window=(Fl_Window*)make_comm_window();	sprintf(buf,"%s/%s",SETUP_DIR,"server_ip.ini");	fdnumber = open (buf,O_RDONLY | O_CREAT , 0666

⌨️ 快捷键说明

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