IoContext IoWorker::doMap() const
{
    const TraceSet &set = getTraceSet();
    TraceSet::Iterator iter = set.between(getBeginPos(), getEndPos());
    TraceSet::Iterator endIter = set.end();

    IoContext data;

    // Get event ids
    std::set<event_id_t> readEventIds {};
    for (const std::string &eventName : readSyscalls) {
        event_id_t id = getEventId(set, eventName);
        readEventIds.insert(id);
    }
    std::set<event_id_t> writeEventIds {};
    for (const std::string &eventName : writeSyscalls) {
        event_id_t id = getEventId(set, eventName);
        writeEventIds.insert(id);
    }
    std::set<event_id_t> readWriteEventIds {};
    for (const std::string &eventName : readWriteSyscalls) {
        event_id_t id = getEventId(set, eventName);
        readWriteEventIds.insert(id);
    }
    std::set<event_id_t> exitEventIds {};
    for (const std::string &eventName : exitSyscalls) {
        event_id_t id = getEventId(set, eventName);
        exitEventIds.insert(id);
    }

    // Iterate through events
    uint64_t count = 0;
    for ((void)iter; iter != endIter; ++iter) {
        count++;
        const auto &event = *iter;
        event_id_t id = event.getId();
        if (readEventIds.find(id) != readEventIds.end()) {
            data.handleSysRead(event);
        } else if (writeEventIds.find(id) != writeEventIds.end()) {
            data.handleSysWrite(event);
        } else if (readWriteEventIds.find(id) != readWriteEventIds.end()) {
            data.handleSysReadWrite(event);
        } else if (exitEventIds.find(id) != exitEventIds.end()) {
            data.handleExitSyscall(event);
        }
    }

    if (getVerbose()) {
        const timestamp_t *begin = getBeginPos();
        const timestamp_t *end = getEndPos();
        std::string beginString = begin ? std::to_string(*begin) : "START";
        std::string endString = end ? std::to_string(*end) : "END";
        std::cout << "Worker " << getId() << " processed " << count << " events between timestamps "
                  << beginString << " and " << endString << std::endl;
    }

    data.handleEnd();

    return data;
}
Example #2
0
WebViewEvent::WebViewEvent(const String &wvName, const String& _name, const std::vector<String>& _args)
 : InputEvent(InputDeviceWPtr(), IdPair(getEventId(), _name)),
   webview(wvName),
   name(_name),
   args(_args)
{
}
Example #3
0
uint StateMachine::addEvent( const string& name )
{
    o_assert(getEventId(name) == 0xffffffff, "An event with the same name already exists");
    uint id = m_EventNames.size();
    m_EventNames.push_back(name);
    m_EventIds[name] = id;
    return id;
}
Example #4
0
//------------------------------------------------------------------------------
// onMouseDown() - when the mouse is pressed
//------------------------------------------------------------------------------
bool SolenoidButton::onMouseDown()
{
    if (!noTimer) {
        // tell our switch to latch
        SolenoidSwitch* hs = (SolenoidSwitch*)findContainerByType(typeid(SolenoidSwitch));
        if (hs != nullptr) hs->latch(getEventId());
    }
    return true;
}
Example #5
0
void 
Event::serialize( SerializedInstance *addTo ) const {
  addTo->addSerializable( &getSendTime() );
  addTo->addSerializable( &getReceiveTime() );
  addTo->addUnsigned( getSender().getSimulationManagerID() );
  addTo->addUnsigned( getSender().getSimulationObjectID() );
  addTo->addUnsigned( getReceiver().getSimulationManagerID() );
  addTo->addUnsigned( getReceiver().getSimulationObjectID() );
  addTo->addUnsigned( getEventId().val );
}
Example #6
0
void EventTableWidget::handleCellPressedEvent(int row) {
	QString eventId = getEventId(row);

	if ( isRowSelected(row) && _controlKeyPressed ) {
		setSelectedRow(-1);
		clearSelection();
		emit eventDeselected(eventId);
	} else {
		setSelectedRow(row);
		emit eventSelected(eventId);
	}
}
Example #7
0
WebViewEvent::WebViewEvent(const String &wvName, const std::vector<DataReference<const char*> >& jsargs)
 : InputEvent(InputDeviceWPtr(), IdPair(getEventId(),
       jsargs.empty()?std::string():std::string(jsargs[0].data(), jsargs[0].length()))),
   webview(wvName)
{
    if (jsargs.size() >= 1) {
        name = std::string(jsargs[0].data(), jsargs[0].length());
        args.reserve(jsargs.size()-1);
        for (size_t i = 1; i < jsargs.size(); i++) {
            args.push_back(std::string(jsargs[i].data(), jsargs[i].length()));
        }
    }
}
Example #8
0
//------------------------------------------------------------------------------
// onSingleClick() - tells us we have been clicked, and we can override this
// to make it do whatever we want.
//------------------------------------------------------------------------------
bool Button::onSingleClick()
{
    // when I am clicked, I will send an event to my container, we find out what
    // event Id we have, and send that eventId
    bool ok = false;
    graphics::Display* myDisplay = (graphics::Display*)findContainerByType(typeid(graphics::Display));

    if (myDisplay != nullptr) {
        myDisplay->buttonEvent(getEventId());
        ok = true;
    }

    return ok;
}
Example #9
0
 InputDeviceEvent(Type type, const InputDevicePtr &dev)
     : Task::Event(IdPair(getEventId(), IdPair::Secondary::null())),
      mType(type), mDevice(dev) {
 }
