首次提交

This commit is contained in:
FH
2025-04-21 15:56:25 +08:00
parent dce4c66dc7
commit 060a17a5f8
48 changed files with 7436 additions and 4 deletions
+15
View File
@@ -0,0 +1,15 @@
# README
1. 组件库
| / | 前段设备 | 常规机构 | 缓存机构 | 集装夹具 | 运输机构 | 仓储机构 | 后段设备 |
|:--------:|----------------------------------------|----------------------------------------------------|---------------------|------|------|------|------|
| 组件形状 | 椭圆形 | 圆角矩形 | 圆角矩形 | 圆角矩形 | 菱形 | 图表 | 椭圆形 |
| 组件外框颜色 | 蓝色 | 绿色 | 黄色 | 橙色 | 青色 | 黑色 | 红色 |
| 组件内文字示例 | 组件名称:前段设备1 投入总数:100 不良品数:2 当前状态:等待后续机构 | 组件名称:常规机构1 当前状态:工作中 当前步骤:步骤1 理论产能:60PPM 实时产能:50PPM | 组件名称:缓存机构1 当前状态:工作中 | | | | |
| 双击设置项 | | | | | | | |
| 功能 | | | | | | | |
| 组件时序计算逻辑 | | | | | | | |
| 流程中仿真逻辑 | | | | | | | |
| 连接点 | | | | | | | |
| 其他 | | | | | | | |
+178
View File
@@ -0,0 +1,178 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>流程图仿真工具</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="sidebar">
<h2>图形库</h2>
<div class="shape-container">
<div class="shape-group">
<h3>机构类型</h3>
<div class="shape-item" draggable="true" data-shape-type="start">
<div class="start-shape">开始</div>
</div>
<div class="shape-item" draggable="true" data-shape-type="process">
<div class="process-shape">普通机构</div>
</div>
<div class="shape-item" draggable="true" data-shape-type="transport">
<div class="transport-shape">运输机构</div>
</div>
<div class="shape-item" draggable="true" data-shape-type="endpoint">
<div class="endpoint-shape">收料机构</div>
</div>
</div>
</div>
<div class="control-panel">
<button id="start-simulation">开始仿真</button>
<button id="stop-simulation">停止仿真</button>
<button id="reset-simulation">重置</button>
<!-- 仿真设置已移除,完全按照机构的实际速度进行仿真 -->
<div class="project-actions">
<button id="save-project">保存项目</button>
<button id="load-project">加载项目</button>
</div>
</div>
<div class="simulation-info">
<h3>仿真数据</h3>
<div id="simulation-stats">
<div>模拟时间: <span id="elapsed-time">0.0</span> 秒</div>
<div>系统产能: <span id="system-throughput">0.0</span> 个/秒</div>
<div>总产出: <span id="total-output">0</span> 个</div>
</div>
</div>
</div>
<div class="main-content">
<div class="canvas-container">
<canvas id="flow-canvas"></canvas>
</div>
<div class="status-bar">
<div id="status-message">就绪</div>
<div id="zoom-controls">
<button id="zoom-in">+</button>
<span id="zoom-level">100%</span>
<button id="zoom-out">-</button>
</div>
</div>
</div>
</div>
<!-- 图形编辑弹窗 -->
<div id="shape-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2 id="modal-title">编辑机构</h2>
<form id="shape-form">
<div class="form-group">
<label for="shape-name">机构名称:</label>
<input type="text" id="shape-name" required>
</div>
<!-- 普通机构参数 -->
<div id="process-params">
<div class="form-group">
<label for="batch-size">批量处理数量:</label>
<input type="number" id="batch-size" min="1" value="1" required>
</div>
<div class="form-group">
<label>步骤设置:</label>
<div id="steps-container">
<!-- 步骤将在这里动态添加 -->
</div>
<div class="steps-actions">
<button type="button" id="add-step" class="add-btn">添加步骤</button>
</div>
</div>
<div class="form-group">
<label>总耗时: <span id="total-time">0</span> 秒</label>
</div>
</div>
<!-- 运输机构参数 -->
<div id="transport-params" style="display:none;">
<div class="form-group">
<label for="transport-time">单次搬运时间(秒):</label>
<input type="number" id="transport-time" min="0.1" step="0.1" value="2.0" required>
</div>
<div class="form-group">
<label for="transport-batch">每次搬运数量:</label>
<input type="number" id="transport-batch" min="1" value="1" required>
</div>
<div class="form-group">
<label for="transport-count">搬运次数:</label>
<input type="number" id="transport-count" min="1" value="1" required>
</div>
</div>
<!-- 收料机构参数 -->
<div id="endpoint-params" style="display:none;">
<div class="form-group">
<label for="collection-capacity">收集容量:</label>
<input type="number" id="collection-capacity" min="1" value="100" required>
</div>
</div>
<div class="form-actions">
<button type="submit">保存</button>
<button type="button" id="cancel-edit">取消</button>
</div>
</form>
</div>
</div>
<!-- 连接编辑弹窗 -->
<div id="connection-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>编辑连接</h2>
<form id="connection-form">
<div class="form-group">
<label for="connection-delay">传输延迟(秒):</label>
<input type="number" id="connection-delay" min="0" step="0.1" value="0" required>
</div>
<div class="form-actions">
<button type="submit">保存</button>
<button type="button" id="cancel-connection-edit">取消</button>
<button type="button" id="delete-connection" class="delete-btn">删除连接</button>
</div>
</form>
</div>
</div>
<!-- 文件操作模态框 -->
<div id="file-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2 id="file-modal-title">保存项目</h2>
<form id="file-form">
<div class="form-group">
<label for="project-name">项目名称:</label>
<input type="text" id="project-name" required>
</div>
<div class="form-actions">
<button type="submit" id="file-action-btn">保存</button>
<button type="button" id="cancel-file-action">取消</button>
</div>
</form>
<div id="saved-projects-container" style="display:none;">
<h3>已保存的项目</h3>
<ul id="saved-projects-list">
<!-- 已保存的项目将在这里显示 -->
</ul>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
File diff suppressed because it is too large Load Diff
+684
View File
@@ -0,0 +1,684 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Microsoft YaHei', sans-serif;
background-color: #f5f5f5;
color: #333;
}
.container {
display: flex;
height: 100vh;
overflow: hidden;
}
/* 侧边栏样式 */
.sidebar {
width: 300px;
background-color: #fff;
border-right: 1px solid #ddd;
padding: 15px;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.sidebar h2, .sidebar h3 {
margin-bottom: 15px;
color: #333;
text-align: center;
}
.sidebar h3 {
margin: 10px 0;
font-size: 16px;
border-bottom: 1px solid #eee;
padding-bottom: 5px;
}
/* 图形库样式 */
.shape-container {
margin-bottom: 20px;
}
.shape-group {
margin-bottom: 15px;
}
.shape-item {
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 8px;
cursor: grab;
user-select: none;
background-color: #f9f9f9;
transition: all 0.2s;
}
.shape-item:hover {
background-color: #e3f2fd;
border-color: #2196F3;
}
.shape-item:active {
cursor: grabbing;
}
/* 图形样式 */
.start-shape {
width: 100%;
height: 40px;
background-color: #fff;
border: 2px solid #ff0000;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
position: relative;
text-align: center;
}
.start-shape::after {
content: "";
position: absolute;
right: -6px;
top: 50%;
transform: translateY(-50%);
width: 12px;
height: 12px;
background-color: #ff0000;
border-radius: 50%;
}
.process-shape {
width: 100%;
height: 40px;
background-color: #fff;
border: 2px solid #4CAF50;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
.transport-shape {
width: 80px;
height: 40px;
margin: 0 auto;
position: relative;
background-color: #fff;
border: none;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
.transport-shape::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #FF9800;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.endpoint-shape {
width: 100px;
height: 40px;
margin: 0 auto;
background-color: #fff;
border: 2px solid #9C27B0;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
/* 控制面板样式 */
.control-panel {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 15px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
}
.control-panel button {
padding: 8px 12px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
.control-panel button:hover {
background-color: #45a049;
}
#stop-simulation {
background-color: #f44336;
}
#stop-simulation:hover {
background-color: #d32f2f;
}
#reset-simulation {
background-color: #2196F3;
}
#reset-simulation:hover {
background-color: #1976D2;
}
.simulation-settings {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #ddd;
}
.project-actions {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #ddd;
display: flex;
gap: 10px;
}
.project-actions button {
flex: 1;
background-color: #673AB7;
}
.project-actions button:hover {
background-color: #5E35B1;
}
/* 仿真信息样式 */
.simulation-info {
margin-top: 15px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
}
#simulation-stats {
margin-top: 10px;
font-size: 14px;
}
#simulation-stats div {
margin-bottom: 5px;
}
#simulation-stats span {
font-weight: bold;
color: #FF5722;
}
/* 主内容区域样式 */
.main-content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.canvas-container {
flex: 1;
position: relative;
background-color: #f1f1f1;
overflow: hidden;
background-image: linear-gradient(#ddd 1px, transparent 1px),
linear-gradient(90deg, #ddd 1px, transparent 1px);
background-size: 20px 20px;
}
#flow-canvas {
width: 100%;
height: 100%;
cursor: grab;
}
#flow-canvas:active {
cursor: grabbing;
}
/* 状态栏样式 */
.status-bar {
height: 30px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 15px;
background-color: #f5f5f5;
border-top: 1px solid #ddd;
}
#status-message {
font-size: 14px;
color: #666;
}
#zoom-controls {
display: flex;
align-items: center;
gap: 5px;
}
#zoom-controls button {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
background-color: #f1f1f1;
border: 1px solid #ddd;
border-radius: 3px;
cursor: pointer;
}
#zoom-controls button:hover {
background-color: #e0e0e0;
}
#zoom-level {
font-size: 14px;
color: #666;
width: 50px;
text-align: center;
}
/* 模态框样式 */
.modal {
display: none;
position: fixed;
z-index: 100;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #fff;
margin: 10% auto;
padding: 20px;
border-radius: 5px;
width: 60%;
max-width: 600px;
max-height: 80vh;
overflow-y: auto;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
.close:hover {
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input,
.form-group select {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
}
.form-actions button {
padding: 8px 15px;
border-radius: 4px;
cursor: pointer;
}
.form-actions button[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
}
.form-actions button[type="button"] {
background-color: #f1f1f1;
border: 1px solid #ddd;
}
.delete-btn {
background-color: #f44336 !important;
color: white !important;
}
.add-btn {
background-color: #4CAF50 !important;
color: white !important;
padding: 5px 10px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 10px;
}
.step-item {
border: 1px solid #ddd;
border-radius: 4px;
padding: 10px;
margin-bottom: 10px;
position: relative;
background-color: #f9f9f9;
}
.step-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.step-title {
font-weight: bold;
}
.step-remove {
background-color: #f44336;
color: white;
border: none;
border-radius: 50%;
width: 24px;
height: 24px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
.step-content {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.step-field {
flex: 1;
min-width: 100px;
}
.steps-actions {
margin-top: 10px;
text-align: center;
}
/* 画布上的图形和连接样式 */
.flow-shape {
position: absolute;
cursor: move;
user-select: none;
}
.flow-start {
width: 160px;
height: 80px;
background-color: white;
border: 2px solid #ff0000;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
text-align: center;
padding: 0;
}
.flow-start::after {
content: "";
position: absolute;
right: -6px;
top: 50%;
transform: translateY(-50%);
width: 12px;
height: 12px;
background-color: #ff0000;
border-radius: 50%;
}
.flow-process {
width: 160px;
height: 80px;
background-color: white;
border: 2px solid #4CAF50;
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.flow-transport {
width: 140px;
height: 80px;
background-color: white;
border: none;
transform: rotate(0deg);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.flow-transport::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #FF9800;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.flow-endpoint {
width: 160px;
height: 80px;
background-color: white;
border: 2px solid #9C27B0;
border-radius: 40px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.shape-title {
font-weight: bold;
margin-bottom: 5px;
max-width: 90%;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.shape-info {
font-size: 12px;
color: #666;
margin-bottom: 2px;
}
.shape-throughput {
font-size: 13px;
color: #FF5722;
font-weight: bold;
}
.connection-point {
position: absolute;
width: 16px;
height: 16px;
background-color: #2196F3;
border-radius: 50%;
cursor: pointer;
z-index: 100;
transition: transform 0.2s, background-color 0.2s;
}
.connection-point:hover {
transform: scale(1.3);
background-color: #1976D2;
}
.connection-point.output {
right: 0;
top: 50%;
transform: translate(50%, -50%);
}
.connection-point.input {
left: 0;
top: 50%;
transform: translate(-50%, -50%);
}
.connection-helper {
position: absolute;
width: 24px;
height: 24px;
background-color: rgba(33, 150, 243, 0.3);
border-radius: 50%;
border: 2px solid #2196F3;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
cursor: pointer;
z-index: 10;
transform: translate(-50%, -50%);
}
.connection-helper:hover {
background-color: rgba(33, 150, 243, 0.6);
}
/* 连接线样式 */
.connection-line {
stroke: #2196F3;
stroke-width: 2;
fill: none;
}
.connection-arrow {
fill: #2196F3;
}
.connection-label {
font-size: 12px;
fill: #333;
text-anchor: middle;
dominant-baseline: central;
}
.connection-label-bg {
fill: white;
stroke: #ddd;
stroke-width: 1;
rx: 3;
ry: 3;
}
/* 物料流动动画 */
.material-particle {
fill: #FF9800;
stroke: #F57C00;
stroke-width: 1;
}
/* 已保存项目列表样式 */
#saved-projects-list {
list-style: none;
margin-top: 10px;
}
#saved-projects-list li {
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
margin-bottom: 5px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
}
#saved-projects-list li:hover {
background-color: #e3f2fd;
}
#saved-projects-list .project-actions {
display: flex;
gap: 5px;
border: none;
margin: 0;
padding: 0;
}
#saved-projects-list .project-actions button {
padding: 3px 6px;
font-size: 12px;
}
/* 响应式设计 */
@media (max-width: 768px) {
.container {
flex-direction: column;
}
.sidebar {
width: 100%;
height: 300px;
}
.modal-content {
width: 90%;
}
}