static Object P_Chown(Object fn, Object uid, Object gid) { #ifndef WIN32 if (chown(Get_Strsym(fn), Get_Integer(uid), Get_Integer(gid)) == -1) Raise_System_Error1("~s: ~E", fn); #endif return Void; }
static Object P_Create_Pixmap (Object d, Object w, Object h, Object depth) { Display *dpy; Drawable dr = Get_Drawable (d, &dpy); return Make_Pixmap (dpy, XCreatePixmap (dpy, dr, Get_Integer (w), Get_Integer (h), Get_Integer (depth))); }
static Object P_Create_Cursor (Object srcp, Object maskp, Object x, Object y, Object f, Object b) { Pixmap sp = Get_Pixmap (srcp), mp; Display *d = PIXMAP(srcp)->dpy; mp = EQ(maskp, Sym_None) ? None : Get_Pixmap (maskp); return Make_Cursor (d, XCreatePixmapCursor (d, sp, mp, Get_Color (f), Get_Color (b), Get_Integer (x), Get_Integer (y))); }
static Object P_Create_Glyph_Cursor (Object srcf, Object srcc, Object maskf, Object maskc, Object f, Object b) { Font sf = Get_Font (srcf), mf; Display *d = FONT(srcf)->dpy; mf = EQ(maskf, Sym_None) ? None : Get_Font (maskf); return Make_Cursor (d, XCreateGlyphCursor (d, sf, mf, Get_Integer (srcc), mf == None ? 0 : Get_Integer (maskc), Get_Color (f), Get_Color (b))); }
static Object P_Create_Bitmap_From_Data (Object win, Object data, Object pw, Object ph) { register unsigned int w, h; Check_Type (win, T_Window); Check_Type (data, T_String); w = Get_Integer (pw); h = Get_Integer (ph); if (w * h > 8 * STRING(data)->size) Primitive_Error ("bitmap too small"); return Make_Pixmap (WINDOW(win)->dpy, XCreateBitmapFromData (WINDOW(win)->dpy, WINDOW(win)->win, STRING(data)->data, w, h)); }
static Object P_Create_Window (Object parent, Object x, Object y, Object width, Object height, Object border_width, Object attr) { unsigned long mask; Window win; Check_Type (parent, T_Window); mask = Vector_To_Record (attr, Set_Attr_Size, Sym_Set_Attr, Set_Attr_Rec); if ((win = XCreateWindow (WINDOW(parent)->dpy, WINDOW(parent)->win, Get_Integer (x), Get_Integer (y), Get_Integer (width), Get_Integer (height), Get_Integer (border_width), CopyFromParent, CopyFromParent, CopyFromParent, mask, &SWA)) == 0) Primitive_Error ("cannot create window"); return Make_Window (1, WINDOW(parent)->dpy, win); }
static Object P_Mkdir(Object fn, Object mode) { #ifndef WIN32 if (mkdir(Get_Strsym(fn), Get_Integer(mode)) == -1) Raise_System_Error1("~s: ~E", fn); #endif return Void; }
void IntControl::Read_Deletes (void) { int node; //---- store the delete data ---- Show_Message ("Reading %s -- Record", delete_file.File_Type ()); Set_Progress (); while (delete_file.Read ()) { Show_Progress (); Get_Integer (delete_file.Record (), &node); if (node == 0) continue; if (!delete_node.Add (node)) { Error ("Adding Delete Node Record"); } } End_Progress (); delete_file.Close (); Print (2, "Number of %s Records = %d", delete_file.File_Type (), Progress_Count ()); }
static Object P_Write_Bitmap_File (int argc, Object *argv) { Pixmap pm; int ret, xhot = -1, yhot = -1; pm = Get_Pixmap (argv[1]); if (argc == 5) Primitive_Error ("both x-hot and y-hot must be specified"); if (argc == 6) { xhot = Get_Integer (argv[4]); yhot = Get_Integer (argv[5]); } Disable_Interrupts; ret = XWriteBitmapFile (PIXMAP(argv[1])->dpy, Get_Strsym (argv[0]), pm, Get_Integer (argv[2]), Get_Integer (argv[3]), xhot, yhot); Enable_Interrupts; return Bits_To_Symbols ((unsigned long)ret, 0, Bitmapstatus_Syms); }
GLOBAL int Expr_Eval_Int(const char *str, const parser_extra* f, int *result) { int err; expr_val e; e = Expr_Eval(str, f, &err); if (err == EXPR_EVAL_SUCCESS) *result = Get_Integer(e); return err; }
static Object P_Translate_Coordinates (Object src, Object x, Object y, Object dst) { int rx, ry; Window child; Object l, t, z; GC_Node3; Check_Type (src, T_Window); Check_Type (dst, T_Window); if (!XTranslateCoordinates (WINDOW(src)->dpy, WINDOW(src)->win, WINDOW(dst)->win, Get_Integer (x), Get_Integer (y), &rx, &ry, &child)) return False; l = t = P_Make_List (Make_Integer (3), Null); GC_Link3 (l, t, dst); Car (t) = Make_Integer (rx); t = Cdr (t); Car (t) = Make_Integer (ry), t = Cdr (t); z = Make_Window (0, WINDOW(dst)->dpy, child); Car (t) = z; GC_Unlink; return l; }
void CheckSurvey::Survey_Weights (void) { int id, count; double weight; char *str_ptr; Household_Data *household_ptr; count = 0; //---- read the survey household weights ---- Show_Message ("Reading %s -- Record", weight_file.File_Type ()); Set_Progress (50000); while (weight_file.Read ()) { str_ptr = weight_file.Record (); //---- check the household id ---- str_ptr = Get_Integer (str_ptr, &id); if (id <= 0) continue; Show_Progress (); household_ptr = survey_hh_data.Get (id); if (household_ptr == NULL) continue; Get_Double (str_ptr, &weight); household_ptr->Location ((int) (weight + random.Probability ())); count++; } End_Progress (); weight_file.Close (); Print (2, "Number of %s Records = %d", weight_file.File_Type (), Progress_Count ()); if (count != Progress_Count ()) { Print (1, "Number of Household Weights Kept = %d", count); } }
void PlanSum::Read_HHList (void) { int nfile, hhold; //---- read the household list files ---- for (nfile=0; ; nfile++) { if (!hhlist_file.Open (nfile)) break; if (hhlist_file.Extend ()) { Show_Message ("Reading %s %s -- Record", hhlist_file.File_Type (), hhlist_file.Extension ()); } else { Show_Message ("Reading %s -- Record", hhlist_file.File_Type ()); } Set_Progress (); //---- store the household list ---- while (hhlist_file.Read ()) { Show_Progress (); Get_Integer (hhlist_file.Record (), &hhold); if (hhold <= 0) continue; if (!hhold_list.Add (hhold)) { Error ("Adding Household %d", hhold); } } End_Progress (); hhlist_file.Close (); } hhold = hhold_list.Num_Records (); hhold_list.Max_Records (hhold); Print (2, "Number of Household List Records = %d", hhold); }
void ConvertTours::Read_HHList (void) { int hhold; Show_Message ("Reading %s -- Record", hhlist_file.File_Type ()); Set_Progress (100000); //---- read the household list file ---- while (hhlist_file.Read ()) { Show_Progress (); Get_Integer (hhlist_file.Record (), &hhold); if (!hhold_list.Add (hhold)) { Error ("Adding Household List Record"); } if (hhold > max_hhlist) max_hhlist = hhold; } End_Progress (); hhlist_file.Close (); }
int Dir (void) { return (Get_Integer (dir)); }
int Link (void) { return (Get_Integer (link)); }
int Route (void) { return (Get_Integer (route)); }
int Lane (void) { return (Get_Integer (lane)); }
int Mode (void) { return (Get_Integer (mode)); }
int Trip (void) { return (Get_Integer (trip)); }
int Person (void) { return (Get_Integer (person)); }
void HHList::Program_Control (void) { int i; char *str_ptr, *format_ptr, buffer [STRING_BUFFER]; Print (1); //---- open the input data file ---- str_ptr = Get_Control_String (HOUSEHOLD_LIST); if (str_ptr != NULL) { list_file.File_Type ("Household List"); list_file.Open (Project_Filename (str_ptr)); list_flag = true; } else { str_ptr = Get_Control_String (HOUSEHOLD_FILE); if (str_ptr != NULL) { input_file.File_Type ("Household File"); format_ptr = Get_Control_String (HOUSEHOLD_FORMAT); } else { str_ptr = Get_Control_String (TRIP_FILE); if (str_ptr != NULL) { input_file.File_Type ("Trip File"); format_ptr = Get_Control_String (TRIP_FORMAT); two_flag = (Get_Control_String (ACTIVITY_FILE) != NULL); } else { str_ptr = Get_Control_String (ACTIVITY_FILE); if (str_ptr != NULL) { input_file.File_Type ("Activity File"); format_ptr = Get_Control_String (ACTIVITY_FORMAT); } else { Error ("A Household List, Household File, Trip File or Activity File is required"); } } } if (format_ptr != NULL) { input_file.File_Format (format_ptr); } input_file.Open (Project_Filename (str_ptr)); } //---- read two files ---- if (two_flag) { str_ptr = Get_Control_String (ACTIVITY_FILE); input2_file.File_Type ("Activity File"); if (format_ptr != NULL) { input2_file.File_Format (format_ptr); } input2_file.Open (Project_Filename (str_ptr)); } //---- read the number of split files ---- str_ptr = Get_Control_String (NUM_SPLIT_FILES); if (str_ptr == NULL) goto control_error; Get_Integer (str_ptr, &num_files); if (num_files < 1 || num_files > 200) { Error ("Number of Split Files %d is Out of Range (1..200)", num_files); } //---- open the output files ---- str_ptr = Get_Control_String (NEW_HOUSEHOLD_LIST); if (str_ptr == NULL) goto control_error; output_file = new Db_File * [num_files]; if (output_file == NULL) { Error ("Insufficient Memory for New Household Lists"); } Print (1); for (i=0; i < num_files; i++) { str_fmt (buffer, sizeof (buffer), "%s.t%c%c", str_ptr, ('A' + (i / 26)), ('A' + (i % 26))); output_file [i] = new Db_File (Db_File::CREATE); output_file [i]->File_Type ("New Household List"); if (!output_file [i]->Open (Project_Filename (buffer))) { File_Error ("Creating Household List", output_file [i]->Filename ()); } } Print (2, "Number of Split Files = %d", num_files); //---- random number seed ---- str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } Print (1, "Random Number Seed = %d", random.Seed ()); return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
int Impedance (void) { return (Get_Integer (impedance)); }
int Use (void) { return (Get_Integer (use)); }
int Toll (void) { return (Get_Integer (toll)); }
int Tour (void) { return (Get_Integer (tour)); }
void Demand_Service::Program_Control (void) { int max_errors; char *str_ptr, *format_ptr; Format_Type default_format, file_format, demand_format; Access_Type access; //---- open network files ---- Network_Service::Program_Control (); demand_format = default_format = Demand_Format (); File_Data *file = demand_file; //---- get the default demand file format ---- format_ptr = Get_Control_String (DEMAND_FILE_FORMAT); if (format_ptr != NULL) { demand_format = Format_Code (format_ptr); if (demand_format != default_format) { Print (2, "Demand File Format = %s", format_ptr); } } else { demand_format = default_format; } Demand_Format (demand_format); //---- open the files ---- for (int i=0; i < END_DEMAND; i++, file++) { if (file->flag || file->option) { //---- initialize overlaid data classes ---- if (i == LINK_DELAY || i == NEW_LINK_DELAY) { if (dir_array == NULL) { dir_array = (Dir_Array *) new TTime_Array (); } if (connect_array == NULL) { connect_array = (Connect_Array *) new Connect_Time_Array (); } } else if (i == PERFORMANCE || i == NEW_PERFORMANCE) { if (dir_array == NULL) { dir_array = (Dir_Array *) new Performance_Array (); } if (connect_array == NULL) { connect_array = (Connect_Array *) new Connect_Time_Array (); } } else if (i == RIDERSHIP || i == NEW_RIDERSHIP) { if (line_array == NULL) { line_array = (Line_Array *) new Rider_Array (); } } //---- read the key ---- str_ptr = Get_Control_String (file->key); if (str_ptr == NULL) { if (file->flag) goto control_error; } else { Print (1); file->flag = true; format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { file_format = Format_Code (format_ptr); } else { file_format = demand_format; } access = file->access; switch (i) { case HOUSEHOLD: case NEW_HOUSEHOLD: file->file = new Household_File (Project_Filename (str_ptr), access, file_format); break; case POPULATION: case NEW_POPULATION: file->file = new Population_File (Project_Filename (str_ptr), access, file_format); break; case LINK_DELAY: case PERFORMANCE: file->file = new Delay_File (Project_Filename (str_ptr), access, file_format); if (((Db_Base *) file->file)->Dbase_Format () == VERSION3) { if (i == LINK_DELAY) { ttime_data.Period_Size (((Delay_File *) file->file)->Increment ()); connect_time.Period_Size (ttime_data.Period_Size ()); } else { performance_data.Period_Size (((Delay_File *) file->file)->Increment ()); connect_time.Period_Size (performance_data.Period_Size ()); } } //---- max link delay errors ---- str_ptr = Get_Control_String (MAX_LINK_DELAY_ERRORS); if (str_ptr != NULL) { Get_Integer (str_ptr, &max_errors); if (max_delay_errors < 0) { Error ("Maximum Link Delay Errors %d is Out of Range", max_errors); } Print (1, "Maximum Number of Link Delay Errors = %d", max_errors); Max_Delay_Errors (max_errors); } break; case NEW_LINK_DELAY: case NEW_PERFORMANCE: file->file = new Delay_File (Project_Filename (str_ptr), access, file_format, Time_Increment ()); break; case RIDERSHIP: case NEW_RIDERSHIP: file->file = new Ridership_File (Project_Filename (str_ptr), access, file_format); break; case VEHICLE_TYPE: case NEW_VEHICLE_TYPE: file->file = new Veh_Type_File (Project_Filename (str_ptr), access, file_format); break; case VEHICLE: case NEW_VEHICLE: file->file = new Vehicle_File (Project_Filename (str_ptr), access, file_format); //---- sort vehicles ---- if (i == VEHICLE) { if (Get_Control_String (SORT_VEHICLES) != NULL) { sort_flag = Get_Control_Flag (SORT_VEHICLES); } if (sort_flag) { Print (1, "Vehicle File will be Sorted by Vehicle ID"); } else { Print (1, "Vehicle File is Sorted by Vehicle ID"); } } break; case ACTIVITY: case NEW_ACTIVITY: str_ptr = Project_Filename (str_ptr); if (Enable_Partitions ()) { Activity_File * act_file = new Activity_File (access, file_format); file->file = act_file; if (Partition ()) { act_file->Filename (str_ptr, Partition_Number ()); } else { act_file->Filename (str_ptr); } Print_Filename (1, act_file->File_Type (), act_file->Groupname ()); if (!act_file->Open (0)) { File_Error (act_file->File_Type (), act_file->Filename ()); } } else { file->file = new Activity_File (str_ptr, access, file_format); } break; case TRIP: case NEW_TRIP: str_ptr = Project_Filename (str_ptr); if (Enable_Partitions ()) { Trip_File * trip_file = new Trip_File (access, file_format); file->file = trip_file; if (Partition ()) { trip_file->Filename (str_ptr, Partition_Number ()); } else { trip_file->Filename (str_ptr); } Print_Filename (1, trip_file->File_Type (), trip_file->Groupname ()); if (!trip_file->Open (0)) { File_Error (trip_file->File_Type (), trip_file->Filename ()); } } else { file->file = new Trip_File (str_ptr, access, file_format); } break; case BOUNDARY_SPEED: case NEW_BOUNDARY_SPEED: file->file = new Boundary_File (Project_Filename (str_ptr), access, file_format); break; } } } } Demand_Format (default_format); control_flag = true; return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
int Area_Type (void) { return (Get_Integer (area)); }
void DynusTNet::Program_Control (void) { int i, lvalue; char *str_ptr, buffer [STRING_BUFFER], project [STRING_BUFFER]; //---- create the network files ---- Demand_Service::Program_Control (); //---- get the time of day format ---- str_ptr = Get_Control_String (TIME_OF_DAY_FORMAT); if (str_ptr == NULL) { str_ptr = "24_HOUR_CLOCK"; } if (!time_range.Format (str_ptr)) { Error ("Time of Day Format %s was Unrecognized", str_ptr); } Print (2, "Time of Day Format = %s", str_ptr); //---- get the select time period ---- str_ptr = Get_Control_String (SELECT_TIME_PERIOD); if (str_ptr != NULL) { Print (2, "Select Time Period = %s", str_ptr); if (!time_range.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } } else { time_range.Add_Ranges ("0:00..24:00"); } //---- saturation flow rates ---- str_ptr = Get_Control_String (SATURATION_FLOW_RATES); i = 0; while (str_ptr != NULL && i < EXTERNAL) { str_ptr = Get_Integer (str_ptr, &lvalue); if (lvalue == 0) break; if (lvalue < 1000 || lvalue > 3000) { Error ("Saturation Flow Rate %d is Out of Range (1000..3000)", lvalue); } sat_flow [++i] = lvalue; } if (i) { for (; i <= EXTERNAL; i++) { sat_flow [i] = lvalue; } } Print (2, "Saturation Flow Rates = "); for (i=1; i <= EXTERNAL; i++) { Print (0, "%d ", sat_flow [i]); } //---- service flow rates ---- str_ptr = Get_Control_String (SERVICE_FLOW_RATES); i = 0; while (str_ptr != NULL && i < EXTERNAL) { str_ptr = Get_Integer (str_ptr, &lvalue); if (lvalue == 0) break; if (lvalue < 1000 || lvalue > 3000) { Error ("Service Flow Rate %d is Out of Range (1000..3000)", lvalue); } ser_flow [++i] = lvalue; } if (i) { for (; i <= EXTERNAL; i++) { ser_flow [i] = lvalue; } } Print (2, "Service Flow Rates = "); for (i=1; i <= EXTERNAL; i++) { Print (0, "%d ", ser_flow [i]); } //---- open the DynusT project name ---- str_ptr = Get_Control_String (DYNUST_PROJECT_NAME); if (str_ptr == NULL) { str_ptr = "ProjectName"; } Print (2, "DynusT Project Name = %s", str_ptr); str_cpy (project, sizeof (project), str_ptr); //---- open the DynusT network directory ---- str_ptr = Get_Control_String (DYNUST_NETWORK_DIRECTORY); if (str_ptr == NULL) goto control_error; str_cpy (net_dir, sizeof (net_dir), Project_Filename (str_ptr)); Print (2, "DynusT Network Directory = %s", net_dir); //---- project dws ---- dws_file.File_Type ("DynusT Project File"); str_fmt (buffer, sizeof (buffer), "%s/%s.dws", net_dir, project); dws_file.Create (buffer); fprintf (dws_file.File (), "VERSION = \"%3.1lf\"\nORIGIN = \"BOTTOM_LEFT\"\n", 1.3); dws_file.Close (); //---- xy.dat ---- xy_file.File_Type ("DynusT Node Coordinate File"); str_fmt (buffer, sizeof (buffer), "%s/xy.dat", net_dir); xy_file.Create (buffer); //---- network.dat ---- net_file.File_Type ("DynusT Network File"); str_fmt (buffer, sizeof (buffer), "%s/network.dat", net_dir); net_file.Create (buffer); if (Network_File_Flag (SHAPE)) { //---- linkxy.dat ---- shp_file.File_Type ("DynusT Link Coordinate File"); str_fmt (buffer, sizeof (buffer), "%s/linkxy.dat", net_dir); shp_file.Create (buffer); } //---- linkname.dat ---- name_file.File_Type ("DynusT Link Name File"); str_fmt (buffer, sizeof (buffer), "%s/linkname.dat", net_dir); name_file.Create (buffer); //---- movement.dat ---- move_file.File_Type ("DynusT Movement File"); str_fmt (buffer, sizeof (buffer), "%s/movement.dat", net_dir); move_file.Create (buffer); //---- control.dat ---- ctl_file.File_Type ("DynusT Control File"); str_fmt (buffer, sizeof (buffer), "%s/control.dat", net_dir); ctl_file.Create (buffer); //---- origin.dat ---- org_file.File_Type ("DynusT Generation Link File"); str_fmt (buffer, sizeof (buffer), "%s/origin.dat", net_dir); org_file.Create (buffer); //---- destination.dat ---- des_file.File_Type ("DynusT Destination File"); str_fmt (buffer, sizeof (buffer), "%s/destination.dat", net_dir); des_file.Create (buffer); //---- bus.dat ---- bus_file.File_Type ("DynusT Bus File"); str_fmt (buffer, sizeof (buffer), "%s/bus.dat", net_dir); bus_file.Create (buffer); //---- GradeLengthPCE.dat ---- pce_file.File_Type ("DynusT Grade Length PCE File"); str_fmt (buffer, sizeof (buffer), "%s/GradeLengthPCE.dat", net_dir); pce_file.Create (buffer); //---- leftcap.dat ---- left_file.File_Type ("DynusT Left Capacity File"); str_fmt (buffer, sizeof (buffer), "%s/leftcap.dat", net_dir); left_file.Create (buffer); //---- output_option.dat ---- out_file.File_Type ("DynusT Output Option File"); str_fmt (buffer, sizeof (buffer), "%s/output_option.dat", net_dir); out_file.Create (buffer); //---- ramp.dat ---- ramp_file.File_Type ("DynusT Ramp File"); str_fmt (buffer, sizeof (buffer), "%s/ramp.dat", net_dir); ramp_file.Create (buffer); //---- StopCap2Way.dat ---- cap2_file.File_Type ("DynusT Stop Capacity 2 Way File"); str_fmt (buffer, sizeof (buffer), "%s/StopCap2Way.dat", net_dir); cap2_file.Create (buffer); //---- StopCap4Way.dat ---- cap4_file.File_Type ("DynusT Stop Capacity 4 Way File"); str_fmt (buffer, sizeof (buffer), "%s/StopCap4Way.dat", net_dir); cap4_file.Create (buffer); //---- superzone.dat ---- super_file.File_Type ("DynusT SuperZone File"); str_fmt (buffer, sizeof (buffer), "%s/superzone.dat", net_dir); super_file.Create (buffer); //---- TrafficFlowModel.dat ---- model_file.File_Type ("DynusT Traffic Flow Model File"); str_fmt (buffer, sizeof (buffer), "%s/TrafficFlowModel.dat", net_dir); model_file.Create (buffer); //---- vms.dat ---- vms_file.File_Type ("DynusT VMS File"); str_fmt (buffer, sizeof (buffer), "%s/vms.dat", net_dir); vms_file.Create (buffer); //---- yield.dat ---- yield_file.File_Type ("DynusT Yield Capacity File"); str_fmt (buffer, sizeof (buffer), "%s/YieldCap.dat", net_dir); yield_file.Create (buffer); //---- zone.dat ---- zone_file.File_Type ("DynusT Zone File"); str_fmt (buffer, sizeof (buffer), "%s/zone.dat", net_dir); zone_file.Create (buffer); //---- demand.dat ---- dem_file.File_Type ("DynusT Demand File"); str_fmt (buffer, sizeof (buffer), "%s/Demand.dat", net_dir); dem_file.Create (buffer); //---- demand_truck.dat ---- trk_file.File_Type ("DynusT Demand Truck File"); str_fmt (buffer, sizeof (buffer), "%s/demand_truck.dat", net_dir); trk_file.Create (buffer); //---- demand_hov.dat ---- hov_file.File_Type ("DynusT Demand HOV File"); str_fmt (buffer, sizeof (buffer), "%s/demand_HOV.dat", net_dir); hov_file.Create (buffer); //---- zone_map.dat ---- zmap_file.File_Type ("Zone Number Equivalence File"); str_fmt (buffer, sizeof (buffer), "%s/zone_map.dat", net_dir); zmap_file.Create (buffer); return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
int Household (void) { return (Get_Integer (hhold)); }