TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version...

12
TIVDM2 Sortation System, Tray Allocation 1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza and Kim Bjerge

Transcript of TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version...

Page 1: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

TIVDM2 Sortation System, Tray Allocation 1

Tray allocation for a sortation system

Real-time versionIteration III

TI-VDM2 Project

by

José Antonio Esparza

and

Kim Bjerge

Page 2: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Today’s presentation

• Status on real-time model

• Update on concurrent model behavior (UML)

• Update on real-time model (VDM)

TIVDM2 Sortation System, Tray Allocation 2

Page 3: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Status for RT model

• Thread’s deployed to CPU’s• CPU for each induction• TrayAllocator on a central CPU controller• Removed TimeStamp and TrayStep• Made periodic thread for TrayAllocator• duration used for induction rate• Version running

Issues for next time• How to feed items on based on time?• Alternative deployment one CPU for two InductionControllers• Error reading logrt?

• (30 errors encoutered in file) • Why we can’t fill the sorter (19/20)?

TIVDM2 Sortation System, Tray Allocation 3

Page 4: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Object diagram concurrent version

TIVDM2 Sortation System, Tray Allocation 4

class ObjectModel

«thread»:SorterEnv ironment

«thread»:InductionController

:TimeStamp :World

«thread»:TrayStep

:SC

«thread»:InductionController

«thread»:InductionController

«thread»:TrayAllocator

Page 5: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Behavior of concurrent model (Sequence #1)

TIVDM2 Sortation System, Tray Allocation 5

sd SequenceModel2

«thread»

:SorterEnvironment

TimeStamp«thread»

:TrayStep

«thread»

:TrayAllocator

«thread»

:InductionController

Block

Block

Block

Run

Run

Run

FeedItem

Awake

ItemsToInduct

WaitStep

RequestTray

Wait

NotifyAndIncTime

NotifyAll

UnblockAwake

IncCounts

NotifyWaitingThreads

FeedItem

UnblockWaitStep

CheckAndInduct

InductItem

InductFirstItem

ReleaseWaitingIC

UnblockWait

WaitSteps

Page 6: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Behavior of concurrent model (Sequence part #2)

TIVDM2 Sortation System, Tray Allocation 6

sd SequenceModel2

«thread»

:SorterEnvironment

TimeStamp«thread»

:TrayStep

«thread»

:TrayAllocator

«thread»

:InductionController

Block

Block

Block

Run

Run

Run

FeedItem

Awake

ItemsToInduct

WaitStep

RequestTray

Wait

NotifyAndIncTime

NotifyAll

UnblockAwake

IncCounts

NotifyWaitingThreads

FeedItem

UnblockWaitStep

CheckAndInduct

InductItem

InductFirstItem

ReleaseWaitingIC

UnblockWait

WaitSteps

Page 7: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

RT version of SC – system instance variables

cpuIC1 : CPU := new CPU (<FCFS>,1E6);

cpuIC2 : CPU := new CPU (<FCFS>,1E6);

cpuIC3 : CPU := new CPU (<FP>,1E9);

cpuTA4 : CPU := new CPU (<FCFS>,1E6);

bus1 : BUS := new BUS (<FCFS>,1E3,{cpuIC1,cpuTA4});

bus2 : BUS := new BUS (<FCFS>,1E3,{cpuIC2,cpuTA4});

bus3 : BUS := new BUS (<FCFS>,1E3,{cpuIC3,cpuTA4});

public static ic1 : InductionController := new InductionController(1);

public static ic2 : InductionController := new InductionController(2);

public static ic3 : InductionController := new InductionController(3);

public static inductionGroup : seq of InductionController := [ic1, ic2, ic3];

public static allocator : TrayAllocator := new TrayAllocator(inductionGroup);

operations

public SC: () ==> SC

SC() ==

(

cpuIC1.deploy(ic1);

cpuIC2.deploy(ic2);

cpuIC3.deploy(ic3);

cpuTA4.deploy(allocator);

);TIVDM2 Sortation System, Tray Allocation 7

Page 8: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

RT version of TrayAllocator periodic thread

-- Periodic thread operation that simulates the TrayStep

TrayStep: () ==> ()

TrayStep () ==

(

trayCount := trayCount + 1;

IO`print("< " ^ String`NatToStr(trayCount) ^ ">");

CardReader(trayCount mod TrayAllocator`NumOfTrays + 1, <Empty>);

-- Induct items for all waiting inductions

CheckItemsToInduct();

);

thread

--

periodic (20000, 0, 0, 0) (TrayStep);

TIVDM2 Sortation System, Tray Allocation 8

Page 9: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

RT version of InductionController thread

-- Permission predicate on Wait operation (Moved from TrayAllocator)

per Wait => threadid not in set dom allocator.icThreadsWaiting;

thread

(

while (ItemsToInduct()) do

(

-- Request tray allocator to induct item and wait for induction

let item = GetFirstItem()

in

(

allocator.RequestTray(threadid, selfIC, item);

Wait();

);

-- In teory this value should be 2x20000 see periodic thread in TrayAllocator

duration(30000) WaitInductionRate();

);

);

TIVDM2 Sortation System, Tray Allocation 9

Page 10: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

RT version of SorterEnviroment thread while busy do

(

timeStep := timeStep + 1;

for all i in set {1,...,TrayAllocator`NumOfInductions}

do

(

-- Check for item to feed induction at time step

let size = itemLoader.GetItemAtTimeStep(timeStep, i)

in

if (size > 0)

then

(

itemId := itemId + 1;

IO`print("[ " ^ String`NatToStr(timeStep) ^ "]");

inductionGroup(i).FeedItem(new Item(size, itemId));

);

);

-- Check if simulation is finish

if (time >= itemLoader.GetNumTimeSteps()) then

busy := false;

);

TIVDM2 Sortation System, Tray Allocation 10

Page 11: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Async operation FeedItem in InductionController

-- Enviroment feeds a new item on induction

async

public FeedItem: Item ==> ()

FeedItem(i) ==items := items ^ [i];

sync

-- Enviroment and TrayAllocator threads

mutex (FeedItem); -- Async new mutex needed!

mutex (FeedItem, InductFirstItem);

TIVDM2 Sortation System, Tray Allocation 11

Page 12: TIVDM2Sortation System, Tray Allocation1 Tray allocation for a sortation system Real-time version Iteration III TI-VDM2 Project by José Antonio Esparza.

Simulation Result*Induction id 1 -> Item id 16 size 100 on tray id 1 *Induction id 3 -> Item id 20 size 300 on tray id 5 < 18 >< 19 >< 20 >< 21 >*Induction id 2 -> Item id 19 size 200 on tray id 7 < 22 >---------------------------------------------Simulation completed for sorter configuration---------------------------------------------Specified throughput [items/hour]: 10000 Sorter speed [mm/sec]: 2000 Item max size [mm]: 1500 Item min size [mm]: 100 Tray size [mm]: 600 Number of trays : 20 Number of inductions : 3 Induction rate : 2 Induction separation [trays]: 2 ----------------------------------------------Number of trays with items : 19 Two tray items on sorter : 0Number of tray steps : 23 Number of inducted items : 19 Calculated throughput[items/hour]: 9913 ---------------------------------------------- **** Sorter is not full ****----------------------------------------------new World().Run() = ()

TIVDM2 Sortation System, Tray Allocation 12