Exemple #1
0
static void cpu_go_st_mem(event_t*e)
{    
    struct event_data_t *rd = event_data(event_ref(e,0));
    struct event_data_t *ed = event_data(e);
    
    ed->inst_node = rd->inst_node;
}
Exemple #2
0
void UDPAssetProvider::StoreAsset(UDPAssetTransfer& transfer)
{
    Foundation::ServiceManagerPtr service_manager = framework_->GetServiceManager();

    boost::shared_ptr<Foundation::AssetServiceInterface> asset_service =
        service_manager->GetService<Foundation::AssetServiceInterface>(Foundation::Service::ST_Asset).lock();
    if (asset_service)
    {
        const std::string& asset_id = transfer.GetAssetId();

        Foundation::AssetPtr new_asset = Foundation::AssetPtr(new RexAsset(asset_id, GetTypeNameFromAssetType(transfer.GetAssetType())));
        RexAsset::AssetDataVector& data = checked_static_cast<RexAsset*>(new_asset.get())->GetDataInternal();
        data.resize(transfer.GetReceived());
        transfer.AssembleData(&data[0]);

        asset_service->StoreAsset(new_asset);

        // Send asset ready event for each request tag
        Foundation::EventManagerPtr event_manager = framework_->GetEventManager();
        const RequestTagVector& tags = transfer.GetTags();
        for(uint i = 0; i < tags.size(); ++i)
        {
            Events::AssetReady event_data(new_asset->GetId(), new_asset->GetType(), new_asset, tags[i]);
            event_manager->SendEvent(event_category_, Events::ASSET_READY, &event_data);
        }
    }
    else
    {
        AssetModule::LogError("Asset service not found, could not store asset to cache");
    }
}
Exemple #3
0
void UDPAssetProvider::SendAssetProgress(UDPAssetTransfer& transfer)
{
    Foundation::EventManagerPtr event_manager = framework_->GetEventManager();
    Events::AssetProgress event_data(transfer.GetAssetId(), GetTypeNameFromAssetType(transfer.GetAssetType()),
                                     transfer.GetSize(), transfer.GetReceived(), transfer.GetReceivedContinuous());
    event_manager->SendEvent(event_category_, Events::ASSET_PROGRESS, &event_data);
}
 bool NetworkStateEventHandler::HandleNetworkStateEvent(event_id_t event_id, Foundation::EventDataInterface* data)
 {
     switch(event_id)
     {
         case ProtocolUtilities::Events::EVENT_SERVER_CONNECTED:
         {   
             // The client has connected to the server. Create a new scene for that.
             rexlogicmodule_->CreateNewActiveScene("World");
             // Send WorldStream as internal event
             event_category_id_t framework_category_id = framework_->GetEventManager()->QueryEventCategory("Framework");
             ProtocolUtilities::WorldStreamReadyEvent event_data(rexlogicmodule_->GetServerConnection());
             framework_->GetEventManager()->SendEvent(framework_category_id, Foundation::WORLD_STREAM_READY, &event_data);
             break;
         }
         case ProtocolUtilities::Events::EVENT_SERVER_DISCONNECTED:
         {
             // Might be user quitting or server dropping connection.
             // This event occurs when OpenSimProtocolModule has already closed connection. 
             // Make sure the rexlogic also thinks connection is closed.
             if (rexlogicmodule_->GetServerConnection()->IsConnected())
                 rexlogicmodule_->GetServerConnection()->ForceServerDisconnect();
             if (framework_->HasScene("World"))
                 rexlogicmodule_->DeleteScene("World");
             break;
         }
         default:
             break;
     }
     
     return false;
 }
