-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw7_1.puml
124 lines (121 loc) · 3.1 KB
/
hw7_1.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@startuml hw7_1
+class Elevator extends Thread {
-int available
-int moveCost
-int openCost
-int closeCost
-int maxMem
-int id;
-long lasttime
-ReentrantLock stautsLock
-Condition notask
-boolean ifmaintain
-AtomicInteger curFloor
-int curDire
-AtomicInteger curNum
-final ArrayList<Semaphore> onlyLetIn;
-final ArrayList<Semaphore> onServe;
-final Scheduler scheduler;
-final ArrayList<Person> onElevator
-int destination;
-final ArrayList<Person> waitUp
-int bitUp;
-final ArrayList<Person> waitDown
-int bitDown;
-Table table;
+Elevator(int id, Scheduler scheduler, ArrayList<Semaphore> onlyLetIn, ...)
+Elevator(ElevatorRequest elevatorRequest, Scheduler scheduler, ...)
+void run()
+void await()
+void awake()
+void addTask(Person person)
+void setIfmaintian(boolean ifmaintain)
+int getCurFloor()
+int getCurNum()
+int getElevatorId()
+int getAvailable()
+int getMoveCost()
+int getMaxMem()
-void setDirection()
-boolean hasOut()
-boolean hasIn()
-void open(boolean onlyIn)
-void close(boolean onlyIn)
-void letIn()
-void letOut()
-void move()
-void maintain()
}
+class Mainclass {
+static void main(String[] args)
}
+class Person {
-int id;
-int curFloor;
-int destFloor;
-Stack<Integer> path
-int mapVersion
+Person(Request request)
+int getMapVersion()
+int getId()
+int getCurFloor()
+int getDestFloor()
+void setCurFloor(int curFloor)
+boolean upStair()
+int getTempDest()
+void setPath(Stack<Integer> path, int mapVersion)
+int hashCode()
+boolean equals(Object obj)
+String toString()
}
+class RequestRecord extends Thread {
-final Table table;
+RequestRecord(Table table)
+void run()
}
+class Scheduler extends Thread {
-Table table
+void add(Request request)
+void add(Person person)
+Person getPerson()
+Request getRequest()
+void awakeGetter()
+void personArrive()
+boolean isEmpty()
+boolean isNomore()
+void setNomore(boolean nomore)
}
+class Table {
-final ArrayList<Person> people
-final ArrayList<Request> requests
-ReentrantReadWriteLock readWriteLock
-ReadLock addPersonLock
-WriteLock getPersonLock
-ReentrantLock requestLock
-Condition emptyPerson
-Condition emptyRequest
-byte sleepcasue
-AtomicInteger recorded
-AtomicBoolean nomore
+Table()
+void add(Request request)
+void add(Person person)
+Person getPerson()
+Request getRequest()
+void awakeGetter()
+void personArrive()
+boolean isEmpty()
+boolean isNomore()
+void setNomore(boolean nomore)
}
Mainclass::main --> Table : Instantiation
Mainclass::main --> RequestRecord : Instantiation
Mainclass::main --> Scheduler : Instantiation
Scheduler --> Elevator : Instantiation\nadd\nremove
Person --> Table : involve
RequestRecord ..> Table::add
Elevator::letOut ..> Table::add
Table::get ..> Scheduler
Scheduler ..> Elevator::addTask : give person
Scheduler ..> Elevator::setIfmaintian : maintain
@enduml