Example #10
0
int MDSUdpEventAst(char *eventName, void (*astadr)(void *,int,char *), void *astprm, int *eventid)
{

    struct sockaddr_in serverAddr;
	char flag = 1;
	int intFlag = 1;
	int udpSocket;
	char ipAddress[64]; 
    struct ip_mreq ipMreq;
	struct EventInfo *currInfo;
	int error;

	initialize();

	if((udpSocket = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
	{
		perror("Error creating socket\n");
		return 0;
	}
	
	//    serverAddr.sin_len = sizeof(serverAddr);
    serverAddr.sin_family = AF_INET;
#ifdef HAVE_WXWORKS_H
    serverAddr.sin_len = (u_char)sizeof(struct sockaddr_in);
#endif
    serverAddr.sin_port = htons(getPort());
    serverAddr.sin_addr.s_addr = htonl(INADDR_ANY);

//Allow multiple connections
#ifdef HAVE_WINDOWS_H
   if(setsockopt(udpSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&flag, sizeof(char)) == SOCKET_ERROR)
#else
   if(setsockopt(udpSocket, SOL_SOCKET, SO_REUSEADDR, &intFlag, sizeof(int)) < 0)
#endif
	{   
		printf("Cannot set REUSEADDR option\n");
#ifdef HAVE_WINDOWS_H
		error = WSAGetLastError();
		switch(error)
		{
			case WSANOTINITIALISED: printf("WSAENETDOWN\n"); break;
			case WSAENETDOWN: printf("WSAENETDOWN\n"); break; 
			case WSAEADDRINUSE: printf("WSAEADDRINUSE\n"); break;
			case WSAEINTR : printf("WSAEINTR\n"); break;
			case WSAEINPROGRESS: printf("WSAEINPROGRESS\n"); break;
			case WSAEALREADY: printf("WSAEALREADY\n"); break;
			case WSAEADDRNOTAVAIL: printf("WSAEADDRNOTAVAIL\n"); break;
			case WSAEAFNOSUPPORT: printf("WSAEAFNOSUPPORT\n"); break;
			case WSAECONNREFUSED : printf("WSAECONNREFUSED\n"); break;
			case WSAEFAULT : printf("WSAEFAULT\n"); break;
			default: printf("BOH\n");
		}
#else
	perror("\n");
#endif
		return 0;
	}

#ifdef HAVE_WINDOWS_H
	if(bind(udpSocket, (SOCKADDR *)&serverAddr, sizeof(serverAddr)) != 0)
#else
	if(bind(udpSocket, (struct sockaddr *)&serverAddr, sizeof(struct sockaddr_in)) != 0)
#endif
	{   
		perror("Cannot bind socket\n");
		return 0;
	}

	getMulticastAddr(eventName, ipAddress);
	ipMreq.imr_multiaddr.s_addr = inet_addr(ipAddress);
        ipMreq.imr_interface.s_addr = INADDR_ANY;
	if(setsockopt(udpSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&ipMreq, sizeof(ipMreq)) < 0)
    {	
  	   	perror("Error setting socket options IP_ADD_MEMBERSHIPin udpStartReceiver\n");
#ifdef HAVE_WINDOWS_H
		error = WSAGetLastError();
		switch(error)
		{
			case WSANOTINITIALISED: printf("WSAENETDOWN\n"); break;
			case WSAENETDOWN: printf("WSAENETDOWN\n"); break; 
			case WSAEADDRINUSE: printf("WSAEADDRINUSE\n"); break;
			case WSAEINTR : printf("WSAEINTR\n"); break;
			case WSAEINPROGRESS: printf("WSAEINPROGRESS\n"); break;
			case WSAEALREADY: printf("WSAEALREADY\n"); break;
			case WSAEADDRNOTAVAIL: printf("WSAEADDRNOTAVAIL\n"); break;
			case WSAEAFNOSUPPORT: printf("WSAEAFNOSUPPORT\n"); break;
			case WSAECONNREFUSED : printf("WSAECONNREFUSED\n"); break;
			case WSAEFAULT : printf("WSAEFAULT\n"); break;
			default: printf("BOH\n");
		}
#endif
    }

	currInfo = (struct EventInfo *)malloc(sizeof(struct EventInfo));
	currInfo->eventName = malloc(strlen(eventName) + 1);
	strcpy(currInfo->eventName, eventName);
	currInfo->socket = udpSocket;
	currInfo->arg = astprm;
	currInfo->astadr = astadr;

	pthread_create(&currInfo->thread, 0, handleMessage, (void *)currInfo);
        pthread_detach(currInfo->thread);
	*eventid = getEventId((void *)currInfo);
	return 1;
}
Example #11
0
void EventTableWidget::handleCellDoubleClickEvent(int row) {
	QString eventId =  getEventId(row);

	emit eventSelected(eventId);
	emit eventDoubleClicked(eventId);
}
/**
 * trata evento de teclados (ASCII)
 */
void RobotWindow::keyboard(unsigned char key, int x, int y) {
	switch(key) {
	// evento de reset da câmera e das posições iniciais
	case 'R':
	case 'r':
		newEvent(EVENT_RESET, interval);
		break;
    // event to go to home posisiton, 6/6/13
    case 'H':
    case 'h':
//        newEvent(EVENT_RESET, interval);
// INSERT CODE HERE
        break;
// event to move as line/circular motion, 6/6/13
    case 'M':
    case 'm':
//        newEvent(EVENT_RESET, interval);
// INSERT CODE HERE
       break;
    // evento de afastamento da câmera
	case 'v':
	case 'V':
		cameraRadius += 0.5;
		setCameraPosition(cameraLongitude, cameraLatitude);
		break;
	// evento de aproximação da câmera
	case 'f':
	case 'F':
		if (cameraRadius >= MIN_CAM_RADIUS) {
			cameraRadius -= 0.5;
			setCameraPosition(cameraLongitude, cameraLatitude);
		}
		break;
	// rotação da base do braço do robô
	case 'z':
	case 'Z':
		if (!robot.isFlying())
			robot.armBase.rotate(1);
		break;
	case 'c':
	case 'C':
		if (!robot.isFlying())
			robot.armBase.rotate(-1);
		break;
    // rotate the base of the claw of robot
    // Added 6/6/13
    case ',':
    case '<':
        if (!robot.isFlying())
            robot.clawBase.rotate(1);
        break;
    case '.':
    case '>':
        if (!robot.isFlying())
            robot.clawBase.rotate(-1);
        break;
    // rotação do braço do robô
	case 'q':
	case 'Q':
		if (!robot.isFlying())
			robot.arm.rotate(1);
		break;
	case 'a':
	case 'A':
		if (!robot.isFlying())
			robot.arm.rotate(-1);
		break;
	// rotação da garra do robô (inclui toda a hélice e os dedos da garra)
	case 'e':
	case 'E':
		if (!robot.isFlying())
			robot.claw.rotate(1);
		break;
	case 'd':
	case 'D':
		if (!robot.isFlying())
			robot.claw.rotate(-1);
		break;
	// rotação dos dedos da garra
	case 'x':
	case 'X':
		robot.claw.finger.rotate(1);
		break;
	case 's':
	case 'S':
		robot.claw.finger.rotate(-1);
		break;
	// alterna estado do robô entre de voando, pousando sobre a base ou resgate
	case 't':
	case 'T':
		// se  o robô está voando
		if (robot.isFlying()) {
			// e já está tentando pousar
			if (getEventId(eventFlying) == EVENT_LANDING) {
				deleteEvent(eventFlying);
				// ativa o modo de resgate
				eventFlying = newEvent(EVENT_RESCUE, interval);
			} else {
				deleteEvent(eventFlying);
				// se está voando, ativa o modo de pouso
				eventFlying = newEvent(EVENT_LANDING, interval);
			}
		} else {
			// se não está voando, inicia o modo de "voando"
			robot.startFlying();
			deleteEvent(eventFlying);
			eventFlying = newEvent(EVENT_START_FLY, interval);
		}
		break;
	// faz uma animação de pouso do robô até sua posição inicial
	case 'y':
	case 'Y':
		if (robot.isFlying()) {
			if (getEventId(eventFlying) == EVENT_FLYING) {
				deleteEvent(eventFlying);
				eventFlying = newEvent(EVENT_SAFE_LANDING, interval);
			}
		}
		break;
	// sobe o robô, caso esteja flutuando (após as animações de início do voo)
	case 'g':
	case 'G':
		robot.moveUp();
		break;
	// desce o robô, caso esteja flutuando (após as animações de início do voo)
	case 'b':
	case 'B':
		robot.moveDown();
		break;
	// modifica o ângulo entre as garras (que formam a hélice)
	case 'i':
	case 'I':
		if (!robot.isFlying())
			robot.claw.rotateAngle(1);
		break;
	case 'k':
	case 'K':
		if (!robot.isFlying())
			robot.claw.rotateAngle(-1);
		break;
	// modifica o ângulo de cada garras (simulando o ângulo de ataque da hélice)
	case 'o':
	case 'O':
		if (!robot.isFlying())
			robot.claw.rotateAttack(0.25);
		break;
	case 'l':
	case 'L':
		if (!robot.isFlying())
			robot.claw.rotateAttack(-0.25);
		break;
	// liga/desliga o desenho da grade de limíte espacial do jogo
	case 'p':
	case 'P':
		drawCage = !drawCage;
		break;
	// modifica o ângulo de deslocamento (usado na rotação das hélices)
	case '+':
	case '=':
		robot.aceleratePropeller(1);
		break;
	case '-':
	case '_':
		robot.aceleratePropeller(-1);
		break;
	default:
		// se não for nenhuma das teclas de comando, retorna sem fazer nada
		return;

	}
	// agenda a renderização do próxim frame
	glutPostRedisplay();
}