Exemple #5
0
	static int LuaOnSignal(lua_State *pState, CYDWEEventData &eventData, bool ignore_error, luabind::object const& func)
	{
		lua_stack_guard tmp_guard(pState);

		TranslateEventDataToLuaTable(pState, eventData);
		luabind::object event_data(luabind::from_stack(pState, -1));

		if (ignore_error) 
		{
			try {
				return luabind::call_function<int>(func, event_data);
			}
			catch (...) {
			}
		}
		else
		{
			try {
				return luabind::call_function<int>(func, event_data);
			}
			catch (luabind::error const& e) {
				LOGGING_ERROR(lg) << "exception: \"" << e.what() << "\" " << lua_tostring(e.state(), -1);
			}
			catch (std::exception const& e) {
				LOGGING_ERROR(lg) << "exception: \"" << e.what() << "\"";
			}
			catch (...) {
				LOGGING_ERROR(lg) << "unknown exception";
			}
		}

		return -1;
	}
    void ProtocolModuleTaiga::RegisterNetworkEvents()
    {
        const char *filename = "./data/message_template.msg";

        networkManager_ = boost::shared_ptr<ProtocolUtilities::NetMessageManager>(new ProtocolUtilities::NetMessageManager(filename));
        assert(networkManager_);
        networkManager_->RegisterNetworkListener(this);

        // Register event categories.
        eventManager_ = framework_->GetEventManager();
        networkStateEventCategory_ = eventManager_->RegisterEventCategory("NetworkState");
        networkEventInCategory_ = eventManager_->RegisterEventCategory("NetworkIn");
        networkEventOutCategory_ = eventManager_->RegisterEventCategory("NetworkOut");

        // Send event that other modules can query above categories
        boost::weak_ptr<ProtocolUtilities::ProtocolModuleInterface> modulePointerToThis = 
            framework_->GetModuleManager()->GetModule<ProtocolModuleTaiga>(Foundation::Module::MT_TaigaProtocol);
        if (modulePointerToThis.lock().get())
        {
            event_category_id_t framework_category_id = eventManager_->QueryEventCategory("Framework");
            ProtocolUtilities::NetworkingRegisteredEvent event_data(modulePointerToThis);
            eventManager_->SendEvent(framework_category_id, Foundation::NETWORKING_REGISTERED, &event_data);
            LogInfo("Sending Networking Registered event");
        }
        LogInfo("Network events [NetworkState, NetworkIn, NetworkOut] registered");
    }
