static ssize_t show_present(struct device *dev, struct device_attribute *da,
             char *buf)
{
    struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
    struct as7716_24xc_expansion_card_data *data = update_device(dev, 0);
    ssize_t status = 0;
	u8 present = !(data->status[CARD_PRESENT] & BIT(data->driver_slot));

    if (!data->valid) {
        return -EIO;
    }

	return sprintf(buf, "%d\n", (int)present);
}
Esempio n. 2
0
//�豸������֪ͨ
int upgradeapp::alarm_notify(param_list * pl){

	cJSON * jssn = cJSON_GetObjectItem(pl->jsdata, "sn");
	cJSON * jstyp = cJSON_GetObjectItem(pl->jsdata, "type");

	if(!jssn || jssn->type != cJSON_String ||
			!jstyp || jstyp->type != cJSON_String){
		log_out(log_error, "alarm_notify::invalid json %s\n", pl->content);
		return -1;
	}

	int state = strcmp(jstyp->valuestring, offline_alarm) ? em_online: em_offline;

	return update_device(jssn->valuestring, state , pl->n);
}
Esempio n. 3
0
int baseapp::alarm_notify(param_list * pl){
	
	cJSON * jsdev = cJSON_GetObjectItem(pl->jsdata, "device_id");
	cJSON * jscpy = cJSON_GetObjectItem(pl->jsdata, "company_id");
	cJSON * jstyp = cJSON_GetObjectItem(pl->jsdata, "type");
	
	if(!jsdev || jsdev->type != cJSON_Number ||
		!jscpy || jscpy->type != cJSON_Number ||
		!jstyp || jstyp->type != cJSON_String){
		log_out(log_error, "alarm_notify::invalid json %s\n", pl->content);
		return -1;
	}
	
	uint cpy = jscpy->valueuint;
	uint dev = jsdev->valueuint;
	int state = strcmp(jstyp->valuestring, offline_alarm) ? em_online: em_offline;
	update_device(dev, cpy, state, pl->n);
	return 0;
}
Esempio n. 4
0
//上下线通知
int svrapp::alarm_notify(param_list * pl){
	
	cJSON * jsdev = cJSON_GetObjectItem(pl->jsdata, "devkey");
	cJSON * jscpy = cJSON_GetObjectItem(pl->jsdata, "company_id");
	cJSON * jstyp = cJSON_GetObjectItem(pl->jsdata, "type");
	server_info * sif = (server_info*)pl->n->get_context();

	if(!jsdev  || jsdev->type != cJSON_String ||
		!jscpy || jscpy->type != cJSON_Number ||
		!jstyp || jstyp->type != cJSON_String){
		log_out(log_error, "alarm_notify::invalid json %s\n", pl->content);
		return -1;
	}
	
	int state = strcmp(jstyp->valuestring, offline_alarm) ? em_online: em_offline;
    
    return update_device(jsdev->valuestring, jscpy->valueuint64, (uint)time(NULL), 
    state, sif->get_numkey());
}
/* main: perform the spring simulation */
int main(int argc, char * argv[])
{
	double time,position,center,force;

	/* Parse command line arguments */
	parse_args(argc,argv);

	/* Initialize device, create constant force effect */
	init_device();

	/* Print header */
	printf("\n        position                   center                     force\n");

	/* For ever */
	for (position=0, time=0;; time+=1.0/update_rate) {

		/* Spring center oscillates */
		center = sin( time * 2 * M_PI * motion_frequency ) * motion_amplitude;

		/* Calculate spring force */
		force = ( center - position ) * spring_strength;
		if (force >  1.0) force =  1.0;
		if (force < -1.0) force = -1.0;

		/* Print graph bars */
		printf("\r");
		fprint_bar(stdout,position,12);
		printf(" ");
		fprint_bar(stdout,center,12);
		printf(" ");
		fprint_bar(stdout,force,12);
		fflush(stdout);

		/* Set force and ask for joystick position */
		update_device(force,&position);

		/* Next time... */
		usleep((unsigned long)(1000000.0/update_rate));

	}
}
Esempio n. 6
0
//��ȡ�����豸Ӧ��
int upgradeapp::get_online_device_ackx(param_list * pl){

	cJSON * jslst = cJSON_GetObjectItem(pl->jsdata, "device_list");
	if(!jslst){
		log_out(log_error, "get_online_device_ackx::no devices\n");
		return -1;
	}

	int count = cJSON_GetArraySize(jslst);
	ipaddr & peer = pl->n->get_peeraddr();

	log_out(log_debug, "get_online_device_ackx::server %s:%d count %d\n",
			peer.ip, peer.port, count);

	for(int k = 0; k < count; k++){
		cJSON * jssn = cJSON_GetArrayItem(jslst, k);
		update_device(jssn->valuestring, em_online , pl->n);
	}

	return 0;
}
Esempio n. 7
0
int main()
{
    data_t data;

    printf("\n\tGestIC %s - Console Demo\n\n", gestic_version_str());

    /* Initialize data and the device */
    init_data(&data);
    init_device(&data);

    /* Update device and menu until quit */
    while(data.running)
    {
        update_device(&data);
        update_menu(&data);
        Sleep(10);
    }

    /* Do the cleanup work */
    free_device(&data);

    return 0;
}
Esempio n. 8
0
//获取在线设备
int svrapp::get_online_device_ackx(param_list * pl){

	cJSON * jslst = cJSON_GetObjectItem(pl->jsdata, "device_list");
	if(!jslst){
		log_out(log_error, "get_online_device_ackx::no devices\n");
		return -1;
	}
	
	int count = cJSON_GetArraySize(jslst);
	ipaddr & peer = pl->n->get_peeraddr();
	server_info * sif = (server_info*)pl->n->get_context();

	log_out(log_debug, "get_online_device_ackx::server(%s) count(%d)\n", peer.ip, count);
	
	uint now = (uint)time(NULL);
	for(int k = 0; k < count; k++){
		cJSON * jsitem = cJSON_GetArrayItem(jslst, k);
		cJSON * jsdev = cJSON_GetObjectItem(jsitem, "id");
		cJSON * jscpy = cJSON_GetObjectItem(jsitem, "cpy");
        update_device(jsdev->valuestring, jscpy->valueuint64, now, 
        em_online, sif->get_numkey());
	}
	return 0;
}
Esempio n. 9
0
//��ȡ�����豸Ӧ��
int svrapp::get_online_device_ackx(param_list * pl){

	cJSON * jslst = cJSON_GetObjectItem(pl->jsdata, "device");
	if(!jslst){
		log_out(log_error, "get_online_device_ackx::no devices\n");
		return -1;
	}
	
	int count = cJSON_GetArraySize(jslst);
	ipaddr & peer = pl->n->get_peeraddr();
	server_info * s = (server_info*)pl->n->get_context();

	log_out(log_debug, "get_online_device_ackx::server %s:%d count %d\n",
		peer.ip, peer.port, count);
	
	uint now = (uint)time(NULL);
	for(int k = 0; k < count; k++){
		cJSON * jsdev = cJSON_GetArrayItem(jslst, k);
		uint dev = cJSON_GetObjectItem(jsdev, "id")->valueuint;
		uint cpy = cJSON_GetObjectItem(jsdev, "cpy")->valueuint;
		update_device(dev, cpy, now, em_online, s->get_id());
	}
	return 0;
}
void MidiDeviceEditor::set_gm_controls() {
	
	update_device();	
}
MidiDeviceEditor::MidiDeviceEditor(QWidget *p_parent,MidiDeviceDescription *p_desc) : QDialog(p_parent) {
	
	
	/**** A LOT OF CODE BORKED AND DIED IN HERE, HAD TO HAX QUITE A LOT, AND DONT KNOW WHY */
	
	LABELS_BEGIN
	
	current_bank=0;
	desc=p_desc;
	
	setLayout(new QVBoxLayout(this));
	
	QWidget *main_hb = new QWidget(this);
	main_hb->setLayout(new QHBoxLayout(main_hb));
	layout()->addWidget(main_hb);
			
	
	QWidget *left_vb = new QWidget(main_hb);
	left_vb->setLayout(new QVBoxLayout(left_vb));
	main_hb->layout()->setAlignment(left_vb,Qt::AlignTop);
	main_hb->layout()->addWidget(left_vb);
	main_hb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
	QWidget *device_hb = new QWidget;
	device_hb->setLayout(new QHBoxLayout(left_vb));
	
	LABEL("Device Name",left_vb,device_hb);			
	
	device_name = new QLineEdit;
	device_hb->layout()->addWidget(device_name);
	device_name->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
	
	QPushButton *load_button = new QPushButton(QPixmap( (const char **)icon_file_open_xpm),"",device_hb);
	device_hb->layout()->addWidget(load_button);
	QObject::connect( load_button ,SIGNAL( clicked() ), this, SLOT(load_device_slot() ) );
		
	QPushButton *save_button = new QPushButton(QPixmap( (const char **)icon_file_save_xpm),"",device_hb);
	device_hb->layout()->addWidget(save_button);
	QObject::connect( save_button ,SIGNAL( clicked() ), this, SLOT(save_device_slot() ) );
	
	device_name->setText( QStrify(desc->get_name() ) );
	QObject::connect(device_name,SIGNAL(textChanged(const QString&)),this,SLOT(device_name_changed( const QString& )));		
	
	QWidget *right_vb = new QWidget(main_hb);
	right_vb->setLayout(new QVBoxLayout(right_vb));
	main_hb->layout()->addWidget(right_vb);
	main_hb->layout()->setAlignment(right_vb,Qt::AlignTop);
	
	bank_select_method = new QComboBox;
	LABEL("Bank Select Method",right_vb,bank_select_method);
	bank_select_method->addItem("None");
	bank_select_method->addItem("MSB/Variation (CC 0)");
	bank_select_method->addItem("LSB (CC 32)");
	bank_select_method->addItem("MSB/LSB (14 Bits)");
	
	QObject::connect(bank_select_method,SIGNAL(currentIndexChanged(int)),this,SLOT(bank_select_method_changed(int)));
	
	tabs = new QTabWidget(this);
	layout()->addWidget(tabs);
	tabs->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
	
	QWidget *banks_hb = new QWidget(tabs);
	banks_hb->setLayout(new QHBoxLayout(banks_hb));
	tabs->addTab(banks_hb,"Bank List");
			
	left_vb = new QWidget(banks_hb);
	left_vb->setLayout(new QVBoxLayout(left_vb));
	banks_hb->layout()->addWidget(left_vb);
	
	banks = new QListWidget;
	LABEL("Bank List",left_vb,banks);
	
	banks->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
	
	QObject::connect(banks,SIGNAL(currentRowChanged(int)),this,SLOT(bank_selected_slot(int)));
	QObject::connect(banks,SIGNAL(currentTextChanged(const QString&)),this,SLOT(bank_name_changed(const QString&)));
	
	CHBox *bank_actions_hb = new CHBox(left_vb);
	left_vb->layout()->addWidget(bank_actions_hb);
			
	QObject::connect( new QPushButton(QPixmap( (const char **)icon_add_xpm),"",bank_actions_hb) ,SIGNAL( clicked() ), this, SLOT(add_bank_slot() ) );
	
	QObject::connect( new QPushButton(QPixmap( (const char **)icon_add_xpm),"GM",bank_actions_hb) ,SIGNAL( clicked() ), this, SLOT(add_gm_bank() ) );
	
	QObject::connect( new QPushButton(QPixmap( (const char **)icon_remove_xpm),"",bank_actions_hb) ,SIGNAL( clicked() ), this, SLOT(erase_bank_slot() ) );
	
	bank_actions_hb->layout()->setMargin(10);
	
	bank_select_MSB = new QSpinBox;
	LABEL("Bank Select MSB (CC 0):",left_vb,bank_select_MSB);
	
	bank_select_MSB->setMinimum(0);	
	bank_select_MSB->setMaximum(127);
	bank_select_MSB->setValue(0);
	QObject::connect(bank_select_MSB,SIGNAL(valueChanged(int)),this,SLOT(bank_select_MSB_changed(int)));
	
	bank_select_LSB = new QSpinBox;
	
	LABEL("Bank Select LSB (CC 32):",left_vb,bank_select_LSB);
	
	bank_select_LSB->setMinimum(0);	
	bank_select_LSB->setMaximum(127);
	bank_select_LSB->setValue(0);
	QObject::connect(bank_select_LSB,SIGNAL(valueChanged(int)),this,SLOT(bank_select_LSB_changed(int)));
	
	right_vb = new QWidget(banks_hb);
	right_vb->setLayout(new QVBoxLayout(right_vb));
	banks_hb->layout()->addWidget(right_vb);
	right_vb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
	

	LABEL("Patch List in Bank",right_vb,NULL);
	patches = new QTableWidget(128,1);
	right_vb->layout()->addWidget(patches);

	right_vb->layout()->addWidget(new QLabel("^ this is a Qt4 Bug! ^"));
	
	QStringList headers;
	headers << "Name";
	patches->setHorizontalHeaderLabels(headers);
	patches->horizontalHeader()->setResizeMode ( 0, QHeaderView::Stretch );
	patches->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
	
	for (int i=0;i<128;i++) {
		
		QTableWidgetItem *name = new QTableWidgetItem( "" );
		
		name->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled);
		patches->setItem(i,0,name );
		
	}

	QObject::connect(patches,SIGNAL(cellChanged(int,int)),this,SLOT(patch_name_changed(int,int)));
	
	
	QWidget *controls_vb = new QWidget(tabs);
	controls_vb->setLayout(new QVBoxLayout(banks_hb));
	tabs->addTab(controls_vb,"Controls");
	
	LABEL("Control List",controls_vb,NULL);
	controls = new QTableWidget(128,1);
	controls_vb->layout()->addWidget(controls);

	//controls_vb->layout()->addWidget(new QLabel("^ this is a Qt4 Bug! ^");
	
	headers=QStringList();
	headers << "Name";
	controls->setHorizontalHeaderLabels(headers);
	controls->horizontalHeader()->setResizeMode ( 0, QHeaderView::Stretch );
	controls->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
	
	QStringList idxnums;
	for (int i=0;i<128;i++) {
		
		QTableWidgetItem *name = new QTableWidgetItem( "" );
		
		name->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled);
		controls->setItem(i,0,name );
		idxnums << QString::number(i);
		
	}
	controls->setVerticalHeaderLabels(idxnums);

	QObject::connect(controls,SIGNAL(cellChanged(int,int)),this,SLOT(control_name_changed(int,int)));
	
	QPushButton *set_gm_ctrls = new QPushButton("Set GM Names",this);
	set_gm_ctrls->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
	QObject::connect(set_gm_ctrls,SIGNAL(clicked()),this,SLOT(set_gm_controls()));
	controls_vb->layout()->addWidget(set_gm_ctrls);
	controls_vb->layout()->setAlignment(set_gm_ctrls,Qt::AlignHCenter);
	
	QPushButton *acceptb = new QPushButton("Close",this);
	acceptb->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
	QObject::connect(acceptb,SIGNAL(clicked()),this,SLOT(accept()));
	layout()->addWidget(acceptb);
	layout()->setAlignment(acceptb,Qt::AlignHCenter);
		
	
	setWindowTitle("MIDI Bank Management");
	
	setMinimumSize( QSize(500,550) );
	
	QTimer *t = new QTimer(this);
	QObject::connect(t,SIGNAL(timeout()),this,SLOT(check_bank_names_changed_horrible_qt4_hack()));
	t->start(500);
	
	update_device();
}