Example #1
0
void BattlegroundRV::StartingEventOpenDoors()
{
    // Buff respawn
    SpawnBGObject(BG_RV_OBJECT_BUFF_1, 90);
    SpawnBGObject(BG_RV_OBJECT_BUFF_2, 90);
    // Elevators
    DoorOpen(BG_RV_OBJECT_ELEVATOR_1);
    DoorOpen(BG_RV_OBJECT_ELEVATOR_2);

    setState(BG_RV_STATE_OPEN_FENCES);
    setTimer(BG_RV_FIRST_TIMER);
}
Example #2
0
int main(void)
{
	uint8_t src_packet[128] = {0x05, 0x30, 0x00, 0x00, 0x0A};
	
	uint8_t rcvd_msg[128] = {0};
	uint8_t rcvd_payload[128] = {0};
	uint8_t rcvd_length;
	uint8_t rcvd_payloadLength;
	uint8_t rcvd_rssi;
	
	uint8_t Type;
	uint16_t Addr;
	uint8_t radio_channel;
	uint16_t radio_panID;
	
	Type = Type_Light;
	Addr = 0x0001;
	radio_channel = 18;
	radio_panID = 0x00AA;
	
	Initial(Addr, Type, radio_channel, radio_panID);
	setTimer(1,RETRANSMIT_PERIOD,UNIT_MS);
	
	while(1){
		
		// Periodically send the msg
		if(checkTimer(1)){
			RF_Tx(0xFFFF,src_packet,5);
		}
		
		// When received some packet
		if(RF_Rx(rcvd_msg, &rcvd_length, &rcvd_rssi)){
			getPayloadLength(&rcvd_payloadLength, rcvd_msg);
			getPayload(rcvd_payload, rcvd_msg, rcvd_payloadLength);
			
			// Check 1)header, 2)sequence number, 3)isACK field
			if(rcvd_payload[0]==0x05 && rcvd_payload[1]==0x30 && 
				 rcvd_payload[2]==src_packet[2] && rcvd_payload[3]==1){
				src_packet[2]++;
				// Change the payload here
			}
		}
		
		if(src_packet[2]==0x14)
			break;
	}
	
	while(1){
		if(checkTimer(1)){
			setGPIO(1,1);
		}	
	}
}
EXTERN_C gboolean sa_Sensor_mark_start(sa_Sensor_mark* self, GError** error)
{
  if (!sa_Sensor_mark_is_active(self)) {
    //logt("START MARK");
    if (!log_db_log_mark(self->log, "start", error)) // begin mark
      return FALSE;

    if (!setTimer(self, error))
      return FALSE;
  }
  return TRUE;
}
Example #4
0
  // ----------------------------------------------------------------------
  void
  EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target,
                                                     unsigned int eventType,
                                                     unsigned int flags,
                                                     unsigned int key,
                                                     unsigned int flavor,
                                                     UInt64 guid,
                                                     bool repeat,
                                                     AbsoluteTime ts,
                                                     OSObject* sender,
                                                     void* refcon)
  {
    IOLockWrapper::ScopedLock lk_eventlock(CommonData::getEventLock());
    if (! lk_eventlock) return;
    IOLockWrapper::ScopedLock lk(timer_.getlock());
    if (! lk) return;

    // ------------------------------------------------------------
    Params_KeyboardSpecialEventCallback::auto_ptr ptr(Params_KeyboardSpecialEventCallback::alloc(EventType(eventType), Flags(flags), ConsumerKeyCode(key),
                                                                                                 flavor, guid, repeat));
    if (! ptr) return;
    Params_KeyboardSpecialEventCallback& params = *ptr;

    // ------------------------------------------------------------
    DeviceVendor deviceVendor(0);
    DeviceProduct deviceProduct(0);
    {
      IOLockWrapper::ScopedLock lk_device(ListHookedKeyboard::instance().getListLock());
      if (! lk_device) return;

      IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender);
      if (! device) return;

      ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get_nolock(device));

      // ------------------------------------------------------------
      CommonData::setcurrent_ts(ts);
      deviceVendor = item->getVendor();
      deviceProduct = item->getProduct();
    }

    // ------------------------------------------------------------
    // Because we handle the key repeat ourself, drop the key repeat by hardware.
    if (repeat) return;

    // ------------------------------------------------------------
    bool retainFlagStatusTemporaryCount = false;
    bool updateWorkspaceData = params.ex_iskeydown;
    enqueue_(params, retainFlagStatusTemporaryCount, updateWorkspaceData, deviceVendor, deviceProduct);

    setTimer();
  }
