本文整理汇总了C++中InitTimer函数的典型用法代码示例。如果您正苦于以下问题:C++ InitTimer函数的具体用法?C++ InitTimer怎么用?C++ InitTimer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitTimer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char **argv )
{
int algo, arg, verbose;
char *filename;
/* Check arguments */
if( (argc < 3) || (argc > 4) )
{
Help( argv[ 0 ] );
return 0;
}
arg = 1;
/* Check for options */
verbose = 0;
if( strcmp( argv[arg], "-v" ) == 0 )
{
verbose = 1;
++ arg;
}
/* Get algo */
algo = 0;
if( strcmp( argv[arg], "rle" ) == 0 ) algo = 1;
if( strcmp( argv[arg], "huff" ) == 0 ) algo = 2;
if( strcmp( argv[arg], "rice8" ) == 0 ) algo = 3;
if( strcmp( argv[arg], "rice16" ) == 0 ) algo = 4;
if( strcmp( argv[arg], "rice32" ) == 0 ) algo = 5;
if( strcmp( argv[arg], "rice8s" ) == 0 ) algo = 6;
if( strcmp( argv[arg], "rice16s" ) == 0 ) algo = 7;
if( strcmp( argv[arg], "rice32s" ) == 0 ) algo = 8;
if( strcmp( argv[arg], "lz" ) == 0 ) algo = 9;
if( strcmp( argv[arg], "lz_f" ) == 0 ) algo = 10;
if( strcmp( argv[arg], "sf" ) == 0 ) algo = 11;
if( !algo )
{
Help( argv[ 0 ] );
return 0;
}
++ arg;
/* Get file name */
filename = argv[arg];
/* Initialize timer */
InitTimer();
/* Test file */
TestFile( filename, algo, verbose );
return 0;
}
示例2: InitTimer
/**
* @function DeleteWorld
* @brief
* @date 2011-10-13
*/
void GRIPFrame::DeleteWorld() {
InitTimer("",0);
timeVector.clear();
if(mWorld) {
delete mWorld;
mWorld = 0;
selectedTreeNode = 0;
treeView->DeleteAllItems();
}
}
示例3: main
int main()
{
InitTimer();
InitComm();
PrintLn("hello, world!");
InitOLED();
TestOLED();
return 0;
}
示例4: main
int main(void) //main body calls all other functions to initialize the proper values of the Transmission protocol, timer and ADC module, then starts them
{
InitialzeLCD(); //initializes LCD
SetADCChannel(5); // sets ADC channel for temperature sensor
InitADC(); // Initializes ADC and timer below to 1 second
InitTimer();
startTimer();
startADC();
while(1)
{
// Main loop
}
}
示例5: main
void main(void) {
(void)puts("\r\nIn test harness for timer.c \r\n");
InitTimer();
EnableInterrupts;
StartTimer(1, 2000);
while(1) {
if(IsTimerExpired(1)) {
(void)printf("Egg is Cooked!\r\n");
}
}
}
示例6: subscribeToShadowActionAcks
IoT_Error_t subscribeToShadowActionAcks(const char *pThingName, ShadowActions_t action, bool isSticky) {
IoT_Error_t ret_val = NONE_ERROR;
MQTTSubscribeParams subParams = MQTTSubscribeParamsDefault;
bool clearBothEntriesFromList = true;
int16_t indexAcceptedSubList = 0;
int16_t indexRejectedSubList = 0;
indexAcceptedSubList = getNextFreeIndexOfSubscriptionList();
indexRejectedSubList = getNextFreeIndexOfSubscriptionList();
if (indexAcceptedSubList >= 0 && indexRejectedSubList >= 0) {
topicNameFromThingAndAction(SubscriptionList[indexAcceptedSubList].Topic, pThingName, action, SHADOW_ACCEPTED);
subParams.mHandler = AckStatusCallback;
subParams.qos = QOS_0;
subParams.pTopic = SubscriptionList[indexAcceptedSubList].Topic;
ret_val = pMqttClient->subscribe(&subParams);
if (ret_val == NONE_ERROR) {
SubscriptionList[indexAcceptedSubList].count = 1;
SubscriptionList[indexAcceptedSubList].isSticky = isSticky;
topicNameFromThingAndAction(SubscriptionList[indexRejectedSubList].Topic, pThingName, action,
SHADOW_REJECTED);
subParams.pTopic = SubscriptionList[indexRejectedSubList].Topic;
ret_val = pMqttClient->subscribe(&subParams);
if (ret_val == NONE_ERROR) {
SubscriptionList[indexRejectedSubList].count = 1;
SubscriptionList[indexRejectedSubList].isSticky = isSticky;
clearBothEntriesFromList = false;
// wait for SUBSCRIBE_SETTLING_TIME seconds to let the subscription take effect
Timer subSettlingtimer;
InitTimer(&subSettlingtimer);
countdown(&subSettlingtimer, SUBSCRIBE_SETTLING_TIME);
while(!expired(&subSettlingtimer));
}
}
}
if (clearBothEntriesFromList) {
if (indexAcceptedSubList >= 0) {
SubscriptionList[indexAcceptedSubList].isFree = true;
} else if (indexRejectedSubList >= 0) {
SubscriptionList[indexRejectedSubList].isFree = true;
}
if (SubscriptionList[indexAcceptedSubList].count == 1) {
ret_val = pMqttClient->unsubscribe(SubscriptionList[indexAcceptedSubList].Topic);
}
}
return ret_val;
}
示例7: MQTTPublish
int MQTTPublish(Client* c, const char* topicName, MQTTMessage* message)
{
int rc = FAILURE;
Timer timer;
MQTTString topic = MQTTString_initializer;
topic.cstring = (char *)topicName;
int len = 0;
InitTimer(&timer);
countdown_ms(&timer, c->command_timeout_ms);
if (!c->isconnected)
goto exit;
if (message->qos == QOS1 || message->qos == QOS2)
message->id = getNextPacketId(c);
len = MQTTSerialize_publish(c->buf, c->buf_size, 0, message->qos, message->retained, message->id,
topic, (unsigned char*)message->payload, message->payloadlen);
if (len <= 0)
goto exit;
if ((rc = sendPacket(c, len, &timer)) != SUCCESS) // send the subscribe packet
goto exit; // there was a problem
if (message->qos == QOS1)
{
if (waitfor(c, PUBACK, &timer) == PUBACK)
{
unsigned short mypacketid;
unsigned char dup, type;
if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
rc = FAILURE;
}
else
rc = FAILURE;
}
else if (message->qos == QOS2)
{
if (waitfor(c, PUBCOMP, &timer) == PUBCOMP)
{
unsigned short mypacketid;
unsigned char dup, type;
if (MQTTDeserialize_ack(&type, &dup, &mypacketid, c->readbuf, c->readbuf_size) != 1)
rc = FAILURE;
}
else
rc = FAILURE;
}
exit:
return rc;
}
示例8: TclServiceIdle
int
TclServiceIdle(void)
{
IdleHandler *idlePtr;
int oldGeneration;
Tcl_Time blockTime;
ThreadSpecificData *tsdPtr = InitTimer();
if (tsdPtr->idleList == NULL) {
return 0;
}
oldGeneration = tsdPtr->idleGeneration;
tsdPtr->idleGeneration++;
/*
* The code below is trickier than it may look, for the following reasons:
*
* 1. New handlers can get added to the list while the current one is
* being processed. If new ones get added, we don't want to process
* them during this pass through the list (want to check for other work
* to do first). This is implemented using the generation number in the
* handler: new handlers will have a different generation than any of
* the ones currently on the list.
* 2. The handler can call Tcl_DoOneEvent, so we have to remove the
* handler from the list before calling it. Otherwise an infinite loop
* could result.
* 3. Tcl_CancelIdleCall can be called to remove an element from the list
* while a handler is executing, so the list could change structure
* during the call.
*/
for (idlePtr = tsdPtr->idleList;
((idlePtr != NULL)
&& ((oldGeneration - idlePtr->generation) >= 0));
idlePtr = tsdPtr->idleList) {
tsdPtr->idleList = idlePtr->nextPtr;
if (tsdPtr->idleList == NULL) {
tsdPtr->lastIdlePtr = NULL;
}
idlePtr->proc(idlePtr->clientData);
ckfree(idlePtr);
}
if (tsdPtr->idleList) {
blockTime.sec = 0;
blockTime.usec = 0;
Tcl_SetMaxBlockTime(&blockTime);
}
return 1;
}
示例9: IR_Init
/*******************************************************************************
* PUBLIC FUNCTIONS *
******************************************************************************/
char IR_Init() {
//dbprintf("\nInitializing the IR Sensor Module.");
#ifdef USE_LEDS
LED_Init(LED_BANK3 |LED_BANK1);
LED_OffBank(LED_BANK3, 0xF);
LED_OffBank(LED_BANK1, 0xF);
#endif
InitTimer(TIMER_IR, UPDATE_DELAY);
return SUCCESS;
}
示例10: InitTimer
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
{
if( !g_bTimerInitialized )
InitTimer();
int64_t ret = timeGetTime() * int64_t(1000);
if( bAccurate )
{
ret = FixupTimeIfLooped( ret );
ret = FixupTimeIfBackwards( ret );
}
return ret;
}
示例11: MQTTConnect
int MQTTConnect (Client *c, MQTTPacket_connectData *options)
{
Timer connect_timer;
int rc = FAILURE;
int len = 0;
MQTTPacket_connectData default_options = MQTTPacket_connectData_initializer;
InitTimer (&connect_timer);
countdown_ms (&connect_timer, c->command_timeout_ms);
if (c->isconnected) // don't send connect packet again if we are already connected
goto exit;
if (options == 0)
options = &default_options; // set default options if none were supplied
c->keepAliveInterval = options->keepAliveInterval;
countdown (&c->ping_timer, c->keepAliveInterval);
//--------------------------------------------------------------------
// Generate a MQTT "Connect" packet, and send it to the remote Broker
//--------------------------------------------------------------------
len = MQTTSerialize_connect (c->buf, c->buf_size, options);
if (len <= 0)
goto exit; // supplied buffer is too small
rc = sendPacket (c, len, &connect_timer); // send the connect packet
if (rc != SUCCESS)
goto exit; // there was a problem
//--------------------------------------------------------------------
// Wait for and read in the MQTT "ConnAck" reply packet.
//--------------------------------------------------------------------
// this will be a blocking call, wait for the connack
if (waitfor(c, CONNACK, &connect_timer) == CONNACK)
{
unsigned char connack_rc = 255;
char sessionPresent = 0;
if (MQTTDeserialize_connack((unsigned char*) &sessionPresent, &connack_rc,
c->readbuf, c->readbuf_size) == 1)
rc = connack_rc;
else rc = FAILURE;
}
else rc = FAILURE;
exit:
if (rc == SUCCESS)
c->isconnected = 1;
return rc;
}
示例12: MQTTSubscribe
int MQTTSubscribe (Client *c, const char *topicFilter, enum QoS qos,
messageHandler messageHandler)
{
int i;
int rc = FAILURE;
Timer timer;
int len = 0;
MQTTString topic = MQTTString_initializer;
topic.cstring = (char*) topicFilter;
InitTimer (&timer);
countdown_ms (&timer, c->command_timeout_ms); // default is 1 second timeouts
if ( ! c->isconnected)
goto exit;
len = MQTTSerialize_subscribe (c->buf, c->buf_size, 0, getNextPacketId(c), 1,
&topic, (int*) &qos);
if (len <= 0)
goto exit;
if ((rc = sendPacket(c, len, &timer)) != SUCCESS) // send the subscribe packet
goto exit; // there was a problem
if (waitfor(c, SUBACK, &timer) == SUBACK) // wait for suback
{
int count = 0, grantedQoS = -1;
unsigned short mypacketid;
if (MQTTDeserialize_suback(&mypacketid, 1, &count, &grantedQoS, c->readbuf, c->readbuf_size) == 1)
rc = grantedQoS; // will be 0, 1, 2 or 0x80
if (rc != 0x80)
{
for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i)
{
if (c->messageHandlers[i].topicFilter == 0)
{
c->messageHandlers[i].topicFilter = topicFilter;
c->messageHandlers[i].fp = messageHandler;
rc = 0; // denote success
break;
}
}
}
}
else rc = FAILURE; // timed out - no SUBACK received
exit:
return rc;
}
示例13: main
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
// Increase PMMCOREV level to 2 for proper radio operation
SetVCore(2);
ResetRadioCore();
InitButtonLeds();
InitTimer();
// Clean out the RX Buffer
rxPosition = PACKET_LEN+2;
while(rxPosition--)
{
RxBuffer[rxPosition] = 0;
}
InitRadio();
ReceiveOn();
while (1)
{
P1IE |= BIT7; // Enable button interrupt
__bis_SR_register( LPM3_bits + GIE );
__no_operation();
if (buttonPressed) // Process a button press->transmit
{
ReceiveOff(); // Button means TX, stop RX
receiving = 0;
TransmitPacket();
buttonPressed = 0; // Re-enable button press
}
if(receiving)
{
ReceivePacket();
__no_operation();
}
if(!transmitting)
{
ReceiveOn();
}
}
}
示例14: main
void main(void) {
(void)printf("Start of E128 program\r\n");
InitPorts();
InitTimer();
InitMotors();
InitSide();
InitBeacons();
EnableInterrupts;
StartMasterSM();
while(1) { // Repeat State Machine Forever
(void)RunMasterSM(CheckEvents());
}
}
示例15: MQTTDisconnect
int MQTTDisconnect(Client* c)
{
int rc = FAILURE;
Timer timer; // we might wait for incomplete incoming publishes to complete
int len = MQTTSerialize_disconnect(c->buf, c->buf_size);
InitTimer(&timer);
countdown_ms(&timer, c->command_timeout_ms);
if (len > 0)
rc = sendPacket(c, len, &timer); // send the disconnect packet
c->isconnected = 0;
return rc;
}