void commandSimulationStep(double time) { // progress the simulation in SUMO // reset is used to initalize the global parameters reset(); // Send command writeUnsignedByte(1 + 1 + 4); // command length writeUnsignedByte(CMD_SIMSTEP2); // look up TraCIConstants.h // writeInt((int)(time*1000)); // TraCI accepts time in milli seconds writeInt((int)(time)); // TraCI accepts time in milli seconds sendExact(storageLength(storageStart)); extractCommandStatus(receiveExact(), CMD_SIMSTEP2, description); if (departed == NULL) { departed = (string_list*) malloc(sizeof(string_list)); // departed MUST point to HEAD departed->string = NULL; departed->next = NULL; } if (arrived == NULL) { arrived = (string_list*) malloc(sizeof(string_list)); // arrived MUST point to HEAD arrived->string = NULL; arrived->next = NULL; } /* if (departed == NULL) departed = (String_list)malloc(sizeof(String_list)); // departed MUST point to HEAD if (arrived == NULL) arrived = (String_list)malloc(sizeof(String_list)); // departed MUST point to HEAD */ processSubscriptions(); }
void init(int max_sim_time) { #ifdef STANDALONE printf(" Initializing TraCI...\n"); #else LOG_N(OMG, " Initializing TraCI...\n"); #endif char *objID = " "; // size_t size = strlen(objID); int noSubscribedVars = 2; writeUnsignedByte(0); writeInt(1 + 4 + 1 + 4 + 4 + 4 + (int) strlen(objID) + 1 + noSubscribedVars); writeUnsignedByte(CMD_SUBSCRIBE_SIM_VARIABLE); // command id writeInt(0); // begin time writeInt(max_sim_time*1000); // end time writeString(objID); // object id writeUnsignedByte(noSubscribedVars); // variable number writeUnsignedByte(VAR_DEPARTED_VEHICLES_IDS); writeUnsignedByte(VAR_ARRIVED_VEHICLES_IDS); // send request message sendExact(storageLength(storageStart)); extractCommandStatus(receiveExact(), CMD_SUBSCRIBE_SIM_VARIABLE, description); if (departed == NULL) { departed = (string_list*) malloc(sizeof(string_list)); // departed MUST point to HEAD departed->string = NULL; departed->next = NULL; } if (arrived == NULL) { arrived = (string_list*) malloc(sizeof(string_list)); // arrived MUST point to HEAD arrived->string = NULL; arrived->next = NULL; } processSubscriptions(); reset(); }
void SyncMaster::endSync() { fdb.checkSanity(); canceled = false; errorCount = 0; int totalGroups = 0; for(ForumSubscription *fsub : fdb) { if(fsub->hasGroupListChanged()) { forumsToUpload.append(fsub); fsub->setGroupListChanged(false); fsub->setBeingSynced(true); } for(ForumGroup *grp : fsub->values()) { if(grp->isSubscribed()) totalGroups++; if(grp->isSubscribed() && grp->hasChanged()) { groupsToUpload.append(grp); } } } maxGroupCount = groupsToUpload.size(); qDebug() << Q_FUNC_INFO << "Uploading " << maxGroupCount << " of " << totalGroups << " groups."; processSubscriptions(); }