Example #5
0
// ----------------------------------------------------------------------
void EventInputQueue::push_KeyboardSpecialEventCallback(OSObject* target,
                                                        unsigned int eventType,
                                                        unsigned int flags,
                                                        unsigned int key,
                                                        unsigned int flavor,
                                                        UInt64 guid,
                                                        bool repeat,
                                                        AbsoluteTime ts,
                                                        OSObject* sender,
                                                        void* refcon) {
  GlobalLock::ScopedLock lk;
  if (!lk) return;

  Params_KeyboardSpecialEventCallback::log(true, EventType(eventType), Flags(flags), ConsumerKeyCode(key), flavor, guid, repeat);

  // ------------------------------------------------------------
  Params_KeyboardSpecialEventCallback params(EventType(eventType),
                                             Flags(flags),
                                             ConsumerKeyCode(key),
                                             flavor, guid, repeat);

  // ------------------------------------------------------------
  IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender);
  if (!device) return;

  ListHookedConsumer::Item* item = static_cast<ListHookedConsumer::Item*>(ListHookedConsumer::instance().get(device));
  if (!item) return;

  // ------------------------------------------------------------
  // Device Hacks

  // Drop events if "Disable an internal keyboard while external keyboards are connected" is enabled.
  if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_internal_keyboard_if_external_keyboard_exsits)) {
    if (item->isInternalDevice() &&
        ListHookedKeyboard::instance().isExternalDevicesConnected()) {
      return;
    }
  }

  // ------------------------------------------------------------
  CommonData::setcurrent_ts(ts);

  // ------------------------------------------------------------
  // Because we handle the key repeat ourself, drop the key repeat by hardware.
  if (repeat) return;

  // ------------------------------------------------------------
  bool retainFlagStatusTemporaryCount = false;
  enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier());

  setTimer();
}
int    broadcast_fc8300_drv_if_set_channel(struct broadcast_dmb_set_ch_info *udata)
{
    signed long frequency = 214714; /*tmm*/
    int ret;
#ifndef BBM_I2C_TSIF
    fci_irq_disable();
#endif
    setTimer();

    if(OnAir == 0 || udata == NULL) {
        print_log(NULL, "[1seg] broadcast_drv_if_set_channel error [!OnAir]\n");
        return ERROR;
    }

    /* uhf 1segment */
    currentSelectedChannel = udata->channel;

    if(udata->segment == 13) {
        currentBroadCast = UHF_13SEG;
    } else {
        currentBroadCast = UHF_1SEG;
    }
    #ifdef CONFIG_LGE_BROADCAST_BRAZIL_FREQ
    if(udata->channel<14 || udata->channel>69) {
        print_log(NULL, "[1seg] channel information error\n");
        return ERROR;
    }
    frequency = frequencyTable[udata->channel-14];
    #else
    if(udata->channel<13 || udata->channel>62) {
        print_log(NULL, "[1seg] channel information error\n");
        return ERROR;
    }
    frequency = frequencyTable[udata->channel-13];
    #endif

    /* Scan mode(udata->mode==1) & need lock check */

#ifndef BBM_I2C_TSIF
    fci_irq_enable();
#endif
    ret = tunerbb_drv_fc8300_set_channel(frequency, udata->mode, udata->subchannel);

    //broadcast_fci_ringbuffer_flush();

    if(ret)
        return ERROR;

    print_log(NULL, "[fc8300] channel channel : %d, %d, %d, scan OK\n", udata->channel, udata->mode, udata->subchannel);

    return OK;
}
Example #7
0
static int renewIP()
{
	setTimer(0);	/* 取消定时器 */
	printf(_(">> 正在获取IP...\n"));
	system(dhcpScript);
	printf(_(">> 操作结束。\n"));
	dhcpMode += 3; /* 标记为已获取,123变为456,5不需再认证*/
	if (fillHeader() == -1)
		exit(EXIT_FAILURE);
	if (dhcpMode == 5)
		return switchState(ID_ECHO);
	return switchState(ID_START);
}
Example #8
0
Clock::Clock(QWidget* parent)
: QWidget(parent), m_timer(0) {
	setTimer(Tanglet);
	setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	m_update = new QTimer(this);
	m_update->setInterval(1000);
	connect(m_update, SIGNAL(timeout()), this, SLOT(updateTime()));

	QFont f = font();
	f.setBold(true);
	setFont(f);
}
Example #9
0
void LatencyTest::BeginTest()
{
     if (State == State_WaitingForButton)
    {
        // Set color to black and wait a while.
        RenderColor = CALIBRATE_BLACK;

        State = State_WaitingForSettlePreCalibrationColorBlack;
        OVR_DEBUG_LOG(("State_WaitingForButton -> State_WaitingForSettlePreCalibrationColorBlack."));

        setTimer(TIME_TO_WAIT_FOR_SETTLE_PRE_CALIBRATION);
    }
}
Example #10
0
void setKeyListener(char key, ObjectHeader* obj, char cmd) {
    static char initialized;
    if(!initialized) {
        initialized = 1;
        setTimer(&keysObj, _MSG_KEYBOARD_TIMER, TIMER_PERIODIC, _MSG_KEYBOARD_TIMER_PERIOD);
    }

    if(key >= MAX_KEYS)
        return;

    keys[key].obj = obj;
    keys[key].cmd = cmd;
}
Example #11
0
File: spi.cpp Project: UIKit0/pixy
int spi_sync()
{
	uint32_t timer;

	setTimer(&timer);
	while(1)
	{
		if(spi_checkIdle())
			return 1;
		if (getTimer(timer)>500000) // timeout .5 seconds
			return 0;
	}	
}
Example #12
0
void EventInputQueue::push_ScrollWheelEventCallback(OSObject* target,
                                                    short deltaAxis1,
                                                    short deltaAxis2,
                                                    short deltaAxis3,
                                                    IOFixed fixedDelta1,
                                                    IOFixed fixedDelta2,
                                                    IOFixed fixedDelta3,
                                                    SInt32 pointDelta1,
                                                    SInt32 pointDelta2,
                                                    SInt32 pointDelta3,
                                                    SInt32 options,
                                                    AbsoluteTime ts,
                                                    OSObject* sender,
                                                    void* refcon) {
  GlobalLock::ScopedLock lk;
  if (!lk) return;

  Params_ScrollWheelEventCallback::log(true,
                                       deltaAxis1,
                                       deltaAxis2,
                                       deltaAxis3,
                                       fixedDelta1,
                                       fixedDelta2,
                                       fixedDelta3,
                                       pointDelta1,
                                       pointDelta2,
                                       pointDelta3,
                                       options);

  // ------------------------------------------------------------
  Params_ScrollWheelEventCallback params(deltaAxis1, deltaAxis2, deltaAxis3,
                                         fixedDelta1, fixedDelta2, fixedDelta3,
                                         pointDelta1, pointDelta2, pointDelta3,
                                         options);

  // ------------------------------------------------------------
  IOHIPointing* device = OSDynamicCast(IOHIPointing, sender);
  if (!device) return;

  ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get(device));
  if (!item) return;

  // ------------------------------------------------------------
  CommonData::setcurrent_ts(ts);

  // ------------------------------------------------------------
  bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event);
  enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier());

  setTimer();
}
Example #13
0
/* ****************************************************************************
*
* utInit - unit test init
*
*/
void utInit(void)
{
#ifdef UT_DEBUG
  ++noOfInits;
  printf("**************** IN utInit (%d inits, %d exits)\n", noOfInits, noOfExits);
#endif

  notifierMock = new NotifierMock();
  if (notifierMock == NULL)
  {
    fprintf(stderr, "error allocating NotifierMock: %s\n", strerror(errno));
    exit(1);
  }
  setNotifier(notifierMock);
  
  timerMock = new TimerMock();
  if (timerMock == NULL)
  {
    fprintf(stderr, "error allocating TimerMock: %s\n", strerror(errno));
    exit(1);
  }
  ON_CALL(*timerMock, getCurrentTime()).WillByDefault(Return(1360232700));
  setTimer(timerMock);

  startTime       = getCurrentTime();
  statisticsTime  = getCurrentTime();

  setupDatabase();

#ifdef UT_DEBUG
  printf("**************** FROM utInit (%d inits, %d exits)\n", noOfInits, noOfExits);
#endif

  //
  // URI parameters used for unit testing
  //   Default mime type for notifications: application/xml
  //
  uriParams[URI_PARAM_NOTIFY_FORMAT]       = "XML";
  uriParams[URI_PARAM_PAGINATION_OFFSET]   = DEFAULT_PAGINATION_OFFSET;
  uriParams[URI_PARAM_PAGINATION_LIMIT]    = DEFAULT_PAGINATION_LIMIT;
  uriParams[URI_PARAM_PAGINATION_DETAILS]  = DEFAULT_PAGINATION_DETAILS;
  uriParams[URI_PARAM_NOT_EXIST]           = ""; // FIXME P7: we need this to implement "restriction-based" filters

  //
  // Resetting servicePathVector
  //
  servicePathVector.clear();

  // Init subs cache (this initialization is overriden in test that use csubs)
  mongoSubCacheInit();
}
Example #14
0
// ATTACK FUNCTIONS =============================================================================== //
void atkTackle(avatar *agent, int targetX, int targetY)
{
	float angle;
	float trigX, trigY;

	angle = atan((targetY - agent->coordY)/(targetX - agent->coordX)) * (-1);

	trigX = cos(angle);
	trigY = sin(angle);

	if(targetX > agent->coordX){
		if(trigX < 0)
			trigX *= (-1);
	} else if(targetX < agent->coordX){
		if(trigX > 0)
			trigX *= (-1);
	}
	if(targetY > agent->coordY){
		if(trigY < 0)
			trigY *= (-1);
	} else if(targetY < agent->coordY){
		if(trigY > 0)
			trigY *= (-1);
	}

	agent->acX = 0;
	agent->acY = 0;

	phAddAc(&agent->acX, TACKLE_SPEED*trigX, 1, agent->weight, 1, TACKLE_SPEED);
	phAddAc(&agent->acY, TACKLE_SPEED*trigY, 1, agent->weight, 1, TACKLE_SPEED);

	setTimer(&agent->timeFlame.time, agent->delay[ATCK_MELEE]);
	setTimer(&agent->cantouch.time, agent->delay[ATCK_MELEE]);

	agent->timeElement.time = agent->delay[ATCK_MELEE];

	return;
}
Example #15
0
    void App::setTimer()
    {
        gtkTimer.expires_from_now(boost::posix_time::milliseconds(1));

        gtkTimer.async_wait([&](const boost::system::error_code &ec)
        {
            if (ec) return;

            while (gtkMain.events_pending())
                gtkMain.iteration(false);

            setTimer();
        });
    }
