BUAAOO P5-P7 Elevator Simulation
目录
- Abstract
- Introduction
- Topic
- Request
- Elevator
- Analysis
- Reading Requests
- Coordinating
- Scheduling and controling
- Elevator simulation
- Topic
- Course
- P5-P6
- Reading (and coordinating)
- Scheduling and controling
- Elevator simulation
- P7
- Reading and coordinating
- Scheduling and controling
- Elevator simulation
- P5-P6
- Class Design
- Measurement
- Complexity Metric
- Method Complexity
- Class Complexity
- Package Complexity
- Module Complexity
- Project Complexity
- Complexity Metric
- Bug Review
- Level movement step
- Door movement time
- Test Strategy
- Concurrent Knowledge
- Acknowledge
- Reference
Abstract
Introduction
Topic
The topic of project 5-7 is concurrent elevator simulation. The program read requests from stdin, simulate the elevator system, and print runtime infomation to stdout.
Request
<PersonID>-FROM-<FromLevel>-TO-<ToLevel>
- On behalf of a pessenger
<PersonID>
must be unique
Elevator
- Function
- Move: Move up or down to next level in
<MoveTime>
, and printARRIVE-<Level>-<ElevatorName>
- Open Door: Open Door in
<OpenTime>
, and printOPEN-<Level>-<ElevatorName>
when begin opening - Close Door: Close Door in
<CloseTime>
, and printCLOSE-<Level>-<ElevatorName>
when close finished - Pessenger in: Print
IN-<PersonID>-<Level>-<ElevatorName>
- Pessenger out: Print
OUT-<PersonID>-<Level>-<ElevatorName>
- Move: Move up or down to next level in
- Argument
- Name
- Time
- OpenTime
- CloseTime
- MoveTime
- Level
- InitialLevel
- SupLevel
- InfLevel
- ApprovedLevel
- Capacity
Analysis
The major focus is concurrency: The program has to plan and simulate while reading requests, so it has to be concurrent. Thus we have to design a concurrent architechture and guarantee its thread safety.
Also, for multi-elevator scene, we need to design a coordinating thread to coordinate elevators.
The program's function can be classified as follows, and the threads can be designed correspondingly:
Reading Requests
Reading requests in real time, and pass them to coordinating thread.
Coordinating
Get requests from reading thread, set path for the person and pass it to scheduling thread.
Scheduling and controling
Get requests from reading thread, schedule and pass the action of elevator to elevator, and control the movement of passenger.
Elevator simulation
Get command from scheduling thread, open and close door, and go up or down stairs.
Course
This topic has three assignments.
P5-P6
Reading (and coordinating)
- Read from given input interface
- Analyse the request, put the person to corresponse location in concurrent two-dimensional map
- Dimension 1: From level
- Dimension 2: To level
- Pass person to scheduling and controling thread through cuncurrent map:
ConcurrentHashMap<MapKey, Set<Integer>>
Scheduling and controling
- Move up and down again and again
- Take in person whose destination direction is consistent with the elevator
- Free person who arrived
- U-turn if there's no person ahead
- Stop if there's no person anywhere
- Give command through
TransferQueue<Command>
to elevator
Elevator simulation
- Execute command
- Print information
- Change level
- Sleep for given time
P7
Reading and coordinating
- Read from given input interface
- Analyse and coordinate
- If there's a single elevator approved to access both from and to floor
- The person only have one request: from
<FromLevel>
to<ToLevel>
- The person only have one request: from
- else
- Because it takes at most two steps to go from
<FromLevel>
to<ToLevel>
- Find the elevator who can access
<FromLevel>
- Find the elevator who can access
<ToLevel>
- Find the level which can be accessed by both elevator
- The person has two request
- From
<FromLevel>
to<TransferLevel>
- From
<TransgerLevel>
to<ToLevel>
- From
- Because it takes at most two steps to go from
- The coordinate algorithm can be refacted to recursive one to support any number of transfers
- If there's a single elevator approved to access both from and to floor
- Pass
- Pass person to scheduling and controling thread through cuncurrent map:
ConcurrentHashMap<MapKey, Set<Integer>>
- The mapkey presents the first request:
new MapKey(<FromLevel>, <ToLevel>)
- The rest requests stored in the person object
- Pass person to scheduling and controling thread through cuncurrent map:
Scheduling and controling
- Move up and down again and again
- If current level is accessable
- Take in person
- Destination direction is consistent with the elevator
- Destination level is accessable
- Free person who arrived
- If the person has rest requests, put him to correspensive location in reqMap, and delete its next request
- Take in person
- U-turn if there's no person at accessable level ahead
- Stop if there's no person anywhere
- If current level is accessable
- Give command through
TransferQueue<Command>
to elevator
Elevator simulation
- Execute command
- Print information
- Change level
- Sleep for given time
Class Design
Measurement
Complexity Metric
Method Complexity
Method | ev(G) | iv(G) | v(G) |
---|---|---|---|
com.nyan.EleSysTest.main(String[]) | 1 | 1 | 1 |
com.nyan.elesys.Commander.Commander(int,String,Integer[],Integer,Integer,Integer,ConcurrentHashMap<MapKey, Set<Person>>,Long,Long,Long)
|
1 | 1 | 1 |
com.nyan.elesys.Commander.closeDoor() | 1 | 2 | 2 |
com.nyan.elesys.Commander.downHave() | 3 | 2 | 3 |
com.nyan.elesys.Commander.inDownPsgers() | 1 | 3 | 3 |
com.nyan.elesys.Commander.inPsgers(Integer) | 4 | 4 | 5 |
com.nyan.elesys.Commander.inUpPsgers() | 1 | 3 | 3 |
com.nyan.elesys.Commander.levelHave(int) | 5 | 6 | 8 |
com.nyan.elesys.Commander.loop() | 7 | 5 | 9 |
com.nyan.elesys.Commander.openDoor() | 1 | 2 | 2 |
com.nyan.elesys.Commander.outPsgers() | 1 | 4 | 4 |
com.nyan.elesys.Commander.run() | 1 | 4 | 5 |
com.nyan.elesys.Commander.upHave() | 3 | 2 | 3 |
com.nyan.elesys.Coordinator.Coordinator(ConcurrentHashMap<MapKey, Set<Person>>,Integer[][])
|
1 | 2 | 2 |
com.nyan.elesys.Coordinator.run() | 12 | 11 | 14 |
com.nyan.elesys.Elevator.Elevator(Long,Long,Long,Integer,String,TransferQueue<Command>)
|
1 | 1 | 1 |
com.nyan.elesys.Elevator.getLevelNum() | 1 | 1 | 1 |
com.nyan.elesys.Elevator.run() | 3 | 7 | 8 |
com.nyan.elesys.Level.Level(Integer) | 1 | 1 | 1 |
com.nyan.elesys.Level.add(Integer) | 1 | 2 | 2 |
com.nyan.elesys.Level.addOne() | 1 | 1 | 2 |
com.nyan.elesys.Level.equals(Object) | 2 | 2 | 2 |
com.nyan.elesys.Level.getLevelNum() | 1 | 1 | 1 |
com.nyan.elesys.Level.sub(Integer) | 1 | 2 | 2 |
com.nyan.elesys.Level.subOne() | 1 | 1 | 2 |
com.nyan.elesys.Level.toString() | 1 | 1 | 1 |
com.nyan.elesys.MapKey.MapKey(Integer,Integer) | 1 | 1 | 1 |
com.nyan.elesys.MapKey.equals(Object) | 2 | 3 | 3 |
com.nyan.elesys.MapKey.hashCode() | 1 | 1 | 1 |
com.nyan.elesys.MapKey.toString() | 1 | 1 | 1 |
com.nyan.elesys.Person.Person(Integer) | 1 | 1 | 1 |
com.nyan.elesys.Person.addReq(Request) | 1 | 1 | 1 |
com.nyan.elesys.Person.compareTo(Person) | 1 | 1 | 1 |
com.nyan.elesys.Person.nextReq() | 2 | 1 | 2 |
com.nyan.elesys.Person.toString() | 1 | 1 | 1 |
com.nyan.elesys.PsgsList.PsgsList(Integer,Integer) | 1 | 2 | 2 |
com.nyan.elesys.PsgsList.add(int,Set<Person>)
|
1 | 1 | 1 |
com.nyan.elesys.PsgsList.get(int) | 1 | 1 | 1 |
com.nyan.elesys.PsgsList.getTotal() | 1 | 2 | 2 |
com.nyan.elesys.PsgsList.isEmpty() | 3 | 3 | 4 |
com.nyan.elesys.Request.Request(Integer,Integer) | 1 | 1 | 1 |
com.nyan.elesys.Request.getFromLevel() | 1 | 1 | 1 |
com.nyan.elesys.Request.getToLevel() | 1 | 1 | 1 |
Class Complexity
Class | OCavg | WMC |
---|---|---|
com.nyan.EleSysTest | 1 | 1 |
com.nyan.elesys.Command | n/a | 0 |
com.nyan.elesys.Commander | 3.33 | 40 |
com.nyan.elesys.Coordinator | 7 | 14 |
com.nyan.elesys.Elevator | 3 | 9 |
com.nyan.elesys.Level | 1.62 | 13 |
com.nyan.elesys.MapKey | 1.25 | 5 |
com.nyan.elesys.Person | 1.2 | 6 |
com.nyan.elesys.PsgsList | 1.8 | 9 |
com.nyan.elesys.Request | 1 | 3 |
Package Complexity
Package | v(G)avg | v(G)tot |
---|---|---|
com.nyan | 1 | 1 |
com.nyan.elesys | 2.67 | 112 |
Module Complexity
Module | v(G)avg | v(G)tot |
---|---|---|
P7Project | 2.63 | 113 |
Project Complexity
Project | v(G)avg | v(G)tot |
---|---|---|
project | 2.63 | 113 |
Bug Review
Level movement step
Door movement time
Test Strategy
Concurrent Knowledge
Acknowledge
Reference
转载于:https://www.cnblogs.com/daniel10001/p/10758916.html
BUAAOO P5-P7 Elevator Simulation相关推荐
- 从阿里P5到P8=入门到内核?看看这份对标80W+年薪的Java进阶路线图
前话: 之前有很多粉丝私信我说: 老光,这Java程序员以后的路到底要怎么走哇? Java开发做到资深是不是到顶了?工资有没有封顶? 真的有"35岁是道坎"这么一说吗? Java之 ...
- 写到usaco上的一题可能题解是凸包所以转来这篇文章看看
凸包 graham 算法 标签: 算法distancexpstructoutputinput 2011-09-08 12:30 8371人阅读 评论(2) 收藏 举报 分类: c++ 凸包 grah ...
- 基于wincc的虚拟电梯设计_基于WINCC的模拟电梯设计
: 151********@163.com 基于 WINCC 的电梯模拟运行控制系统设计 冯鹏辉 谭兮 郭少校 刘国营 ( 湖南工业大学,湖南 株洲 412008) 摘要: 电梯的运行是电梯与大楼及各 ...
- isp 图像算法(二)之dead pixel correction坏点矫正
代码在git 相机中的坏点就是那些和周围不一样的点,就是那些数值极大或者极小值点,你可以理解一张曲面的山峰或者山谷,人群中也是一样,那些与大众不一样的人就是"坏人",衡量好坏用他与 ...
- HDU 1492 The number of divisors(约数) about Humble Numbers(数论,简单约数)
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- 模拟电梯控制软件设计c语言,模拟电梯控制系统设计.docx
PAGE \* MERGEFORMAT PAGE \* MERGEFORMAT IV 摘 要 我们所说的单片机就是单片微型计算机(Single-Chip Microcomputer )又可以称作微控制 ...
- Humble Numbers(丑数) 超详解!
给定一个素数集合 S = { p[1],p[2],...,p[k] },大于 1 且素因子都属于 S 的数我们成为丑数(Humble Numbers or Ugly Numbers),记第 n 大的丑 ...
- 杭电OJ分类题目(2)
原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(2) HDU Water~~~ HDU 100 ...
- 网易称暴雪离婚不离身;苹果发布 M2 Pro 和 M2 Max 芯片;滴滴出行 App 已重新上架安卓应用商店 | 极客头条...
「极客头条」-- 技术人员的新闻圈! CSDN 的读者朋友们早上好哇,「极客头条」来啦,快来看今天都有哪些值得我们技术人关注的重要新闻吧. 整理 | 郑丽媛 出品 | CSDN(ID:CSDNnews ...
最新文章
- Effect Java 学习笔记-对象的创建与销毁
- 最新动态,电信屏蔽Godaddy部分DNS服务
- W600 PWM 捕获功能使用示例程序
- php篮球比赛,篮球数据API接口 - 【篮球比赛动画直播变化数据】API调用示例代码...
- 虚拟化系列-VMware vSphere 5.1 虚拟机管理
- 智能玩具 数据采集 首页展示 注册 登录 自动登录 二维码图片
- 桌面恶心的无法删除的图标之 淘宝购物 删除办法
- 创建你的第一个游戏Pong——概览
- 小米手机访问电脑共享文件_详细方法步骤教你如何解决小米电视访问电脑共享资源!...
- 设计模式(四)行为型之模板方法模式、策略模式、命令模式、责任链模式
- Matlab 批量读取,处理及保存图片
- 解决JDK下载速度过慢的问题
- 一键复制吱口令,支付宝红包js代码
- ellipse()用法
- CVPR 2022 | 重新审视池化:你的感受野不是最理想的
- 【Vue】路由 —— 黑马程序员
- 51单片机的延时函数快速生成技巧
- 解决某些软件无法在虚拟机中运行的方法
- 无法打开物理文件 XXX.mdf,操作系统错误 5:5(拒绝访问。)的解决办法
- 联盟成员猛增近20家 联想超融合架构师预言成真
热门文章
- python cad 二次开发bom_30.Python前端基础之BOM和DOM
- 【C语言】在线OJ题 BC7-BC52-牛客网编程初学者入门训练
- android判断是否登陆过_如何判断车辆是否受到过碰撞?_搜狐汽车
- vim-python j教程_实践Vim配置python开发环境
- android实现直接发短信,android5.0以上版本如何直接发送短信?
- python输出变量的值使用_Python捕获任何异常,并使用变量值打印或记录回溯
- 2021年计算机二级考试广东卷英语,2021年广东计算机等级考试考试模拟练习卷.doc...
- ibm量子计算机 申请,【IBM量子计算机问世,造福人类的杰作!】IBM量子计算机已面前全球开放申请使用_来自网易大神圈子_科学企图玄学...
- linux命令忘了,Linux考试易忘命令
- m3u8和HLS下载和分析工具