Beispiel #1
0
void blklib_load_devices()
{
	string f;
	char devices[1024];
	char * dName;
	devlib_ent_t * d;
	char str[1024];
	
	f = string(get_working_dir()) + "config/f8-devices.inf";
	GetPrivateProfileSectionNames(devices, sizeof(devices), f.c_str());
	dName=devices;
	d = device_lib;
	while(*dName){
		if(stricmp(dName, "OEM")){
			d->name = (char*)alloc_buffer_v(dName, strlen(dName) + 1, 0);
			
			GetPrivateProfileString(dName, "description", "", str, sizeof(str), f.c_str());
			d->description = (char*)alloc_buffer_v(str, strlen(str) + 1, 0);
			
			GetPrivateProfileString(dName, "id", "", str, sizeof(str), f.c_str());
			f8_uuid_from_string(&d->dev.clsid, str);
			
			GetPrivateProfileString(dName, "n_di", "0", str, sizeof(str), f.c_str());
			d->dev.n_di = atoi(str);
			GetPrivateProfileString(dName, "n_do", "0", str, sizeof(str), f.c_str());
			d->dev.n_do = atoi(str);
			GetPrivateProfileString(dName, "n_ai", "0", str, sizeof(str), f.c_str());
			d->dev.n_ai = atoi(str);
			GetPrivateProfileString(dName, "n_ao", "0", str, sizeof(str), f.c_str());
			d->dev.n_ao = atoi(str);
			GetPrivateProfileString(dName, "ai_width", "0", str, sizeof(str), f.c_str());
			d->dev.ai_width = atoi(str);
			GetPrivateProfileString(dName, "ao_width", "0", str, sizeof(str), f.c_str());
			d->dev.ao_width = atoi(str);

			if(d->dev.n_di != 0|| d->dev.n_ai != 0){
				d->dev.features |= IO_DEVICE_INPUT;
			}
			if(d->dev.n_do != 0|| d->dev.n_ao != 0){
				d->dev.features |= IO_DEVICE_OUTPUT;
			}
			
			
			d++;
		}
		dName += strlen(dName) + 1;
	}
	
	return;
}
Beispiel #2
0
	CAddDevice(
		PCNODE_KEY node,
		PCDEVICE_KEY key,
		PCVENDOR_KEY v,
		PCDEVTYPE_KEY t,
		const char * addr,
		const char * init_string, 
		__uint timeout
		)
	{
		RTK_ADDR dest;
		node_to_host(node, &dest.host);
		dest.port = PORT_ALL_SERVER;
		ok = false;
		__uint size;
		if(!init_string){
			init_string = "";
		}
		size = strlen(addr) + 1 + strlen(init_string) + 1 + sizeof(*v) + sizeof(*t) + sizeof(*key);
		void *buf;
		buf = alloc_buffer_v(
			key,
			sizeof(*key),
			v, 
			sizeof(*v), 
			t,
			sizeof(*t),
			addr,
			strlen(addr) + 1,
			init_string, 
			strlen(init_string)+1,
			0
			);
		if(!buf){
			return;
		}
		add_transaction(vbus_config, this);
		send_rtk_data_with_guid(
			vbus_config,
			&dest,
			&Guid,
			PT_AddDevice,
			buf,
			size);
		free_buffer(buf);
		Wait(timeout);
	}
    CDropTagsTransaction(__uint count, PCTAG_NAME names, __uint timeout)
    {
        void	*buf;
        left = count;

        buf = alloc_buffer_v(names, sizeof(names[0])*count, 0);
        if(!buf) {
            return;
        }
        add_transaction(vbus_config, this);
        broadcast_rtk_data_with_guid(
            vbus_config,
            PORT_ALL_SERVER,
            &Guid,
            PT_DropTag,
            buf,
            sizeof(names[0])*count
        );
        free_buffer(buf);
        Wait(timeout);
    }
	CAddEditGroupsTransaction(
		__uint count, 
		PCNODE_KEY nodes, 
		PCRTK_GROUP groups,
		__uint timeout, 
		__bool bEdit=false
		)
	{
		void	*buf;
		left = count;
		
		m_bEdit = bEdit;
		/*将nodes和groups中的字符串复制给buf
		buf中的存储的顺序为:[nodes..groups..]
		*/
		buf = alloc_buffer_v(                                //librtk.dll
			nodes, sizeof(nodes[0])*count, 
			groups, sizeof(groups[0])*count, 
			0
			);
		if(!buf){
			return;
		}
		add_transaction(vbus_config, this);//将vbus_config强转为CRtkVBus*, 然后把this插入链表tList中      list<CTransaction*>
		//客户端发出的数据报,当在pmc.exe中添加一个组程序将执行到这里
		broadcast_rtk_data_with_guid(
			vbus_config,                  //链表g_buses <VBUS_ID, CRtkVbus*>的一个键值对的值
			PORT_ALL_SERVER,               //用于赋给数据包头RTK_PACKET的成员dest.port
			&Guid,                        //链表s_lst  <RTK_GUID, RTK_LIST_ENTRY>的键,在类CTransaction的构造函数中创建
			bEdit? PT_EditGroup : PT_AddGroup,  //用于赋给数据包头RTK_PACKET的成员packet_type
			buf,                                //将要发送的数据包内容(除了数据包头,注意data[1])
			(sizeof(nodes[0]) + sizeof(groups[0]))*count  //将要发送的数据包内容的大小
			);
		free_buffer(buf);
		Wait(timeout);
	}