Skip to content

! Version 2

Emerson edited this page May 18, 2024 · 11 revisions

Version 2 is intended to make tagtracker more usable by bike parking services that are not set up the same way as Victoria's.

  • allow much more flexible tag labels (issue #427)
  • allow re-use of tags (ie track visits, not tags) (issue #394)
  • reduce device dependency (could it work in a py environment on an ipad?)
  • improve ease of installation and configuration
  • Consider whether a VTime might be a datetime, not just a time.

Implementation notes

  • a tag 'colour' no longer has meaning since we don't know what the colours might mean
  • remove option to delete "both"

BikeTag - the use of a tag

Attributes
- class attribute all_tags (dict of .simple-keyed tags)
- tagid (unique PK): NOTE: return self if already defined.
- status [IN/IN_USE, USED/DONE/RETURNED/OUT, NEW/UNUSED, RETIRED]
- visits[BikeVisit]
- bike_type [R,O]
Lower-level methods
- start_visit( time )
- finish_visit( time )
  - sets status, sets time_out
- latest_visit() -> BikeVisit
Higher-level Methods
- check_in( time)
  - edit_in( time )
- check_out( time )
  - self.status == IN
    - self.finish_visit( time )
- edit_in( time) <-- are these the same as check_in & check_out? Or vice versa?
  - self.status == UNUSED
    - self.start_visit(time)
  - self.status == IN and self.status == OUT len(self.visits) == 1
    - self.latest_visit.time_in = time
  - otherwise ERROR
- edit_out( time )
  - self.status == RETURNED
    - v = self.latest_visit()
    - v.time_in must be < time
    - v.time_out = time
  - self.status == IN
    - v = self.latest_visit()
    - v.time_in must be < time
    - self.finish_visit(time) 
- delete_in
  - self.status == IN
    - remove last element of visits list
  - else error
- delete_out
  - self.status == RETURNED
    - v = self.latest_visit()
    - v.status = IN
    - v.time_out = None
  - else error

BikeVisit -- a visit of a bike



class BikeVisit:
    # Class attributes
    all_visits = {}
    _last_seq = 0

    def __init__(self, tagid, time_in="now"):
        # Auto-generate a unique seq number
        self.seq = BikeVisit._last_seq
        BikeVisit._last_seq += 1
        self.time_in = VTime(time_in)
        self.time_out = VTime("")  
        self.tagid = TagID(tagid)
        # Add the new instance to the all_visits dict
        BikeVisit.all_visits[self.seq] = self

    def delete_visit(self):
        if self.seq in BikeVisit.all_visits:
            del BikeVisit.all_visits[self.seq]

    def duration(self, as_of_when:Vtime|str="now") ->int:
        # Return duration (in minutes) of visit
        as_of_when = VTime(as_of_when)
        dur = min(as_of_when.int, time_out.int)
        dur = dur if dur >= 0 else 0
        return dur

Trackerday obj

- everything about a single day.
- would have 100% of what is needed to create a datafile

- this is more about BikeTags than BikeVisits, since tags is how the TT UI works

Properties

Unchanged
.date
.opening_time
.closing_time
.notes
.registrations

New or changed
.regular_tagids, .oversize_tagids, .retired_tagids --> renamed versions of regular/oversize/retired
.bikes_in, .bikes_out --> removed in favour of biketags dictionary
.biketags: dict keys on tagid.simple, value is BikeTag.  This is *all* the tags that are configured for this day
.colour_letters --> does this have meaning any more?  Maybe not. Probably remove
.notes


Methods
.visits() --> return a list/dict of all the visits.
.all_tags --> probably rename to all_tagids() -- this is going to be same ids as keys(.biketags)
.make_fake_tag_lists() --> can we remove this?
.fill_colour_dict_gaps() --> prob remove this too, since no longer know colours
.lint_check() - keep.
.earlist_event(), .latest_event(), num_later_events() -- keep.


- dict of all tags is BikeTag.all_tags

- create list of BikeTags from list of BikeVisits
- create list of BikeVisits from list of BikeTags

Freeform tags

  • what is a valid tag? Anything that's in config
  • fold all tags uc and compress out lead 0s in numeric sequences
  • optional re in config file to test for a valid tag format
TagID:
.simple - label in its simplest form (uc & compressed)
.comparing - folded UC and all numeric sequences made long
__new__: return self if already defined(?)