home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
palmos
/
bart-1.3b2.tar.gz
/
bart-1.3b2.tar
/
bart-1.3b2
/
bart.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-12
|
8KB
|
224 lines
/* BART Scheduler Palm Pilot App
*
* Copyright (c) 1999, 2000 Michael Wittman
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
/* bart.h contains data types and declarations shared between the two C
files, as well as all #define options. */
#include "bartRsc.h"
/* Set to 1 to enable timing for tuning purposes, or 0 to turn off.
When enabled, the data displayed is determined by the number (0-9)
entered as grafitti in the main form. Zero (the default) disables
the display of info. See the FindTrips function for the results of
the other settings. */
#define TUNING 0
/* The results popup window and selection pop up when the pen goes
down on a table entry. They remain up until RESULTS_POPUP_TIME1
seconds after the pen went down, or RESULTS_POPUP_TIME2 seconds
after it subsequently goes up, whichever is later. The effect is
that the user can hold the pen down to keep the popup window on the
screen (like in the week view of Datebook). Set both of these to 0
to disable the popup window (and save 1.5k of precious memory), but
remember to modify the help info for the results window in
bart.rcp! */
#define RESULTS_POPUP_TIME1 5
#define RESULTS_POPUP_TIME2 1
#if RESULTS_POPUP_TIME1 || RESULTS_POPUP_TIME2
#define RESULTS_POPUP 1
#else
#define RESULTS_POPUP 0
#endif
/* Max number of transfers allowed in a single trip. This is dictated
by the number of columns in the table. It should not be an issue
for vanilla BART scheduling though. */
#define MAX_TRANSFERS 2
/* The maximum number of different line combinations making up a trip
that will be found for a search. Sixteen should be more than
sufficient (hopefully)... */
#define MAX_TRIP_TYPES 16
/* The maximum number of distinct trips (includes time info) that will
be found. */
#define MAX_TRIPS 8
/* The maximum number of distinct trips that will be displayed.
MAX_TRIPS_DISPLAYED is less than MAX_TRIPS so we can weed out trips
well before and after that take more time than necessary. We will
need twice this number of rows in the table to display the trips if
subsequent trips go through different stations. */
#define MAX_TRIPS_DISPLAYED 4
/* Format of the station bike restrictions in the database; the struct
says that no bikes are allowed in or out of the station between the
two times (it's OK for bikes to be on trains going through the
stations though). */
typedef struct {
Byte station;
Byte junk; /* for alignment */
UInt time_start;
UInt time_end;
} StationBikeRestrictionType;
extern Byte station_bike_restrictions;
extern StationBikeRestrictionType *station_bike_restriction;
/* TABLE_ROWS needs to be at least 2*MAX_TRIPS_DISPLAYED.
TABLE_COLUMNS needs to be at least 2*(MAX_TRANSFERS+1). These
numbers must also match the dimensions in the .rcp file. */
#define TABLE_ROWS 8
#define TABLE_COLUMNS 6
typedef struct {
Byte type;
union ResultsCellDataType {
/* nothing to store for an empty cell or a "to" cell */
struct ResultsCellDataStationType {
Byte number;
} station;
struct ResultsCellDataTimeType {
UInt time;
} time;
#if TUNING
struct ResultsCellDataNumber {
ULong number;
} number;
#endif
} data;
} ResultsCellType;
#define resultsCellEmpty 0x00
#define resultsCellStation 0x01
#define resultsCellTime 0x02
#if TUNING
#define resultsCellNumber 0x03
#endif
#if TUNING
extern Int tuningSetting;
extern Int miscSetting;
#endif
extern Int useSourceForDestination;
/* represents a "block" of trains with the same characteristics */
typedef struct {
/* number of trains represented by this structure */
Byte trains;
/* time difference between departures at initial valid stations */
SByte time_diff;
/* index into inc_vector array */
Byte inc_vector_idx;
/* applicable bike restriction pair; 0xff == no restrictions */
Byte nobike_pair_idx;
} TrainBlockType;
/* gives a pointer to inc_vector i in the given lineinfo. this is
still valid, but no longer used. */
#define inc_vector_ptr(lineinfo,i) ((lineinfo)->inc_vector+(i)*(lineinfo).stations)
/* transfers, as they are layed out in the database */
typedef struct {
/* station at which the transfer is made */
Byte station;
/* line to which the transfer is made */
Byte new_line;
/* amount of time necessary to make the transfer; if there is not
this amount of time between the two trains, we don't consider
the transfer possible */
UInt time;
} TransferInfoType;
typedef struct {
/* record handle for this line */
VoidHand record_handle;
/* Info from and pointers to info in the record: */
/* station numbers (in order of appearance) for stations on this line */
Byte stations;
Byte *station;
/* Increment vectors represent difference between the time a train
is at a given station on the line and the time it is at the
first station. In theory, a small number of increment vectors
will describe all trains on a line. */
Byte inc_vectors;
Byte *inc_vector;
/* "No bike pairs" are the first and last stations of a bike
restriction. In theory, a small number of "no bike pairs" will
describe all bike restrictions on a line. */
Byte nobike_pairs;
Byte (*nobike_pair)[2];
/* Time of initial train on this line at its initial valid station. */
Word initial_time;
/* train blocks described above... */
Byte train_blocks;
TrainBlockType *train_block;
/* transfers for all stations on this line */
Byte transfers;
TransferInfoType *transfer;
/* number of trains on this line */
Byte trains;
/* These are for the train block data uncompressed into linear
arrays (indexed by train number) and are dynamically allocated
when they are needed. */
VoidHand departure_time_handle;
VoidHand inc_vector_idx_handle;
VoidHand nobike_pair_idx_handle;
} LineDataType;
extern Byte currentLines;
extern LineDataType *lineInfo;
#define INVALID_STATION 0xff
#define INVALID_TRANSFER 0xff
#define INVALID_BIKEPAIR 0xff
#define INVALID_TRAIN 0xff
#define INVALID_INC 0xff
void AllocateDepartureTimes(LineDataType *line);
void DeallocateDepartureTimes(LineDataType *line);
#define DebugPrintF(format, args...) \
do { \
char string[100]; \
StrPrintF(string,format,##args); \
FrmCustomAlert(ID_Debug_Alert,string,NULL,NULL); \
} while (0)