Behavioural modelling Gas Station Behavioural modelling
Gas Stations An oil company possesses a number of gas stations spread across the country. Customers can pay their refuel turn in cash at the counter or by using their fuel card. At the end of each month, the holder of a fuel card receives a monthly invoice with the amounts of all the refuel turns paid with the fuel card. On the monthly invoice, discounts are given depending on the turnover of the customer during the invoiced month. Invoicing and paying occurs in any order: one can already receive a second invoice before having paid the first one. But obviously, each invoice must first have been sent before a payment can be received. Each refuel turn only appears on the invoice of the month of the refuel turn. If a customer doesn't pay the invoice, the unpaid refuel turns are not added to the next month’s invoice. Instead, the invoice is simply sent again to the customer to remind him/her of the payment due. If a customer repeatedly doesn't pay the invoices (e.g. two months in a row), then the customer is blacklisted and his/her card is blocked until the bills have been paid. The exact threshold to block a customer is not 100% fixed: very good customers are given a bit more slack than new customers. If the bills are settled, a customer may return to the normal state.
Gas Stations Each gas station has a number of pumps that each contain a particular type of gasoline. Obviously only one customer can refuelling his/her car at a time at a given pump. When the gauge is taken, the refuelling can start. When the gauge is put back the refuelling is stopped. Between those two moment, no other customer can use this pump. As soon as the gauge is put back, the pump becomes available for the next customer. Each pump has a separate reservoir that must be refilled when the quantity of gasoline drops below a certain pre-set reordering level. Refilling can occur at any time. The system should produce a daily report indicating which pump needs to be refilled and for each pump the current level of gasoline and the quantity to order. As the bottom of a tank can contain dirt, when the fuel drops below a critical level, the pump is automatically blocked so that no refuelling can occur with this pump. For the same reason, when refilling a tank that was still above the critical level, the pump is temporarily blocked by the gas station responsible for approximatively an hour, so that dirt can sink to the bottom. The pump is released when the gas station responsible deems that refuelling with this pump is safe again.
EDG Model Solution We start from this EDG Numbers indicate "Bottom-Up-Level" 3 2 2 1 1
Life cycle modelling Order for modelling is bottom up Invoice Line and Cash Turn Refuel Turn and Invoice Customer and Pump Gas Station
Invoice line Default life cycle is fine
Cash Turn Imagine how you take fuel when paying cash You take the gauge out of the pump. This resets the counters to 0 (So you can already keep in mind that starting a cash refuel turn will affect the state of the pump as well). You fill the tank of your car. This has a duration, so this is not an event. When the tank is full, you put the gauge back. This stops the counter. The pump will be free for the next customer, because according to the specifications: "As soon as the gauge is put back, the pump becomes available for the next customer." You go to the counter and pay your refuel turn (= happy path) OR you drive away without paying (= unhappy path, at least from the point of view of the Gas Stations owner)
Cash Turn Resulting FSM Taking the gauge without first inserting a card for paying means that a cash turn is started.
Refuel Turn with card When taking fuel with a card, first the card is identified (by putting it in a machine and validating it with a code) as well as the pump where the refuelling will occur. Then you take the gauge, refuel your tank and put the gauge back. At this point in time, it is known how much fuel you have taken. So only from this point onwards, invoicing is possible.
RefuelTurn A RefuelTurn has optional-one InvoiceLine Potentially the Refuel Turn could be invoiced several times consecutively. This should not be allowed to happen life cycle of Refuel Turn sample life cycles of InvoiceLines for this Refuel Turn Use the FSM to enforce the invoicing at some point and to prevent the creation of a second invoice.
RefuelTurn
Invoice At the end of each month, the holder of a fuel card receives a monthly invoice with the amounts of all the refuel turns paid with the fuel card. The invoice is "filled" by adding invoice lines for all the turns taken during the past month. On the monthly invoice, discounts are given depending on the turnover of the customer during the invoiced month. This is a calculation rule that can be part of the internal behaviour of the invoice. A business event is not really required for this. Invoicing and paying occurs in any order: one can already receive a second invoice before having paid the first one. This is behaviour from the perspective of the customer, not of the invoice. But obviously, each invoice must first have been sent before a payment can be received. This is behaviour of the invoice: it is sent, and then hopefully paid.
Invoice Think of unhappy paths "Reminding" can be a different business event than "send" or can be the same Add ending events to allow for (manual) cascading delete
Card Holder/Customer "Blacklisted" is a state of the customer. If a customer repeatedly doesn't pay the invoices (e.g. two months in a row), then the customer is blacklisted and his/her card is blocked until the bills have been paid. The exact threshold to block a customer is not 100% fixed: very good customers are given a bit more slack than new customers. If the bills are settled, a customer may return to the normal state. "Blacklisted" is a state of the customer. The card being blocked means that the card holder cannot take fuel with the card any more. But the card holder should be able to still pay the bills when in the blocked state. Creating invoices for not yet invoiced refuel turns should be possible as well.
Card Holder/Customer The cardholder being blacklisted means that the card holder cannot take fuel with the card any more. But the card holder should be able to still pay the bills when in the blocked state. Creating invoices for not yet invoiced refuel turns should be possible as well.
Pump Obviously only one customer can refuelling his/her car at a time at a given pump. When the gauge is taken, the refuelling can start. When the gauge is put back the refuelling is stopped. Between those two moment, no other customer can use this pump. As soon as the gauge is put back, the pump becomes available for the next customer. As indicated before, taking and putting back the gauge changes the state of the pump from free to in use and back to free. In case of a refuel turn paid with the card, the pump is already reserved at the moment the pump is chosen when checking the card.
Pump
Pump Each pump has a separate reservoir that must be refilled when the quantity of gasoline drops below a certain pre-set reordering level. Refilling can occur at any time. .... As the bottom of a tank can contain dirt, when the fuel drops below a critical level, the pump is automatically blocked so that no refuelling can occur with this pump. For the same reason, when refilling a tank that was still above the critical level, the pump is temporarily blocked by the gas station responsible for approximatively an hour, so that dirt can sink to the bottom. The pump is released when the gas station responsible deems that refuelling with this pump is safe again. The requirements indicate an extra state "blocked" you can go to from the different states. In the state "blocked" you have to ensure that all events required to end ongoing refuel turns can happen. Again: refilling the reservoir has a duration, so 'refill' is not a business event but a task.
Pump
The system should produce a daily report indicating which pump needs to be refilled and for each pump the current level of gasoline and the quantity to order. This is an IS Service.
Gas Station Default life cycle
Scoring Maximal score = 10pts per FSM ==> 50 points for this exercise Score per state chart: 10 points Basic states and transitions are OK ==> 5 pts earned All events on the right place ==> additionally +5 pts. Basic states and transitions not OK ==> score between 0 and 4,5/10 Missing state chart: loss of 10 points Overall coordination problematic ==> loss of points on the total earned so far. This can result from assigning events to wrong owner Additional state chart: If defendable ==> no loss of points If this ruins the working of the system ==> loss of points
Tips Name your events with a verb Always have your FSMs checked by the tool !! Always run "Check Model" before finalising your solution ALWAYS GENERATE PROTOTYPE AND TEST !!