Exemple #7
0
void parse_events(uint8_t *buf, int len, list<event_data> &events)
{
    struct section *section;
    struct section_ext *section_ext = NULL;

    if ((section = section_codec(buf, len)) == NULL) {
        return;
    }

    switch(section->table_id) {

    case stag_dvb_event_information_nownext_actual:
    case stag_dvb_event_information_nownext_other:
    case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57:
    case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f:
    case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67:
    case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f:
    {

        struct dvb_eit_section *eit;
        struct dvb_eit_event *cur_event;
        struct descriptor *curd;
        time_t start_time;

        if ((section_ext = section_ext_decode(section, 1)) == NULL) {
            return;
        }

        if ((eit = dvb_eit_section_codec(section_ext)) == NULL) {
            return;
        }

        dvb_eit_section_events_for_each(eit, cur_event) {

            event_data E = event_data();


            start_time = dvbdate_to_unixtime(cur_event->start_time);

            E.set_service_id(dvb_eit_section_service_id(eit));
            E.set_event_id(cur_event->event_id);
            E.set_duration(dvbduration_to_seconds(cur_event->duration));
            E.set_running_status(cur_event->running_status);
            E.set_start_time((int) start_time);

            dvb_eit_event_descriptors_for_each(cur_event, curd) {
                parse_event_descriptor(curd,  E);
            }

            AddIntoEventList(events, E);

        }
        break;
    }
Exemple #8
0
    // virtual
    bool OgreRenderingModule::HandleEvent(event_category_id_t category_id, event_id_t event_id, Foundation::EventDataInterface* data)
    {
        PROFILE(OgreRenderingModule_HandleEvent);
        if (!renderer_)
            return false;

        if (category_id == asset_event_category_)
        {
            return renderer_->GetResourceHandler()->HandleAssetEvent(event_id, data);
        }

        if (category_id == resource_event_category_)
        {
            return renderer_->GetResourceHandler()->HandleResourceEvent(event_id, data);
        }

        if (category_id == input_event_category_ && event_id == Input::Events::INWORLD_CLICK)
        {
            // do raycast into the world when user clicks mouse button
            Input::Events::Movement *movement = checked_static_cast<Input::Events::Movement*>(data);
            assert(movement);
            Foundation::RaycastResult result = renderer_->Raycast(movement->x_.abs_, movement->y_.abs_);

            Scene::Entity *entity = result.entity_;
            if (entity)
            {
                Scene::Events::RaycastEventData event_data(entity->GetId());
                event_data.pos = result.pos_, event_data.submesh = result.submesh_, event_data.u = result.u_, event_data.v = result.v_; 
                framework_->GetEventManager()->SendEvent(scene_event_category_, Scene::Events::EVENT_ENTITY_GRAB, &event_data);

                //Semantically same as above but sends the entity pointer
                Scene::Events::EntityClickedData clicked_event_data(entity);
                framework_->GetEventManager()->SendEvent(scene_event_category_, Scene::Events::EVENT_ENTITY_CLICKED, &clicked_event_data);
            }
            else
                framework_->GetEventManager()->SendEvent(scene_event_category_, Scene::Events::EVENT_ENTITY_NONE_CLICKED, 0);
        }

        if (network_state_event_category_)
        {
            if (event_id == ProtocolUtilities::Events::EVENT_USER_DISCONNECTED)
                renderer_->ResetImageRendering();
            return false;
        }

        return false;
    }
Exemple #9
0
	void RtpSender::Close()
	{
		MS_TRACE();

		static const Json::StaticString k_class("class");

		Json::Value event_data(Json::objectValue);

		// Notify.
		event_data[k_class] = "RtpSender";
		this->notifier->Emit(this->rtpSenderId, "close", event_data);

		// Notify the listener.
		this->listener->onRtpSenderClosed(this);

		delete this;
	}
Exemple #10
0
/*
 *   go phase of instruction
 *  
 */
static void cpu_go_inst(event_t*e)
{
    hwe_cont *hwe = event_content(e);
    struct event_data_t *ed = event_data(e);
    struct comp_data_t  *cd = comp_data(event_component(e));
    int i = 0;

    if (hwe->inst.body.exec){
        for(i = 0, ed->regs.nreg = hwe->inst.body.nregs; i < hwe->inst.body.nregs; i++){
            ed->regs.id[i] = hwe->inst.reg_id[i];
            ed->regs.data[i] = hwe->inst.reg_data[i];
            // Alternativelly call cpu_exec to avoid so many "for"s
            // Call plugin also when it is configured to this granularity 
        }
        // Update PC
        ed->regs.nreg++;
        ed->regs.id[i] = 15;
        if(hwe->inst.body.jump){
            ed->regs.data[i] = hwe->inst.jump_pc;
        }else {
            ed->regs.data[i] = hwe->inst.body.pc + 4; 
        }
        if(hwe->inst.body.dmem){
           // Next steps and wait for other events 
        }
    }else { // Not executed instruction (update PC)
        ed->regs.nreg = 1;
        ed->regs.id[0] = 15;
        ed->regs.data[0] = hwe->inst.body.pc + 4;
    }

    // TODO: Put those function inside 
    cpu_exec(cd->comp.cpu, &ed->regs);

    pg_exec_cpu(cd->comp.cpu, &ed->regs);

    // This pointer will be used by other instructions
    e->data.inst_node = oracle_get_last_exec();
    
    //  printf("[%d.%d] GO\n", (uint32_t)e->hwe->common.id.devid, (uint32_t)e->hwe->common.id.index);

    // Dump registers
    // dump_regs(cd, e->hwe->inst.body.pc);
}
Exemple #11
0
void
ios_base::register_callback(event_callback fn, int index)
{
    if (cb_siz_ >= cb_cap_)
    {
        size_t new_cap = cb_cap_;
        if (new_cap == 0)
            new_cap = 1;
        else
            new_cap *= 2;
        event_data* newevents = static_cast<event_data*>(realloc(cb_vec_, new_cap*sizeof(event_data)));
        if (newevents == 0)
        {
            setstate(badbit);
            return;
        }
        cb_vec_ = newevents;
        cb_cap_ = new_cap;
    }
    cb_vec_[cb_siz_++] = event_data(fn, index);
}
Exemple #12
0
void *client_thr(void *arg) {
    Util_AA<char>   event_data(MS_MON_MAX_SYNC_DATA);
    int             event_len;
    int             ferr;
    int             inx;
    int             msgid;
    Util_AA<char>   recv_buffer(BUFSIZ);
    Util_AA<short>  recv_buffer3(BUFSIZ);
    RT              results;
    Util_AA<char>   send_buffer(BUFSIZ);
    Util_AA<short>  send_buffer2(BUFSIZ);
    int             send_len;
    long            t_elapsed;
    struct timeval  t_start;
    struct timeval  t_stop;
    int             whoami = inxc++;

    arg = arg; // touch
    if (event) {
        ferr = msg_mon_event_wait(1, &event_len, &event_data);
        TEST_CHK_FEOK(ferr);
    }
    util_time_timer_start(&t_start);
    for (inx = 0; inx < loop; inx++) {
        if (txrate) {
            if ((inx % 100) == 0) {
                util_time_timer_stop(&t_stop);
                t_elapsed = (t_stop.tv_sec * 1000000 + t_stop.tv_usec) -
                            (t_start.tv_sec * 1000000 + t_start.tv_usec);
                t_elapsed = t_elapsed / 1000;
                if (inx == 0)
                    printf("%s: c-%d\n", name, whoami);
                else
                    printf("%s: c-%d, inx=%d, msg/ms=%ld\n",
                           name, whoami, inx, t_elapsed / inx);
            }
        } else if (mq) {
            if ((inx % 100) == 0)
                printf("%s: c-%d, inx=%d\n", name, whoami, inx);
        } else if (!quiet)
            printf("c-%d, inx=%d\n", whoami, inx);
        fflush(stdout);
        sprintf(&send_buffer, "hello, greetings from %s-%d, inx=%d",
                my_name, whoami, inx);
        send_len = (int) strlen(&send_buffer) + 1;
        if (verbose)
            printf("c-%d: sending %s\n", whoami, &send_buffer);
        ferr = XMSG_LINK_(TPT_REF(phandle),                     // phandle
                          &msgid,                      // msgid
                          &send_buffer2,               // reqctrl
                          (ushort) (inx & 1),          // reqctrlsize
                          &recv_buffer3,               // replyctrl
                          (ushort) 1,                  // replyctrlmax
                          &send_buffer,                // reqdata
                          (ushort) send_len,           // reqdatasize
                          &recv_buffer,                // replydata
                          (ushort) BUFSIZ,             // replydatamax
                          0,                           // linkertag
                          0,                           // pri
                          0,                           // xmitclass
                          0);                          // linkopts
        if (!abortserver)
            util_check("XMSG_LINK_", ferr);
        ferr = XMSG_BREAK_(msgid, results.u.s, TPT_REF(phandle));
        if (!abortserver)
            util_check("XMSG_BREAK_", ferr);
        if (!abortserver) {
            if (verbose)
                printf("c-%d: received %s\n", whoami, &recv_buffer);
            assert(results.u.t.ctrl_size == (uint) (inx & 1));
            assert(results.u.t.data_size == 100);
            assert(results.u.t.errm == RT_DATA_RCVD); // data
            if (inx == (loop - 1)) {
                if (maxcp > 1)
                    printf("%s: %s\n", name, &recv_buffer);
                else
                    printf("%s\n", &recv_buffer);
            }
        }
    }
    return NULL;
}
Exemple #13
0
void UDPAssetProvider::SendAssetCanceled(UDPAssetTransfer& transfer)
{
    Foundation::EventManagerPtr event_manager = framework_->GetEventManager();
    Events::AssetCanceled event_data(transfer.GetAssetId(), GetTypeNameFromAssetType(transfer.GetAssetType()));
    event_manager->SendEvent(event_category_, Events::ASSET_CANCELED, &event_data);
}
void log_event(int a, int b, const char *c, const char *d)
  {
  if(check_event) event_data(d);
  }