bool Demand_Service::Vehicle_Processing (Db_File *fh) { bool parking_flag; int id, lvalue, index; Vehicle_Data *vehicle_ptr; Vehicle_File *file = (Vehicle_File *) fh; parking_flag = Network_Data_Flag (PARKING); //---- reserve memory ---- if (vehicle_data.Max_Records () == 0) { if (!vehicle_data.Max_Records (file->Estimate_Records ())) goto mem_error; } //---- check the vehicle id ---- id = file->Vehicle (); if (id <= 0) return (false); vehicle_ptr = vehicle_data.New_Record (true); if (vehicle_ptr == NULL) goto mem_error; vehicle_ptr->Vehicle (id); vehicle_ptr->Household (file->Household ()); lvalue = file->Location (); if (parking_flag) { index = parking_data.Get_Index (lvalue); if (index == 0) { Warning ("Vehicle %d Location %d was Not Found in the Parking File", id, lvalue); return (false); } if (Renumber ()) { lvalue = index; } } vehicle_ptr->Location (lvalue); vehicle_ptr->Type (file->Type ()); vehicle_ptr->Sub_Type (file->Sub_Type ()); return (true); mem_error: Error ("Insufficient Memory for Vehicle Data"); return (false); }
bool Demand_Service::Population_Processing (Db_File *fh) { bool household_flag; int lvalue, index; Population_Data *population_ptr; Population_File *file = (Population_File *) fh; household_flag = Demand_Data_Flag (HOUSEHOLD); //---- reserve memory ---- if (population_data.Max_Records () == 0) { if (!population_data.Max_Records (file->Estimate_Records ())) goto mem_error; } //---- check the population id ---- lvalue = file->Household (); if (lvalue <= 0) return (false); population_ptr = population_data.New_Record (true); if (population_ptr == NULL) goto mem_error; if (household_flag) { index = household_data.Get_Index (lvalue); if (index == 0) { Error ("Population household %d was Not Found in the Household File", lvalue); } if (Renumber ()) { lvalue = index; } } population_ptr->Household (lvalue); population_ptr->Person (file->Person ()); population_ptr->Relate (file->Relate ()); population_ptr->Age (file->Age ()); population_ptr->Gender (file->Gender ()); population_ptr->Work (file->Work ()); population_ptr->Drive (file->Drive ()); return (true); mem_error: Error ("Insufficient Memory for Population Data"); return (false); }
//////////////////////////////////////////////////////////////// // ファイルから全PARTを読込み //////////////////////////////////////////////////////////////// bool cP6PART::Readf( FILE *fp ) { PRINTD( P6T2_LOG, "[cP6PART][Readf]\n" ); // ファイルポインタは有効? if( !fp ) return false; // 識別子 "TI"(0x4954) ? while( ( FGETWORD( fp ) ) == 0x4954 ){ BYTE NextID = fgetc( fp ); // ID番号 // 既にDATAブロックがあり,IDが異なるなら新規PARTを追加 if( LastPart()->Data && ( LastPart()->Info.ID != NextID ) ){ New(); LastPart()->Info.ID = NextID; } // 既にDATAブロックがある? if( LastPart()->Data ) // 継続PARTならデータ名とボーレートを読み飛ばす fseek( fp, sizeof(Info.Name)+sizeof(Info.Baud)-1, SEEK_CUR ); else{ // データ名 fread( LastPart()->Info.Name, sizeof(BYTE), sizeof(Info.Name)-1, fp ); // ボーレート LastPart()->Info.Baud = FGETWORD( fp ); } // DATAブロック追加 cP6DATA *NewBlk = LastPart()->NewBlock(); WORD stime = FGETWORD( fp ); // 無音部の時間(ms) WORD ptime = FGETWORD( fp ); // ぴー音の時間(ms) DWORD doff = FGETDWORD( fp ); // ベタイメージ先頭からのオフセット DWORD dnum = FGETDWORD( fp ); // データサイズ // データを読込む DWORD fps = ftell( fp ); fseek( fp, doff, SEEK_SET ); NewBlk->SetData( fp, dnum ); NewBlk->SetPeriod( stime, ptime ); fseek( fp, fps, SEEK_SET ); // ファイルポインタを次のPART情報に戻す } Renumber(); return true; }
void Network_Service::Read_Phasing (void) { Db_File *file = Network_Db_File (PHASING_PLAN); //---- store the phasing plan data ---- Show_Message ("Reading %s -- Record", file->File_Type ()); Set_Progress (); if (Check_Data () || Renumber ()) { if (!Network_File_Flag (NODE) && Network_Option_Flag (NODE)) { Error (file_error, "Node", file->File_ID ()); } if (!Network_File_Flag (LINK) && Network_Option_Flag (LINK)) { Error (file_error, "Link", file->File_ID ()); } if (!Network_File_Flag (TIMING_PLAN) && Network_Option_Flag (TIMING_PLAN)) { Error (file_error, "Timing Plan", file->File_ID ()); } } file->Num_Records (); First_Record (true); while (file->Read ()) { Show_Progress (); if (Phasing_Processing (file)) { if (!phasing_data.Add ()) { Error ("Adding Record to the Phasing Plan List"); } } First_Record (false); } End_Progress (); file->Close (); phasing_data.Max_Records (phasing_data.Num_Records ()); Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ()); int num = phasing_data.Num_Records (); if (num && num != Progress_Count ()) { Print (1, "Number of Phasing Plan Data Records = %d", num); } if (num > 0) Network_Data_True (PHASING_PLAN); }
void scContUnit::PostInsert( scContUnit *p2 ) { scContUnit *nextP; if ( p2 ) { nextP = GetNext( ); SetNext( p2 ); p2->SetPrev( this ); scContUnit* last = (scContUnit*)p2->LastInChain(); last->SetNext( nextP ); if ( nextP ) nextP->SetPrev( last ); Renumber( ); } }
void Network_Service::Read_Turn (void) { Turn_File *file = (Turn_File *) Network_Db_File (TURN_PROHIBITION); //---- store the turn prohibition data ---- Show_Message ("Reading %s -- Record", file->File_Type ()); Set_Progress (); if (Check_Data () || Renumber ()) { if (!Network_File_Flag (NODE) && Network_Option_Flag (NODE) && file->Node_Based ()) { Error (file_error, "Node", file->File_ID ()); } if (!Network_File_Flag (LINK) && Network_Option_Flag (LINK)) { Error (file_error, "Link", file->File_ID ()); } } file->Num_Records (); First_Record (true); while (file->Read ()) { Show_Progress (); if (Turn_Processing (file)) { if (!turn_data.Add ()) { Error ("Adding Record to the Turn Data List"); } } First_Record (false); } End_Progress (); file->Close (); Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ()); int num = turn_data.Num_Records (); if (num && num != Progress_Count ()) { Print (1, "Number of Turn Prohibition Data Records = %d", num); } turn_data.Optimize (); if (num > 0) Network_Data_True (TURN_PROHIBITION); }
void Demand_Service::Read_Vehicle (void) { vehicle_data.Sorted (!sort_flag); Db_File *file = Demand_Db_File (VEHICLE); //---- store the vehicle data ---- Show_Message ("Reading %s -- Record", file->File_Type ()); Set_Progress (50000); if (Check_Data () || Renumber ()) { if (!Network_File_Flag (PARKING) && Network_Option_Flag (PARKING)) { Error (file_error, "Parking", file->File_ID ()); } } //file->Num_Records (); First_Record (true); while (file->Read ()) { Show_Progress (); if (Vehicle_Processing (file)) { if (!vehicle_data.Add ()) { Error ("Adding Record to the Vehicle Data Array"); } } First_Record (false); } End_Progress (); file->Close (); Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ()); int num = vehicle_data.Num_Records (); if (num && num != Progress_Count ()) { Print (1, "Number of Vehicle Data Records = %d", num); } vehicle_data.Optimize (compress_flag); if (num > 0) Demand_Data_True (VEHICLE); }
void Demand_Service::Read_Population (void) { Db_File *file = Demand_Db_File (POPULATION); //---- store the population data ---- Show_Message ("Reading %s -- Record", file->File_Type ()); Set_Progress (50000); if (Check_Data () || Renumber ()) { if (!Demand_File_Flag (HOUSEHOLD) && Demand_Option_Flag (HOUSEHOLD)) { Error (file_error, "Household", file->File_ID ()); } } //file->Num_Records (); First_Record (true); while (file->Read ()) { Show_Progress (); if (Population_Processing (file)) { if (!population_data.Add ()) { Error ("Adding Record to the Population Data Array"); } } First_Record (false); } End_Progress (); file->Close (); Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ()); int num = population_data.Num_Records (); if (num && num != Progress_Count ()) { Print (1, "Number of Population Data Records = %d", num); } population_data.Optimize (); if (num > 0) Demand_Data_True (POPULATION); }
bool CPVRChannelGroup::RemoveFromGroup(CPVRChannel *channel) { bool bReturn(false); CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) { if (*channel == *at(iChannelPtr).channel) { // TODO notify observers erase(begin() + iChannelPtr); bReturn = true; m_bChanged = true; break; } } Renumber(); return bReturn; }
scStream* scStream::Split( scContUnit* cu ) { scContUnit* prevPara; scContUnit* para; /* insure that they are in the same stream */ raise_if( this != (scContUnit *)cu->FirstInChain( ), scERRlogical ); /* make the split */ prevPara = cu->GetPrev(); prevPara->SetNext( NULL ); cu->SetPrev( NULL ); /* walk down the second half and delete any existing lines */ for ( para = cu; para; para = para->GetNext( ) ) para->Deformat( ); /* renumber the streams */ Renumber(); cu->Renumber(); return (scStream*)cu; }
bool CPVRChannelGroup::MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb /* = true */) { if (iOldChannelNumber == iNewChannelNumber) return true; bool bReturn(false); CSingleLock lock(m_critSection); /* make sure the list is sorted by channel number */ SortByChannelNumber(); /* old channel number out of range */ if (iOldChannelNumber > size()) return bReturn; /* new channel number out of range */ if (iNewChannelNumber > size()) iNewChannelNumber = size(); /* move the channel in the list */ PVRChannelGroupMember entry = at(iOldChannelNumber - 1); erase(begin() + iOldChannelNumber - 1); insert(begin() + iNewChannelNumber - 1, entry); /* renumber the list */ Renumber(); m_bChanged = true; if (bSaveInDb) bReturn = Persist(); else bReturn = true; CLog::Log(LOGNOTICE, "CPVRChannelGroup - %s - %s channel '%s' moved to channel number '%d'", __FUNCTION__, (m_bRadio ? "radio" : "tv"), entry.channel->ChannelName().c_str(), iNewChannelNumber); return true; }
void Ide::BeginBuilding(bool sync_files, bool clear_console) { SetupDefaultMethod(); HdependTimeDirty(); Renumber(); StopDebug(); ShowConsole(); SaveFile(); SaveWorkspace(); SetIdeState(BUILDING); console.Kill(); console.ClearError(); error_cache.Clear(); error.Clear(); SyncErrorsMessage(); error_count = 0; warning_count = 0; if(clear_console) console.Clear(); build_time = GetTickCount(); CreateHost(sync_files); cmdout.Clear(); }
bool CPVRChannelGroup::AddToGroup(CPVRChannel *channel, int iChannelNumber /* = 0 */, bool bSortAndRenumber /* = true */) { CSingleLock lock(m_critSection); bool bReturn(false); if (!channel) return bReturn; if (!CPVRChannelGroup::IsGroupMember(channel)) { if (iChannelNumber <= 0 || iChannelNumber > (int) size() + 1) iChannelNumber = size() + 1; CPVRChannel *realChannel = (IsInternalGroup()) ? channel : (CPVRChannel *) CPVRManager::GetChannelGroups()->GetGroupAll(m_bRadio)->GetByChannelID(channel->ChannelID()); if (realChannel) { PVRChannelGroupMember newMember = { realChannel, iChannelNumber }; push_back(newMember); m_bChanged = true; if (bSortAndRenumber) { SortByChannelNumber(); Renumber(); } // TODO notify observers bReturn = true; } } return bReturn; }
bool Network_Service::Turn_Processing (Db_File *fh) { bool node_flag, link_flag, ab_flag; int lvalue, num, node_num, link; char *str_ptr; Link_Data *link_ptr = NULL; Turn_Data *turn_ptr = NULL; Time_Step time_step; Turn_File *file = (Turn_File *) fh; node_flag = Network_Data_Flag (NODE); link_flag = Network_Data_Flag (LINK); ab_flag = file->Node_Based (); //---- reserve memory ---- if (turn_data.Max_Records () == 0) { if (!turn_data.Max_Records (file->Num_Records ())) goto mem_error; } //---- read and save the data ---- turn_ptr = turn_data.New_Record (); if (turn_ptr == NULL) goto mem_error; node_num = file->Node (); if (node_num == 0) return (false); if (node_flag) { num = node_data.Get_Index (node_num); if (num == 0) { return (Check_Message ("Turn Prohibition Node %d was Not Found in the Node file", node_num)); } if (!Renumber ()) { num = node_num; } } else { num = node_num; } if (ab_flag) { //---- node-based method ---- AB_Data *ab_ptr; Dir_Data *dir_ptr; lvalue = file->In_Node (); ab_ptr = ab_key.Get (lvalue, node_num); if (ab_ptr == NULL) { return (Check_Message ("A Link between %d and %d was Not Found", lvalue, node_num)); } dir_ptr = dir_data [ab_ptr->dir]; turn_ptr->In_Link_Dir (dir_ptr->Link_Dir ()); lvalue = file->Out_Node (); ab_ptr = ab_key.Get (node_num, lvalue); if (ab_ptr == NULL) { return (Check_Message ("A Link between %d and %d was Not Found", node_num, lvalue)); } dir_ptr = dir_data [ab_ptr->dir]; turn_ptr->Out_Link_Dir (dir_ptr->Link_Dir ()); } else { //---- link-based method ---- lvalue = file->In_Link (); if (link_flag) { link = link_data.Get_Index (lvalue); if (link == 0) { return (Check_Message ("Turn Prohibition In-Link %d was Not Found in the Link file", lvalue)); } link_ptr = link_data [link]; if (!Renumber ()) { link = lvalue; } turn_ptr->In_Link (link); if (link_ptr->Anode () == num) { turn_ptr->In_Dir (1); } else if (link_ptr->Bnode () == num) { turn_ptr->In_Dir (0); } else { return (Check_Message ("Turn Prohibition In-Link %d is Not Attached to Node %d", lvalue, node_num)); } } else { turn_ptr->In_Link (lvalue); } //---- check/convert the out-link number ---- lvalue = file->Out_Link (); if (link_flag) { link = link_data.Get_Index (lvalue); if (link == 0) { return (Check_Message ("Turn Prohibition Out-Link %d was Not Found in the Link file", lvalue)); } link_ptr = link_data [link]; if (!Renumber ()) { link = lvalue; } turn_ptr->Out_Link (link); if (link_ptr->Bnode () == num) { turn_ptr->Out_Dir (1); } else if (link_ptr->Anode () == num) { turn_ptr->Out_Dir (0); } else { return (Check_Message ("Turn Prohibition Out-Link %d is Not Attached to Node %d", lvalue, node_num)); } } else { turn_ptr->Out_Link (lvalue); } } str_ptr = file->Start (); if (*str_ptr == '\0') { turn_ptr->Start (0); } else { turn_ptr->Start (Round (time_step.Step (str_ptr))); } str_ptr = file->End (); if (*str_ptr == '\0') { turn_ptr->End (Round (MIDNIGHT)); } else { turn_ptr->End (Round (time_step.Step (str_ptr))); } str_ptr = file->Use (); if (*str_ptr == '\0') { str_ptr = "ANY"; } turn_ptr->Use (Use_Code (str_ptr)); turn_ptr->Penalty (file->Penalty ()); return (true); mem_error: Error ("Insufficient Memory for Turn Prohibition Records"); return (false); }
bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channels) { bool bChanged = false; int iCurSize = size(); CPVRChannelGroup *newChannels = new CPVRChannelGroup(m_bRadio); CPVRDatabase *database = g_PVRManager.GetTVDatabase(); if (!database || !database->Open()) return bChanged; /* go through the channel list and check for updated or new channels */ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++) { const CPVRChannel *channel = channels.at(iChannelPtr).channel; /* check if this channel is present in this container */ CPVRChannel *existingChannel = (CPVRChannel *) GetByClient(channel->UniqueID(), channel->ClientID()); if (existingChannel) { /* if it's present, update the current tag */ if (existingChannel->UpdateFromClient(*channel)) { bChanged = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - updated %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); } } else { /* new channel */ CPVRChannel *newChannel = new CPVRChannel(m_bRadio); newChannel->SetUniqueID(channel->UniqueID(), false); newChannel->UpdateFromClient(*channel); newChannels->AddToGroup(newChannel); int iChannelNumber = iCurSize == 0 ? channel->ClientChannelNumber() : 0; InsertInGroup(newChannel, iChannelNumber, false); bChanged = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - added %s channel '%s' at position %d", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str(), iChannelNumber); } } /* persist changes */ for (unsigned int iChannelPtr = 0; iChannelPtr < newChannels->size(); iChannelPtr++) ((CPVRChannel *) newChannels->GetByIndex(iChannelPtr))->Persist(false); /* write immediately to get a db id */ delete newChannels; /* check for deleted channels */ unsigned int iSize = size(); for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++) { CPVRChannel *channel = (CPVRChannel *) GetByIndex(iChannelPtr); if (!channel) continue; if (channels.GetByClient(channel->UniqueID(), channel->ClientID()) == NULL) { /* channel was not found */ CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - deleted %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); /* remove this channel from all non-system groups */ ((CPVRChannelGroups *) g_PVRChannelGroups->Get(m_bRadio))->RemoveFromAllGroups(channel); delete at(iChannelPtr).channel; erase(begin() + iChannelPtr); iChannelPtr--; iSize--; bChanged = true; } } database->Close(); /* try to find channel icons */ SearchAndSetChannelIcons(); CacheIcons(); if (bChanged || HasChanges()) { /* remove invalid channels */ RemoveInvalidChannels(); /* sort by client channel number if this is the first time */ if (iCurSize == 0) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. new channels were added at the back, so they'll get the highest numbers */ Renumber(); return Persist(); } else { return true; } }
bool CPVRChannelGroupInternal::UpdateGroupEntries(CPVRChannelGroup *channels) { CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if(!database && !database->Open()) return false; int iSize = size(); for (int ptr = 0; ptr < iSize; ptr++) { CPVRChannel *channel = at(ptr).channel; /* ignore virtual channels */ if (channel->IsVirtual()) continue; /* check if this channel is still present */ const CPVRChannel *existingChannel = channels->GetByUniqueID(channel->UniqueID()); if (existingChannel) { /* if it's present, update the current tag */ if (channel->UpdateFromClient(*existingChannel)) { channel->Persist(true); CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - updated %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); } /* remove this tag from the temporary channel list */ channels->RemoveByUniqueID(channel->UniqueID()); } else { /* channel is no longer present */ CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - removing %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); channel->Delete(); erase(begin() + ptr); ptr--; iSize--; } } /* the temporary channel list only contains new channels now */ for (unsigned int ptr = 0; ptr < channels->size(); ptr++) { CPVRChannel *channel = channels->at(ptr).channel; channel->Persist(true); PVRChannelGroupMember member = { channel, size() }; push_back(member); CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - added %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); } /* post the queries generated by the update */ database->CommitInsertQueries(); database->Close(); Renumber(); return true; }
void Network_Service::Read_Schedule (void) { int i, route, time, stop, last_route, first_stop, nrun, nstop, index, npoints, tim; int num_runs, max_runs, num; bool stop_flag; Line_Data *line_ptr = NULL; Schedule_File *file = (Schedule_File *) Network_Db_File (TRANSIT_SCHEDULE); if (!Network_Data_Flag (TRANSIT_ROUTE)) { Error (file_error, "Transit Route", file->File_ID ()); } stop_flag = Network_Data_Flag (TRANSIT_STOP); if (Check_Data () || Renumber ()) { if (!Network_File_Flag (TRANSIT_STOP) && Network_Option_Flag (TRANSIT_STOP)) { Error (file_error, "Transit Stop", file->File_ID ()); } } Show_Message ("Reading %s -- Record", file->File_Type ()); //---- scan for number of runs per route ---- last_route = first_stop = nrun = nstop = npoints = num_runs = max_runs = 0; while (file->Read ()) { route = file->Route (); if (route == 0) continue; //---- check the stop data ---- stop = file->Stop (); if (stop_flag) { index = stop_data.Get_Index (stop); if (index == 0) { Check_Message ("Stop %d on Route %d was Not Found in the Stop File", stop, route); continue; } if (Renumber ()) stop = index; } if (route != last_route) { if (last_route > 0) { if (!line_ptr->Runs (nrun)) goto mem_error; if (nrun > max_runs) max_runs = nrun; num_runs += nrun; } first_stop = stop; last_route = route; nrun = 1; nstop = 1; line_ptr = line_data.Get (route); if (line_ptr == NULL) { Check_Message ("Transit Route %d was Not Found in the Route File", route); continue; } stop = line_ptr->Stop (1); if (first_stop != stop) { if (Renumber ()) stop = stop_data [stop]->ID (); Check_Message ("Transit Route %d First Stop %d Schedule was Not Found", route, stop); continue; } } else { for (nstop++; nstop <= line_ptr->Stops (); nstop++) { if (stop == line_ptr->Stop (nstop)) break; } if (nstop > line_ptr->Stops ()) { nstop = 1; if (stop == first_stop) { nrun++; } else { Check_Message ("Stop %d was Not Found on Route %d", file->Stop (), route); continue; } nstop = i = 1; } } } if (last_route > 0) { if (!line_ptr->Runs (nrun)) goto mem_error; if (nrun > max_runs) max_runs = nrun; num_runs += nrun; } file->Rewind (); line_data.Num_Runs (num_runs); line_data.Max_Runs (max_runs); //---- store the transit schedule data ---- Set_Progress (); last_route = first_stop = num = 0; nrun = nstop = 1; while (file->Read ()) { Show_Progress (); route = file->Route (); if (route == 0) continue; //---- check the stop id ---- stop = file->Stop (); if (Renumber ()) { stop = stop_data.Get_Index (stop); } time = Round (file->Time ()); //---- check for a new route ---- if (route != last_route) { first_stop = stop; last_route = route; nrun = nstop = i = 1; line_ptr = line_data.Get (route); } else { //---- find the stop id on the route ---- for (i=nstop; i <= line_ptr->Stops (); i++) { if (line_ptr->Stop (i) == stop) break; } if (i > line_ptr->Stops ()) { if (stop == first_stop) nrun++; nstop = i = 1; } } //---- add the time point ---- line_ptr->Schedule (nrun, i, time); num++; //---- interpolate time points ---- if (i > nstop) { if (nstop == 1) { Check_Message ("Stop %d is Not the First Stop for Route %d", file->Stop (), route); continue; } index = i; tim = line_ptr->Schedule (nrun, nstop-1); time = (time - tim) / (index - nstop + 1); for (i=nstop; i < index; i++) { tim += time; line_ptr->Schedule (nrun, i, tim); npoints++; } nstop = index; } nstop++; } End_Progress (); file->Close (); line_data.Schedule_Records (Progress_Count ()); Print (2, "Number of %s Records = %d", file->File_Type (), Progress_Count ()); if (num && num != Progress_Count ()) { Print (1, "Number of Transit Schedule Data Records = %d", num); } if (npoints > 0) { Print (1, "Number of Interpolated Time Points = %d", npoints); } if (num > 0) Network_Data_True (TRANSIT_SCHEDULE); return; mem_error: Error ("Insufficient Memory for %d Runs on Route %d", nrun, last_route); }
void Ide::FindInFiles(bool replace) { CodeEditor::FindReplaceData d = editor.GetFindReplaceData(); CtrlRetriever rf; rf(ff.find, d.find) (ff.replace, d.replace) (ff.ignorecase, d.ignorecase) (ff.samecase, d.samecase) (ff.wholeword, d.wholeword) (ff.wildcards, d.wildcards) (ff.regexp, d.regexp) ; WriteList(ff.find, d.find_list); WriteList(ff.replace, d.replace_list); ff.Sync(); if(IsNull(~ff.folder)) ff.folder <<= GetUppDir(); ff.style <<= STYLE_NO_REPLACE; ff.Sync(); ff.itext = editor.GetI(); ff.Setup(replace); int c = ff.Execute(); ff.find.AddHistory(); ff.replace.AddHistory(); rf.Retrieve(); d.find_list = ReadList(ff.find); d.replace_list = ReadList(ff.replace); editor.SetFindReplaceData(d); if(c == IDOK) { ffound.HeaderTab(2).SetText("Source line"); Renumber(); ff.find.AddHistory(); ff.files.AddHistory(); ff.folder.AddHistory(); ff.replace.AddHistory(); Progress pi("Found %d files to search."); pi.AlignText(ALIGN_LEFT); Index<String> files; if(ff.workspace) { const Workspace& wspc = GetIdeWorkspace(); for(int i = 0; i < wspc.GetCount(); i++) SearchForFiles(files, GetFileFolder(PackagePath(wspc[i])), ~ff.files, ~ff.readonly, pi); } else SearchForFiles(files, NormalizePath(~~ff.folder, GetUppDir()), ~ff.files, ~ff.readonly, pi); if(!pi.Canceled()) { String pattern; RegExp rx, *regexp = NULL; if(ff.regexp) { rx.SetPattern(~ff.find); regexp = ℞ pattern = "dummy"; } else if(ff.wildcards) { String q = ~ff.find; for(const char *s = q; *s; s++) if(*s == '\\') { s++; if(*s == '\0') break; pattern.Cat(*s); } else switch(*s) { case '*': pattern.Cat(WILDANY); break; case '?': pattern.Cat(WILDONE); break; case '%': pattern.Cat(WILDSPACE); break; case '#': pattern.Cat(WILDNUMBER); break; case '$': pattern.Cat(WILDID); break; default: pattern.Cat(*s); } } else pattern = ~ff.find; pi.SetTotal(files.GetCount()); ShowConsole2(); ffound.Clear(); pi.SetPos(0); int n = 0; for(int i = 0; i < files.GetCount(); i++) { pi.SetText(files[i]); if(pi.StepCanceled()) break; if(!IsNull(pattern)) { if(!SearchInFile(files[i], pattern, ff.wholeword, ff.ignorecase, n, regexp)) break; } else { ErrorInfo f; f.file = files[i]; f.lineno = 1; f.linepos = 0; f.kind = 0; f.message = files[i]; ffound.Add(f.file, 1, f.message, RawToValue(f)); ffound.Sync(); n++; } } if(!IsNull(pattern)) ffound.Add(Null, Null, AsString(n) + " occurrence(s) have been found."); else ffound.Add(Null, Null, AsString(n) + " matching file(s) have been found."); ffound.HeaderTab(2).SetText(Format("Source line (%d)", ffound.GetCount())); } } }
Router::Router (void) : Demand_Service (), Problem_Service () { Program ("Router"); Version ("4.0.71"); Title ("Network Path Builder"); Network_File required_network [] = { NODE, LINK, LANE_CONNECTIVITY, PARKING, ACTIVITY_LOCATION, PROCESS_LINK, END_NETWORK }; Network_File optional_network [] = { DIRECTORY, LANE_USE, TOLL, TURN_PROHIBITION, TRANSIT_STOP, TRANSIT_FARE, TRANSIT_ROUTE, TRANSIT_SCHEDULE, END_NETWORK }; Demand_File optional_demand [] = { HOUSEHOLD, TRIP, ACTIVITY, LINK_DELAY, VEHICLE, VEHICLE_TYPE, END_DEMAND }; char *keys [] = { HOUSEHOLD_LIST, HOUSEHOLD_RECORD_FILE, PARKING_PENALTY_FILE, TRANSIT_PENALTY_FILE, TIME_OF_DAY_FORMAT, PLAN_FILE, PLAN_FORMAT, NEW_PLAN_FILE, NEW_PLAN_FORMAT, NODE_LIST_PATHS, ROUTE_SELECTED_MODES, ROUTE_SELECTED_PURPOSES, ROUTE_WITH_SPECIFIED_MODE, ROUTE_FROM_SPECIFIED_LOCATIONS, ROUTE_TO_SPECIFIED_LOCATIONS, ROUTE_AT_SPECIFIED_TIMES, ROUTE_BY_TIME_INCREMENT, UPDATE_PLAN_RECORDS, PRINT_UPDATE_WARNINGS, IGNORE_VEHICLE_ID, LIMIT_PARKING_ACCESS, WALK_PATH_DETAILS, ADJUST_ACTIVITY_SCHEDULE, IGNORE_ACTIVITY_DURATIONS, IGNORE_TIME_CONSTRAINTS, END_TIME_CONSTRAINT, IGNORE_ROUTING_PROBLEMS, INTERPOLATE_LINK_DELAYS, PERCENT_RANDOM_IMPEDANCE, RANDOM_NUMBER_SEED, HOUSEHOLD_TYPE_SCRIPT, WALK_SPEED, BICYCLE_SPEED, WALK_TIME_VALUE, BICYCLE_TIME_VALUE, FIRST_WAIT_VALUE, TRANSFER_WAIT_VALUE, VEHICLE_TIME_VALUE, DISTANCE_VALUE, COST_VALUE, LEFT_TURN_PENALTY, RIGHT_TURN_PENALTY, U_TURN_PENALTY, TRANSFER_PENALTY, STOP_WAITING_PENALTY, STATION_WAITING_PENALTY, BUS_BIAS_FACTOR, BUS_BIAS_CONSTANT, RAIL_BIAS_FACTOR, RAIL_BIAS_CONSTANT, MAX_WALK_DISTANCE, MAX_BICYCLE_DISTANCE, MAX_WAIT_TIME, MIN_WAIT_TIME, MAX_NUMBER_OF_TRANSFERS, MAX_NUMBER_OF_PATHS, MAX_PARK_RIDE_PERCENTAGE, MAX_KISS_RIDE_PERCENTAGE, KISS_RIDE_TIME_FACTOR, KISS_RIDE_STOP_TYPES, MAX_KISS_RIDE_DROPOFF_WALK, MAX_LEGS_PER_PATH, ADD_WAIT_TO_TRANSIT_LEG, FARE_CLASS_DISTRIBUTION, PARKING_HOURS_BY_PURPOSE, LOCAL_ACCESS_DISTANCE, LOCAL_FACILITY_TYPE, MAX_CIRCUITY_RATIO, MIN_CIRCUITY_DISTANCE, MAX_CIRCUITY_DISTANCE, MAX_LINK_DELAY_ERRORS, LINK_DELAY_UPDATE_RATE, LINK_DELAY_VOL_FACTOR, LINK_DELAY_START_TIME, LINK_DELAY_END_TIME, EQUATION_PARAMETERS_x, NEW_PROBLEM_FILE, NEW_PROBLEM_FORMAT, MAX_ROUTING_PROBLEMS, ARCVIEW_PROBLEM_DUMP, PROBLEM_DUMP_TYPE, PERCENT_PROBLEMS_DUMPED, NEW_PATH_ATTRIBUTE_FILE, NULL }; char *reports [] = { "HOUSEHOLD_TYPE_SCRIPT", "HOUSEHOLD_TYPE_STACK", "FARE_DATA_REPORT", NULL }; Required_Network_Files (required_network); Optional_Network_Files (optional_network); Optional_Demand_Files (optional_demand); Key_List (keys); Report_List (reports); Enable_Partitions (true); Check_Data (true); Renumber (true); Max_Problems (100000); nhh_list = nhh_proc = nrecord = nprocess = ntrips = num_trips = update_rate = nupdates = 0; random_imped = max_tod = new_mode = nmagic = ntransit = nroute = tot_trips = 0; last_traveler = last_trip = last_time = last_xfer = last_wait = last_acc = 0; nlegs = nlegs_transit = nlegs_auto = 0; vol_factor = 1; limit_access = node_flag = true; purpose_flag = ignore_veh_flag = reset_veh_flag = stop_imp_flag = skim_flag = warn_flag = false; walk_net = bike_net = drive_net = loc_net = transit_net = fare_flag = wait_leg_flag = false; hhlist_flag = hhold_flag = hhrec_flag = trip_flag = ignore_time = update_flag = tod_flag = false; random_flag = walk_flag = bike_flag = walk_detail = walk_active = local_flag = false; save_plans = problem_flag = ignore_errors = delay_flag = zero_flag = old_plan_flag = false; mode_flag = park_ride_flag = distance_flag = wait_flag = toll_flag = turn_flag = false; time_flag = dist_flag = length_flag = wait_time_flag = use_flag = dump_flag = veh_flag = false; activity_flag = select_od = select_org = select_des = select_time = park_imp_flag = false; rail_bias_flag = bus_bias_flag = park_hours_flag = fare_class_flag = sel_dump_flag = false; attribute_flag = interpolate_flag = adjust_flag = duration_flag = false; first_ptr = last_ptr = NULL; walk_speed = 1.0; bike_speed = 4.0; value_walk = 20; value_bike = 15; value_wait = 20; value_xfer = 20; value_time = 10; value_distance = 0; value_cost = 0; value_roll = 3; //---- 1/8 resolution ---- value_round = (1 << (value_roll-1)); offset_roll = 11; //---- 1/2048 resolution ---- offset_round = (1 << (offset_roll-1)); time_period = 900; //---- 15 minutes ---- max_walk = 2000; max_bike = 10000; max_wait = 60; min_wait = 0; max_transfers = 3; max_paths = 4; max_parkride = 50; max_kissride = 35; kissride_factor = 250; kissride_walk = 100; rail_bias = 100; rail_constant = 0; bus_bias = 100; bus_constant = 0; park_hours = 0; xfer_imped = 0; stop_imped = 0; station_imped = 0; left_imped = 0; right_imped = 0; uturn_imped = 0; traveler_class = CASH; local_type = EXTERNAL; local_distance = 2000; end_time = 0; //---- 0 minutes ---- leg_check = 1000; min_distance = 2000; max_distance = 20000; max_ratio = 0; dump_type = 0; percent_dump = Round (100); memset (&attribute_data, '\0', sizeof (attribute_data)); default_vehicle.ID (1); default_vehicle.Type (CAR); default_vehicle.Sub_Type (0); default_vehicle.Passengers (0); default_vehicle.Household (1); default_vehicle.Location (1); }
bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) { bool bChanged(false); CSingleLock lock(m_critSection); int iCurSize = size(); CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if (!database || !database->Open()) return false; /* go through the channel list and check for updated or new channels */ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++) { CPVRChannel *channel = channels.at(iChannelPtr).channel; int iChannelNumber = channels.at(iChannelPtr).iChannelNumber; if (!channel) continue; CPVRChannel *realChannel = (CPVRChannel *) CPVRManager::GetChannelGroups()->GetGroupAll(m_bRadio)->GetByClient(channel->UniqueID(), channel->ClientID()); if (!realChannel) continue; if (!IsGroupMember(realChannel)) { AddToGroup(realChannel, iChannelNumber, false); bChanged = true; m_bChanged = true; CLog::Log(LOGINFO,"PVRChannelGroup - %s - added %s channel '%s' at position %d in group '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", realChannel->ChannelName().c_str(), iChannelNumber, GroupName().c_str()); } } /* check for deleted channels */ unsigned int iSize = size(); for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++) { CPVRChannel *channel = (CPVRChannel *) GetByIndex(iChannelPtr); if (!channel) continue; if (channels.GetByClient(channel->UniqueID(), channel->ClientID()) == NULL) { /* channel was not found */ CLog::Log(LOGINFO,"PVRChannelGroup - %s - deleted %s channel '%s' from group '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str(), GroupName().c_str()); /* remove this channel from all non-system groups */ RemoveFromGroup(channel); m_bChanged = true; bChanged = true; iChannelPtr--; iSize--; } } if (bChanged) { /* sort by client channel number if this is the first time */ if (iCurSize == 0) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. new channels were added at the back, so they'll get the highest numbers */ Renumber(); return Persist(); } return true; }
bool Network_Service::Line_Processing (Db_File *fh) { static int id, nstops, stop_num; int zone; bool stop_flag; Line_Data *line_ptr = NULL; Line_File *file = (Line_File *) fh; stop_flag = Network_Data_Flag (TRANSIT_STOP); //---- process a header line ---- if (!file->Nest ()) { id = file->Route (); if (id == 0) return (false); if (id < 1) { return (Check_Message ("Transit Route ID %d is Out of Range", id)); } line_ptr = line_data.New_Record (true); if (line_ptr == NULL) goto mem_error; line_ptr->Route (id); stop_num = 1; nstops = file->Stops (); if (nstops < 2) { return (Check_Message ("Number of Stops %d on Route %d is Out of Range", nstops, id)); } if (!line_ptr->Stops (nstops)) { Error ("Insufficient Memory for %d Stops on Router %d", nstops, id); } line_ptr->Mode (Transit_Code (file->Mode ())); line_ptr->Null_Name (); line_ptr->Null_Notes (); if (Notes_Name_Flag ()) { char *str_ptr = file->Name (); if (str_ptr != NULL && *str_ptr != '\0') { line_ptr->Name (str_ptr); } str_ptr = file->Notes (); if (str_ptr != NULL && *str_ptr != '\0') { line_ptr->Notes (str_ptr); } } } else { line_ptr = line_data.New_Record (false); if (line_ptr == NULL) goto mem_error; //---- process a stop record ---- int stop = file->Stop (); if (stop_flag) { int index = stop_data.Get_Index (stop); if (index == 0) { return (Check_Message ("Transit Stop %d on Route %d was Not Found in the Stop File", stop, id)); } if (Renumber ()) stop = index; } line_ptr->Stop (stop_num, stop); zone = file->Zone (); if (Num_Fare_Zones () > 0 && (zone < 1 || zone > Num_Fare_Zones ())) { if (zone != 0 || !Zero_Fare_Zone ()) { Warning ("Transit Zone %d on Route %d is Out of Range (1..%d)", zone, id, Num_Fare_Zones ()); if (zone == 0) Zero_Fare_Zone (true); } } line_ptr->Zone (stop_num, zone); line_ptr->Time_Flag (stop_num, file->Time_Flag ()); if (stop_num == nstops) { return (true); } else { stop_num++; return (false); } } return (false); mem_error: Error ("Insuffienct Memory for Transit Line Data"); return (false); }
bool Network_Service::Phasing_Processing (Db_File *fh) { bool node_flag, link_flag, timing_flag, detector_flag; int lvalue, index, node_num, num; char *svalue, *ptr; Link_Data *link_ptr = NULL; Phasing_Data *phasing_ptr = NULL; Timing_Data timing_rec; Phasing_File *file = (Phasing_File *) fh; node_flag = Network_Data_Flag (NODE); link_flag = Network_Data_Flag (LINK); timing_flag = Network_Data_Flag (TIMING_PLAN); detector_flag = Network_Data_Flag (DETECTOR); //---- reserve memory ---- if (phasing_data.Max_Records () == 0) { if (!phasing_data.Max_Records (file->Num_Records ())) goto mem_error; } //---- read and save the data ---- phasing_ptr = phasing_data.New_Record (); if (phasing_ptr == NULL) goto mem_error; phasing_ptr->Reset (); node_num = file->Node (); if (node_num == 0) return (false); //---- store the node ---- if (node_flag) { num = node_data.Get_Index (node_num); if (num == 0) { return (Check_Message ("Phasing Plan Node %d was Not Found in the Node file", node_num)); } if (!Renumber ()) { num = node_num; } } else { num = node_num; } phasing_ptr->Node (num); //---- check the timing plan ---- if (timing_flag) { timing_rec.Timing (file->Timing ()); timing_rec.Phase (file->Phase ()); if (timing_data.Get_Index (&timing_rec) == 0) { return (Check_Message ("Timing Plan %d-%d was Not Found in the Timing Plan file", file->Timing (), file->Phase ())); } } phasing_ptr->Timing (file->Timing ()); phasing_ptr->Phase (file->Phase ()); //---- check/convert the in-link number ---- lvalue = file->In_Link (); if (lvalue <= 0) goto link_error; if (link_flag) { index = link_data.Get_Index (lvalue); if (index == 0) goto link_error; link_ptr = link_data [index]; if (!Renumber ()) { index = lvalue; } phasing_ptr->In_Link (index); if (link_ptr->Anode () == num) { phasing_ptr->In_Dir (1); index = link_ptr->BA_Dir (); } else if (link_ptr->Bnode () == num) { phasing_ptr->In_Dir (0); index = link_ptr->AB_Dir (); } else { index = 0; } if (index == 0) goto link_error; } else { phasing_ptr->In_Link (lvalue); } //---- check/convert the out-link number ---- lvalue = file->Out_Link (); if (lvalue <= 0) goto link_error; if (link_flag) { index = link_data.Get_Index (lvalue); if (index == 0) goto link_error; link_ptr = link_data [index]; if (!Renumber ()) { index = lvalue; } phasing_ptr->Out_Link (index); if (link_ptr->Bnode () == num) { phasing_ptr->Out_Dir (1); index = link_ptr->BA_Dir (); } else if (link_ptr->Anode () == num) { phasing_ptr->Out_Dir (0); index = link_ptr->AB_Dir (); } else { index = 0; } if (index == 0) goto link_error; } else { phasing_ptr->Out_Link (lvalue); } //---- convert the protection code ---- phasing_ptr->Protection (Protection_Code (file->Protection ())); //---- process the detectors ---- svalue = file->Detectors (); if (*svalue == '\0' || atoi (svalue) == 0) { phasing_ptr->Num_Detectors (0); return (true); } num = 1; ptr = svalue; while ((ptr = strchr (ptr, '/')) != NULL) { num++; ptr++; } if (!phasing_ptr->Num_Detectors (num)) { Error ("Insufficient Memory for %d Detectors on Phasing Plan %d", num, Progress_Count ()); } num = 0; while (svalue != NULL) { ptr = strchr (svalue, '/'); if (ptr != NULL) { *ptr++ = '\0'; } lvalue = atoi (svalue); if (lvalue <= 0) break; num++; if (detector_flag) { index = detector_data.Get_Index (lvalue); if (index == 0) { return (Check_Message ("Phasing Plan Detector %d was Not Found in the Detector file", lvalue)); } if (!Renumber ()) { index = lvalue; } phasing_ptr->Detector (num, index); } else { phasing_ptr->Detector (num, lvalue); } svalue = ptr; } if (phasing_ptr->Num_Detectors () != num) { return (Check_Message ("Phasing Plan %d Detector Numbers are Not Valid", Progress_Count ())); } return (true); link_error: return (Check_Message ("Phasing Plan Node %d Link %d was Not Found", node_num, lvalue)); mem_error: Error ("Insufficient Memory for Phasing Plan Data"); return (false); }