public final class BasePolicy extends Object implements Policy, ExtendedBasePolicyCallback
| Modifier and Type | Class and Description |
|---|---|
static class |
BasePolicy.ProposalFilterResult
The result of the standard proposal filter
|
static class |
BasePolicy.ReservationRecord
The record of a reservation.
|
static class |
BasePolicy.ReserveParam
The reservation parameter record generated by processProposals()
|
| Modifier and Type | Field and Description |
|---|---|
protected V2IManagerCallback |
im
The V2IManager of which this Policy is a part.
|
| Constructor and Description |
|---|
BasePolicy(V2IManagerCallback im,
RequestHandler requestHandler)
Create a new base policy for a given V2IManagerCallback (implemented by
a V2IManager) and a request handler.
|
BasePolicy(V2IManagerCallback im,
RequestHandler requestHandler,
StatCollector<BasePolicy> statCollector)
Create a new base policy for a given V2IManagerCallback (implemented by
a V2IManager) and a request handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
act(double timeStep)
Give the policy a chance to do any processing it might need to do in
order to respond to requests, if it hasn't responded to them already.
|
BasePolicy.ReserveParam |
findReserveParam(Request msg,
List<Request.Proposal> proposals)
Compute the reservation parameter given the request message and a
set of proposals.
|
double |
getCurrentTime()
Get the current time
|
RequestHandler |
getRequestHandler()
Get the request handler.
|
ReservationGrid |
getReservationGrid()
Get the reservation grid.
|
StatCollector<BasePolicy> |
getStatCollector()
Get the statistic collector.
|
TrackModel |
getTrackMode() |
boolean |
hasReservation(int vin)
Check whether the vehicle currently has a reservation.
|
void |
processAwayMsg(Away msg)
Submit an away message to the policy.
|
void |
processCancelMsg(Cancel msg)
Submit a cancel message to the policy.
|
void |
processDoneMsg(Done msg)
Submit a done message to the policy.
|
void |
processV2IMessage(V2IMessage msg)
Process a V2I message
|
void |
sendComfirmMsg(int latestRequestId,
BasePolicy.ReserveParam reserveParam)
Send a confirm message
|
void |
sendRejectMsg(int vin,
int latestRequestId,
Reject.Reason reason)
Send a reject message
|
void |
setRequestHandler(RequestHandler RequestHandler)
Set the request handler.
|
void |
setV2IManagerCallback(V2IManagerCallback im)
Set the V2I manager call-back.
|
static BasePolicy.ProposalFilterResult |
standardProposalsFilter(List<Request.Proposal> proposals,
double currentTime)
Remove the proposals that are either too early or too late.
|
protected V2IManagerCallback im
public BasePolicy(V2IManagerCallback im, RequestHandler requestHandler)
im - the V2IManagerCallback for which this FCFSPolicy is
being createdrequestHandler - the request handlerpublic BasePolicy(V2IManagerCallback im, RequestHandler requestHandler, StatCollector<BasePolicy> statCollector)
im - the V2IManagerCallback for which this FCFSPolicy is
being createdrequestHandler - the request handlerstatCollector - the statistic collectorpublic static BasePolicy.ProposalFilterResult standardProposalsFilter(List<Request.Proposal> proposals, double currentTime)
proposals - the list of proposalscurrentTime - the current timepublic void setV2IManagerCallback(V2IManagerCallback im)
setV2IManagerCallback in interface Policyim - the V2I manager's call-backpublic RequestHandler getRequestHandler()
public void setRequestHandler(RequestHandler RequestHandler)
RequestHandler - the request handler.public void act(double timeStep)
public void sendComfirmMsg(int latestRequestId,
BasePolicy.ReserveParam reserveParam)
sendComfirmMsg in interface BasePolicyCallbacklatestRequestId - the latest request id of the vehiclereserveParam - the reservation parameterpublic void sendRejectMsg(int vin,
int latestRequestId,
Reject.Reason reason)
sendRejectMsg in interface BasePolicyCallbackvin - the VINlatestRequestId - the latest request id of the vehiclereason - the reason of rejectionpublic BasePolicy.ReserveParam findReserveParam(Request msg, List<Request.Proposal> proposals)
findReserveParam in interface BasePolicyCallbackmsg - the request messageproposals - the set of proposalspublic double getCurrentTime()
getCurrentTime in interface BasePolicyCallbackpublic ReservationGrid getReservationGrid()
getReservationGrid in interface ExtendedBasePolicyCallbackpublic boolean hasReservation(int vin)
hasReservation in interface BasePolicyCallbackvin - the VIN of the vehiclepublic void processV2IMessage(V2IMessage msg)
processV2IMessage in interface Policymsg - the V2I messagepublic void processCancelMsg(Cancel msg)
msg - the cancel messagepublic void processDoneMsg(Done msg)
msg - the done messagepublic void processAwayMsg(Away msg)
msg - the away messagepublic StatCollector<BasePolicy> getStatCollector()
getStatCollector in interface Policypublic TrackModel getTrackMode()
getTrackMode in interface BasePolicyCallbackCopyright © 2013. All rights reserved.