Example #16
0
	Mtorz() {
		setBackground(osapal[8]);
		setBounds(200, 64, 14 * 8 + 12, 4 * 16 + 28);
		setTitle("M t . o r z 0");
		label1 = new Label(
			"   orz\n"
			"  orz orz\n"
			" orz orz orz\n"
			"orz orz orz orz");
		label1->setBounds(20, 8, 12 * 8, 3 * 16);
		label1->setBackground(osapal[8]);
		add(label1);
		setTimer(500);
	}
Example #17
0
File: Utils.c Project: zhshr/CS502
void my_Timer_Interrupt() {
	/*TODO:
	 * Get current time T
	 * Move everything with waketime before T from TimerQueue to ReadyQueue
	 * Get next item in TimerQueue
	 * Reset Timer
	 */
	PrintState();
	ReadyQueue_Lock("Timer Interrupt");
	TimerQueue_Lock("Timer Interrupt");

	currentTimer = 0;
	INT32 time = 0;
	time = my_GET_TIME_OF_DAY();
	debug(GREY, "Timer Queue, Current Time: %d", time);
	debug(YELLOW, "Timer Queue Lock in interrupt");

	if (!TimerQueueHead->Next) {
		debug(RED, "Bug in Timer Queue\n");
	} else {
		INT32 currentTime = my_GET_TIME_OF_DAY();
		if (TimerQueueHead->Next != NULL) {
			debug(GREY, "Timer Queue Item: %d, waketime %d",
					TimerQueueHead->Next->PCB->PID,
					TimerQueueHead->Next->WakeTime);
		} else {
			debug(RED, "Timer Item is NULL");
		}

		while (TimerQueueHead->Next != NULL
				&& TimerQueueHead->Next->WakeTime < currentTime) {
			//move it to the ready Q
			TimerQueueItem * temp = TimerQueue_Pop();
			debug(GREEN, "Move PID %d from Timer Q to Ready Q", temp->PCB->PID);
			if (temp != NULL) {
				ReadyQueue_Add(temp->PCB);
				Printer("Ready", temp->PCB->PID, FALSE);
			}
		}
	}
	if (TimerQueueHead->Next != NULL) {
		//reset Timer
		currentTimer = TimerQueueHead->Next->WakeTime;
		setTimer(TimerQueueHead->Next->WakeTime - time);
		debug(YELLOW, "reset timer to %d", currentTimer,
				TimerQueueHead->Next->WakeTime - time);
	}
	TimerQueue_Unlock("Timer Interrupt");
	ReadyQueue_Unlock("Timer Interrupt");
}
Example #18
0
void vitalDemage(circle *vital, avatar *enemy)
{
    float distance;

    distance = sqrt(pow((vital->coordX - enemy->coordX),2) + pow((vital->coordY - enemy->coordY),2));

    if((distance < vital->radius + enemy->radius)&&(vital->timeDemage.flag))
    {
        vital->life-=10;
        if(vital->life <= 0)
            vital->life = 0;
        setTimer(&vital->timeDemage.time, 100);
    }
}
Example #19
0
void GridFrame::update() {
    float tmp = (float)15/19;

    currentTetrimono->fall(25);
    repaint();
    if(!hasLost)
        setTimer(1000*tmp/(currentGame->getLevel() + tmp));
    else
        setTimer(75);
    if (currentTetrimono->isOnFloor()) {
        if (currentTetrimono->getUpperBound() <= 0) {
            hasLost = true;
            return;
        }
        currentGame->scoreManage();
        delete currentTetrimono; // on désaloue la mémoire  du tétrimono sur le sol
        currentTetrimono = new Tetrimono(nextTetrimonoNumber, grid);
        int i = rand() % 7;
        nextTetrimonoNumber = i;
        emit updateNextBlock(i);
    }
    QWidget::update();
}
Example #20
0
uint8_t eeprom_write_byte(uint8_t *index, uint8_t val) {
  if (((uint32_t)index) >= sizeof(flash_backing))
    return 1;

  if (flash_state == STATE_EMPTY)
    memcpy(flash_backing, (const void *)&flash_area, sizeof(flash_backing));

  flash_backing[(uint32_t)index] = val;
  flash_state = STATE_DIRTY;

  setTimer(&my_timer, MS2ST(30), eeprom_flush, NULL);

  return 0;
}
void CSrvMsgHandler::onLoad(const char* srvName, const unsigned int srvId, unsigned short moduleId)
{
	if (!GatewayProxyConfig::config::getConfigValue(CCfg::getValue("GatewayProxyService", "BusinessXmlConfigFile")).isSetConfigValueSuccess())
	{
		ReleaseErrorLog("set business xml config value error");
		stopService();
		return;
	}
	
    const DBConfig::config& dbCfg = DBConfig::config::getConfigValue(CCfg::getValue("GatewayProxyService", "DbConfigFile"));
	if (!dbCfg.isSetConfigValueSuccess())
	{
		ReleaseErrorLog("set db xml config value error");
		stopService();
		return;
	}

	if (!m_redisDbOpt.connectSvr(dbCfg.redis_db_cfg.center_db_ip.c_str(), dbCfg.redis_db_cfg.center_db_port,
	    dbCfg.redis_db_cfg.center_db_timeout * MillisecondUnit))
	{
		ReleaseErrorLog("gateway connect center redis service failed, ip = %s, port = %u, time out = %u",
		dbCfg.redis_db_cfg.center_db_ip.c_str(), dbCfg.redis_db_cfg.center_db_port, dbCfg.redis_db_cfg.center_db_timeout);
		
		stopService();
		return;
	}
	
	static const unsigned int gatewayProxySrvId = getSrvId();
	m_gatewayProxySrvData.ip = CSocket::toIPInt(CCfg::getValue("NetConnect", "NetIP"));  // 外网IP
	m_gatewayProxySrvData.port = atoi(CCfg::getValue("NetConnect", "Port"));
	m_gatewayProxySrvData.curTimeSecs = time(NULL);
	m_gatewayProxySrvData.currentPersons = 0;
	int rc = m_redisDbOpt.setHField(GatewayProxyListKey, GatewayProxyListKeyLen,
	                                (const char*)&gatewayProxySrvId, sizeof(gatewayProxySrvId), (const char*)&m_gatewayProxySrvData, sizeof(m_gatewayProxySrvData));
	if (rc != 0)
	{
		ReleaseErrorLog("set gateway proxy service data to redis center service failed, rc = %d", rc);
		stopService();
		return;
	}
	
	m_gameHallId = GatewayProxyConfig::config::getConfigValue().commonCfg.game_hall_id;
	
	// 定时保存数据到redis
	unsigned int millisecondUnit = 1000; // 秒转换为毫秒乘值
	unsigned int timerId = setTimer(millisecondUnit * atoi(CCfg::getValue("GatewayProxyService", "SaveDataToDBInterval")),
	                                (TimerHandler)&CSrvMsgHandler::saveDataToDb, 0, NULL, (unsigned int)-1);

    ReleaseInfoLog("gateway message handler load, service name = %s, id = %d, timer id = %u", srvName, srvId, timerId);
}
Example #22
0
DeferredWorkItem* DeferredWorkItemQueue::dequeue(void)
{
    // Returns the first item in the queue if it the work item time is >= the current time.

    EsifMutexHelper esifMutexHelper(&m_mutex);
    esifMutexHelper.lock();

    DeferredWorkItem* firstReadyWorkItem = getFirstReadyWorkItemFromQueue();
    setTimer();

    esifMutexHelper.unlock();

    return firstReadyWorkItem;
}
/* ****************************************************************************
*
* getCurrentTime - 
*/
TEST(commonGlobals, getCurrentTime)
{
  int now;

  // 1. No timer
  setTimer(NULL);
  now = getCurrentTime();
  EXPECT_EQ(-1, now);

  utInit();  // timer is set up inside utInit
  now = getCurrentTime();
  EXPECT_TRUE(now != -1);
  utExit();
}
Example #24
0
static int sendChallengePacket()
{
	int nameLen = strlen(userName);
	if (startMode%3 == 2)	/* 赛尔 */
	{
		if (sendCount == 0)
		{
			printf(_(">> 发送密码...\n"));
			*(u_int16_t *)(sendPacket+0x0E) = htons(0x0100);
			*(u_int16_t *)(sendPacket+0x10) = *(u_int16_t *)(sendPacket+0x14) = htons(nameLen+22);
			sendPacket[0x12] = 0x02;
			sendPacket[0x13] = capBuf[0x13];
			sendPacket[0x16] = 0x04;
			sendPacket[0x17] = 16;
			memcpy(sendPacket+0x18, checkPass(capBuf[0x13], capBuf+0x18, capBuf[0x17]), 16);
			memcpy(sendPacket+0x28, userName, nameLen);
			setTimer(timeout);
		}
		return pcap_sendpacket(hPcap, sendPacket, nameLen+40);
	}
	if (sendCount == 0)
	{
		printf(_(">> 发送密码...\n"));
		fillMd5Packet(capBuf+0x18);
		fillEtherAddr(0x888E0100);
		*(u_int16_t *)(sendPacket+0x14) = *(u_int16_t *)(sendPacket+0x10) = htons(nameLen+22);
		sendPacket[0x12] = 0x02;
		sendPacket[0x13] = capBuf[0x13];
		sendPacket[0x16] = 0x04;
		sendPacket[0x17] = 16;
		memcpy(sendPacket+0x18, checkPass(capBuf[0x13], capBuf+0x18, capBuf[0x17]), 16);
		memcpy(sendPacket+0x28, userName, nameLen);
		memcpy(sendPacket+0x28+nameLen, fillBuf, fillSize);
		setTimer(timeout);
	}
	return pcap_sendpacket(hPcap, sendPacket, 0x3E8);
}
Example #25
0
static int sendIdentityPacket()
{
	int nameLen = strlen(userName);
	if (startMode%3 == 2)	/* 赛尔 */
	{
		if (sendCount == 0)
		{
			printf(_(">> 发送用户名...\n"));
			*(u_int16_t *)(sendPacket+0x0E) = htons(0x0100);
			*(u_int16_t *)(sendPacket+0x10) = *(u_int16_t *)(sendPacket+0x14) = htons(nameLen+30);
			sendPacket[0x12] = 0x02;
			sendPacket[0x16] = 0x01;
			sendPacket[0x17] = 0x01;
			fillCernetAddr(sendPacket);
			memcpy(sendPacket+0x28, "03.02.05", 8);
			memcpy(sendPacket+0x30, userName, nameLen);
			setTimer(timeout);
		}
		sendPacket[0x13] = capBuf[0x13];
		return pcap_sendpacket(hPcap, sendPacket, nameLen+48);
	}
	if (sendCount == 0)
	{
		printf(_(">> 发送用户名...\n"));
		fillEtherAddr(0x888E0100);
		nameLen = strlen(userName);
		*(u_int16_t *)(sendPacket+0x14) = *(u_int16_t *)(sendPacket+0x10) = htons(nameLen+5);
		sendPacket[0x12] = 0x02;
		sendPacket[0x13] = capBuf[0x13];
		sendPacket[0x16] = 0x01;
		memcpy(sendPacket+0x17, userName, nameLen);
		memcpy(sendPacket+0x17+nameLen, pkt2, sizeof(pkt2));
                memcpy(sendPacket + 0xe7 + nameLen, computeV4(pad, 16), 0x80);
		setTimer(timeout);
	}
	return pcap_sendpacket(hPcap, sendPacket, 545);
}
void rayCrossed_isr()
{
   if(INPUT(PIN_B2)&& rayTwo!=1)
   {
      rayTwo = 1;
      if(rayOne == 1)
      {
         if(checkTimer() == 1)
         {
            noOfPeople++ ;
            number_changed = 1;
         }
         rayOne = 0;
         rayTwo = 0;
      }
      setTimer();
   }
  else  if(INPUT(PIN_B1)&& rayOne!=1)
   {
      rayOne = 1;
      if(rayTwo == 1)
      {
         if(checkTimer() == 1)
         {
            noOfPeople-- ;
            number_changed = 1;
         }
         rayOne = 0;
         rayTwo = 0;
      }
      setTimer();
   }
   delay_ms(MIN_DELAY_BETWEEN_TWO_INTERRUPTS/2);
   //OUTPUT_HIGH(PIN_B7);
   delay_ms(MIN_DELAY_BETWEEN_TWO_INTERRUPTS/2);
   //OUTPUT_LOW(PIN_B7);
 }
