Package org.powertac.common.repo
Class TimeslotRepo
- java.lang.Object
- 
- org.powertac.common.repo.TimeslotRepo
 
- 
- All Implemented Interfaces:
- DomainRepo
 
 @Service public class TimeslotRepo extends Object implements DomainRepo Repository for Timeslots. Timeslots are created with makeTimeslot(). Several query methods are supported, including currentTimeslot(), enabledTimeslots(), and findBySerialNumber(). The implementation makes a strong assumption that timeslots are created in sequence, and that each timeslot starts when the previous timeslots ends.- Author:
- John Collins
 
- 
- 
Constructor SummaryConstructors Constructor Description TimeslotRepo()standard constructor
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Timeslot timeslot)Adds a timeslot that already exists.intcount()Returns the number of timeslots that have been successfully created.voidcreateInitialTimeslots()Creates timeslots to fill in the time from sim start to the current time.intcurrentSerialNumber()Returns the serial number of the current timeslotTimeslotcurrentTimeslot()Returns the timeslot for the current time.List<Timeslot>enabledTimeslots()Returns the list of enabled timeslots, starting with the first by serial number.TimeslotfindByInstant(org.joda.time.Instant time)Returns the timeslot (if any) corresponding to a particular Instant.TimeslotfindBySerialNumber(int serialNumber)Returns the timeslot with the given serial number.TimeslotfindOrCreateBySerialNumber(int serialNumber)Returns the timeslot with the given serial number.org.joda.time.DateTimegetDateTimeForIndex(int index)Converts int timeslot index to DateTime in UTC timezoneTimeslotgetNext(Timeslot slot)Returns the following timeslot.org.joda.time.InstantgetTimeForIndex(int index)Converts int timeslot index to InstantintgetTimeslotIndex(org.joda.time.Instant time)Converts time to timeslot index without actually creating a timeslotbooleanisTimeslotEnabled(int index)True just in case the timeslot with the given index is enabled.booleanisTimeslotEnabled(Timeslot ts)True just in case the specified timeslot is enabled.TimeslotmakeTimeslot(org.joda.time.Instant startTime)Creates a timeslot with the given start time.voidrecycle()Implementations must clear out the repository in preparation for a new simulation.
 
- 
- 
- 
Method Detail- 
makeTimeslotpublic Timeslot makeTimeslot(org.joda.time.Instant startTime) Creates a timeslot with the given start time. The sequence number of the timeslot is the number of timeslots since the simulation base time.
 - 
currentTimeslotpublic Timeslot currentTimeslot() Returns the timeslot for the current time.
 - 
currentSerialNumberpublic int currentSerialNumber() Returns the serial number of the current timeslot
 - 
findBySerialNumberpublic Timeslot findBySerialNumber(int serialNumber) Returns the timeslot with the given serial number.
 - 
findOrCreateBySerialNumberpublic Timeslot findOrCreateBySerialNumber(int serialNumber) Returns the timeslot with the given serial number.
 - 
createInitialTimeslotspublic void createInitialTimeslots() Creates timeslots to fill in the time from sim start to the current time. This is needed to initialize brokers.
 - 
findByInstantpublic Timeslot findByInstant(org.joda.time.Instant time) Returns the timeslot (if any) corresponding to a particular Instant.
 - 
getTimeslotIndexpublic int getTimeslotIndex(org.joda.time.Instant time) Converts time to timeslot index without actually creating a timeslot
 - 
enabledTimeslotspublic List<Timeslot> enabledTimeslots() Returns the list of enabled timeslots, starting with the first by serial number. This code depends on the set of enabled timeslots being contiguous in the serial number sequence, and on a disabled timeslot never being re-enabled.
 - 
isTimeslotEnabledpublic boolean isTimeslotEnabled(Timeslot ts) True just in case the specified timeslot is enabled.
 - 
isTimeslotEnabledpublic boolean isTimeslotEnabled(int index) True just in case the timeslot with the given index is enabled.
 - 
countpublic int count() Returns the number of timeslots that have been successfully created.
 - 
addpublic void add(Timeslot timeslot) Adds a timeslot that already exists. Visibility is public to support logfile analysis, should not be used in other contexts.
 - 
getTimeForIndexpublic org.joda.time.Instant getTimeForIndex(int index) Converts int timeslot index to Instant
 - 
getDateTimeForIndexpublic org.joda.time.DateTime getDateTimeForIndex(int index) Converts int timeslot index to DateTime in UTC timezone
 - 
recyclepublic void recycle() Description copied from interface:DomainRepoImplementations must clear out the repository in preparation for a new simulation.- Specified by:
- recyclein interface- DomainRepo
 
 
- 
 
-