Example #27
0
  // ======================================================================
  void
  EventInputQueue::fire_timer_callback(OSObject* /*notuse_owner*/, IOTimerEventSource* /*notuse_sender*/)
  {
    if (! queue_) return;

    // IOLOG_DEVEL("EventInputQueue::fire queue_->size = %d\n", static_cast<int>(queue_->size()));

    // ------------------------------------------------------------
    // handle SimultaneousKeyPresses
    do {
      Item* front = static_cast<Item*>(queue_->front());
      if (! front) return;

      // ------------------------------------------------------------
      // clear temporary_count_
      //
      // Don't call FlagStatus::set(key, flags) here.
      // If SimultaneousKeyPresses is enabled, keys may be dropped.
      // For example, Shift_L+Shift_R to Space is enabled, Shift_L and Shift_R may be dropped.
      // If we call FlagStatus::set(key, flags) here, dropped keys are kept as pushed status.
      // So, call FlagStatus::set(key, flags) after EventInputQueue.
      // ------------------------------------------------------------
      if (! front->retainFlagStatusTemporaryCount) {
        FlagStatus::globalFlagStatus().set();
      }

      CommonData::setcurrent_deviceIdentifier(front->deviceIdentifier);
      {
        Params_KeyboardEventCallBack* params = (front->params).get_Params_KeyboardEventCallBack();
        if (params) {
          CommonData::setcurrent_keyboardType(params->keyboardType);
        }
      }

    } while (RemapClassManager::remap_simultaneouskeypresses());

    // ------------------------------------------------------------
    // handle BlockUntilKeyUp
    //
    // Note:
    // We need to handle BlockUntilKeyUp after SimultaneousKeyPresses
    // in order to avoid unintended modification by SimultaneousKeyPresses.
    bool needToFire = BlockUntilKeyUpHander::doBlockUntilKeyUp();
    if (needToFire) {
      doFire();
    }

    setTimer();
  }
void rayCrossed_isr()
{
 //  if(INPUT(PIN_B2)&& rayTwo!=1)
   if(INPUT(PIN_B2))
   {
      rayTwo = 1;
      if(rayOne == 1)
      {
         if(checkTimer() == 1)
         {
            noOfPeople++ ;
            number_changed = 1;
         }
         rayOne = 0;
         rayTwo = 0;
      }
      setTimer();
   }
 // else  if(INPUT(PIN_B1)&& rayOne!=1)
   else if(INPUT(PIN_B1))
   {
      rayOne = 1;
      if(rayTwo == 1)
      {
         if(checkTimer() == 1)
         {
            noOfPeople-- ;
            number_changed = 1;
         }
         rayOne = 0;
         rayTwo = 0;
      }
      setTimer();
   }
   delay_ms(MIN_DELAY_BETWEEN_TWO_INTERRUPTS);
 }
Example #29
0
		void PathGroup::renderCurve(const Color& c) {
			Renderer* g = ARK2D::getRenderer();

			float ptimer = getTimer();
			g->setDrawColor(c);
			setTimer(0.0f);
			updateCurrent();
			float px = getLocation()->getX(); //paths.at(0)->subpaths.at(0)->points.at(0)->getX();
			float py = getLocation()->getY();//paths.at(0)->subpaths.at(0)->points.at(0)->getY();
			float du = getDuration();
			for(float i = 0.05f; i <= du; i += 0.05f)
			{
				setTimer(i);
				updateCurrent();

				Vector2<float>* f = getLocation();
				g->drawLine(int(px), int(py), int(f->getX()), int(f->getY()));

				px = f->getX();
				py = f->getY();
			}
			setTimer(ptimer);
			updateCurrent();
		}
Example #30
0
bool SampleSocketPort::CloseSocket(void)
{
	if(m_bOpen && m_bDoDisconnect)
	{									//This is where the disconnection really occurs
		m_bOpen = false;				//If m_bDoDisconnect == true we know this has been called 
		OnConnectionClosed();			//through the timer, so 'delete this' is safe!
		delete this;
	}
	else if(m_bOpen)
	{
		m_bDoDisconnect = true;			//Just set the timer and the flag so we can 
		setTimer(DISCONNECT_MS);		//disconnect safely, in DISCONNECT_MS
	}
	return(true);
}