9 Commits
v1.0.1 ... main

11 changed files with 247 additions and 1202 deletions

View File

@@ -1,110 +0,0 @@
<mxfile host="Electron" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/29.0.3 Chrome/140.0.7339.249 Electron/38.7.0 Safari/537.36" version="29.0.3">
<diagram name="Arquitetura SD" id="QKeTeUWuUs8JeLsq44d-">
<mxGraphModel dx="1426" dy="841" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1654" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="0K4eb2koB2xQ8duQ1-_a-1" value="&lt;b&gt;CoordinatorProcess&lt;/b&gt;&lt;br&gt;(Cliente Socket)&lt;hr&gt;• VehicleGenerator&lt;br&gt;• Modelo Poisson (λ=0.5)&lt;br&gt;• Liga a Cr1-Cr5" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="560" y="40" width="240" height="100" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-2" value="&lt;b&gt;Cr1&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8001&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8001)&lt;br&gt;• Thread Semáforo Sul&lt;br&gt;• Thread Semáforo Este&lt;br&gt;• Thread Semáforo Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="280" y="200" width="180" height="160" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-3" value="&lt;b&gt;Cr2&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8002&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8002)&lt;br&gt;• Thread Semáforo Sul&lt;br&gt;• Thread Semáforo Este&lt;br&gt;• Thread Semáforo Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="590" y="190" width="180" height="160" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-5" value="&lt;b&gt;Cr4&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8004&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8004)&lt;br&gt;• Thread Semáforo Sul&lt;br&gt;• Thread Semáforo Este&lt;br&gt;• Thread Semáforo Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="440" y="530" width="180" height="160" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-6" value="&lt;b&gt;Cr5&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8005&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8005)&lt;br&gt;• Thread Semáforo Sul&lt;br&gt;• Thread Semáforo Este&lt;br&gt;• Thread Semáforo Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="910" y="430" width="180" height="160" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-7" value="&lt;b&gt;ExitNode (S)&lt;/b&gt;&lt;br&gt;Porta: 9001&lt;br&gt;Servidor Socket&lt;hr&gt;• Recebe veículos finais&lt;br&gt;• Calcula estatísticas:&lt;br&gt; - Tempo no sistema&lt;br&gt; - Tempo de espera&lt;br&gt; - Métricas por tipo&lt;br&gt;• Envia para Dashboard" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="727" y="810" width="200" height="170" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-8" value="&lt;b&gt;DashboardServer&lt;/b&gt;&lt;br&gt;Porta: 9000&lt;br&gt;Servidor Socket&lt;hr&gt;• Thread Pool (10 threads)&lt;br&gt;• ConcurrentHashMap&lt;br&gt;• Agrega estatísticas&lt;br&gt;• Display a cada 5s:&lt;br&gt; - Throughput&lt;br&gt; - Tempos médios&lt;br&gt; - Tamanhos de filas" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="1210" y="585" width="200" height="160" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-9" value="VEHICLE_SPAWN&lt;br&gt;(Vehicle)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-1" target="0K4eb2koB2xQ8duQ1-_a-2" edge="1">
<mxGeometry x="-0.2105" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-10" value="VEHICLE_SPAWN&lt;br&gt;(Vehicle)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-1" target="0K4eb2koB2xQ8duQ1-_a-3" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-11" value="VEHICLE_SPAWN&lt;br&gt;(Vehicle)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-1" target="0K4eb2koB2xQ8duQ1-_a-4" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-12" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-2" target="0K4eb2koB2xQ8duQ1-_a-3" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-13" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-3" target="0K4eb2koB2xQ8duQ1-_a-4" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-14" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-2" target="0K4eb2koB2xQ8duQ1-_a-5" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-15" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-3" target="0K4eb2koB2xQ8duQ1-_a-5" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-16" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-5" target="0K4eb2koB2xQ8duQ1-_a-6" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-17" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=none;startFill=0;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-4" target="0K4eb2koB2xQ8duQ1-_a-6" edge="1">
<mxGeometry x="0.3659" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-18" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#FF6600;strokeWidth=2;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-5" target="0K4eb2koB2xQ8duQ1-_a-7" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-19" value="VEHICLE_TRANSFER" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#FF6600;strokeWidth=2;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-6" target="0K4eb2koB2xQ8duQ1-_a-7" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-20" value="STATS_UPDATE&lt;br&gt;(periódico 5s)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-2" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-21" value="STATS_UPDATE&lt;br&gt;(periódico 5s)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-4" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-22" value="STATS_UPDATE&lt;br&gt;(periódico 5s)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-4" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-23" value="STATS_UPDATE&lt;br&gt;(periódico 5s)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-5" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-24" value="STATS_UPDATE&lt;br&gt;(periódico 5s)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-6" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-25" value="STATS_UPDATE&lt;br&gt;(periódico 5s)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-26" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-27" value="&lt;b&gt;MessageProtocol&lt;/b&gt;&lt;hr&gt;interface:&lt;br&gt;• getType()&lt;br&gt;• getPayload()&lt;br&gt;• getSourceNode()&lt;br&gt;• getDestinationNode()" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#fff2cc;strokeColor=#d6b656;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="30" y="30" width="180" height="120" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-28" value="&lt;b&gt;Tipos de Mensagens&lt;/b&gt;&lt;hr&gt;• VEHICLE_TRANSFER&lt;br&gt;• VEHICLE_SPAWN&lt;br&gt;• STATS_UPDATE&lt;br&gt;• TRAFFIC_LIGHT_SYNC&lt;br&gt;• HEARTBEAT" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#fff2cc;strokeColor=#d6b656;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="20" y="170" width="200" height="120" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-3" target="0K4eb2koB2xQ8duQ1-_a-4" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="480" y="280" as="sourcePoint" />
<mxPoint x="990" y="440" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-4" value="&lt;b&gt;Cr3&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8003&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8003)&lt;br&gt;• Thread Semáforo Sul&lt;br&gt;• Thread Semáforo Este&lt;br&gt;• Thread Semáforo Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="910" y="200" width="180" height="160" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-30" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="1" source="0K4eb2koB2xQ8duQ1-_a-7" target="0K4eb2koB2xQ8duQ1-_a-26" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="500" y="710" as="sourcePoint" />
<mxPoint x="1090" y="520" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-26" value="&lt;b&gt;LEGENDA&lt;/b&gt;&lt;hr&gt;━━━► Comunicação síncrona&lt;br&gt;╌╌╌► Comunicação periódica&lt;br&gt;&lt;br&gt;&lt;b&gt;Cores:&lt;/b&gt;&lt;br&gt;🔵 Azul = Geração&lt;br&gt;🟢 Verde = Transferência&lt;br&gt;🟠 Laranja = Finalização&lt;br&gt;🟣 Roxo = Monitorização&lt;br&gt;&lt;br&gt;&lt;b&gt;Serialização:&lt;/b&gt; JSON (Gson)&lt;br&gt;&lt;b&gt;Protocolo:&lt;/b&gt; TCP/IP" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;spacing=10;" parent="1" vertex="1">
<mxGeometry x="1210" y="825" width="200" height="220" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

3
.gitignore vendored
View File

@@ -6,6 +6,8 @@
*.trace *.trace
logs logs
*.md *.md
*.tex
!README.md
# BlueJ files # BlueJ files
*.ctxt *.ctxt
@@ -57,3 +59,4 @@ dependency-reduced-pom.xml
# Python env # Python env
venv/ venv/
.$Diagrama de arquitetura - SD.drawio.bkp

View File

@@ -1,171 +0,0 @@
<mxfile host="Electron" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/29.0.3 Chrome/140.0.7339.249 Electron/38.7.0 Safari/537.36" version="29.0.3">
<diagram name="Arquitetura SD" id="QKeTeUWuUs8JeLsq44d-">
<mxGraphModel dx="1426" dy="841" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="0K4eb2koB2xQ8duQ1-_a-27" value="&lt;b&gt;MessageProtocol&lt;/b&gt;&lt;hr&gt;interface:&lt;br&gt;• getType()&lt;br&gt;• getPayload()&lt;br&gt;• getSourceNode()&lt;br&gt;• getDestinationNode()" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#fff2cc;strokeColor=#d6b656;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="30" y="30" width="180" height="120" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-28" value="&lt;b&gt;Tipos de Mensagens&lt;/b&gt;&lt;hr&gt;• VEHICLE_TRANSFER&lt;br&gt;• VEHICLE_SPAWN&lt;br&gt;• STATS_UPDATE&lt;br&gt;• TRAFFIC_LIGHT_SYNC&lt;br&gt;• HEARTBEAT" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#fff2cc;strokeColor=#d6b656;spacing=10;fontColor=#000000;" parent="1" vertex="1">
<mxGeometry x="20" y="170" width="200" height="120" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-26" value="&lt;b&gt;LEGENDA&lt;/b&gt;&lt;hr&gt;━━━► Comunicação síncrona&lt;br&gt;╌╌╌► Comunicação periódica&lt;br&gt;&lt;br&gt;&lt;b&gt;Cores:&lt;/b&gt;&lt;br&gt;🔵 Azul =&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;Criação do veículo&lt;/span&gt;&lt;div&gt;🟢 Verde = Transferência do veículo&lt;br&gt;🟠 Laranja = Chegada ao destino&lt;br&gt;🟣 Roxo =&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;Envio das estatísticas&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;b&gt;Serialização:&lt;/b&gt; JSON (Gson)&lt;br&gt;&lt;b&gt;Protocolo:&lt;/b&gt; TCP/IP&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;spacing=10;" parent="1" vertex="1">
<mxGeometry x="10" y="320" width="220" height="220" as="geometry" />
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-13" value="" style="group" parent="1" vertex="1" connectable="0">
<mxGeometry x="280" y="40" width="850" height="730" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-20" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.616;exitY=-0.011;exitDx=0;exitDy=0;entryX=0.661;entryY=-0.002;entryDx=0;entryDy=0;entryPerimeter=0;exitPerimeter=0;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-2" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="794" y="530" as="targetPoint" />
<Array as="points">
<mxPoint x="99" y="122" />
<mxPoint x="793" y="122" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-1" value="&lt;b&gt;CoordinatorProcess&lt;/b&gt;&lt;br&gt;(Cliente Socket)&lt;hr&gt;• VehicleGenerator&lt;br&gt;• Modelo Poisson&lt;br&gt;• Liga a Cr1-Cr5" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry x="205.6637168141593" width="176.28318584070794" height="101.38888888888889" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-2" value="&lt;b&gt;Cr1&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8001&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8001)&lt;br&gt;• Thread Semáforo - Sul&lt;br&gt;• Thread Semáforo - Este&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry y="162.22" width="160" height="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-3" value="&lt;b&gt;Cr2&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8002&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8002)&lt;br&gt;• Thread Semáforo - Sul&lt;br&gt;• Thread Semáforo - Este&lt;br&gt;• Thread Semáforo - Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry x="227.7" y="162.22" width="162.3" height="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-5" value="&lt;b&gt;Cr4&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8004&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8004)&lt;br&gt;• Thread Semáforo - Este&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry y="486.67" width="160" height="133.33" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-6" value="&lt;b&gt;Cr5&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8005&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8005)&lt;br&gt;• Thread Semáforo - Este&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry x="220.35" y="486.67" width="169.65" height="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-7" value="&lt;b&gt;ExitNode (S)&lt;/b&gt;&lt;br&gt;Porta: 9001&lt;br&gt;Servidor Socket&lt;hr&gt;• Recebe veículos finais&lt;br&gt;• Calcula estatísticas:&lt;br&gt; - Tempo no sistema&lt;br&gt; - Tempo de espera&lt;br&gt; - Métricas por tipo&lt;br&gt;• Envia para o Dashboard" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry x="464.07" y="476.53" width="154.6" height="172.36" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-8" value="&lt;b&gt;DashboardServer&lt;/b&gt;&lt;br&gt;Porta: 9000&lt;br&gt;Servidor Socket&lt;hr&gt;• Thread Pool (10 threads)&lt;br&gt;• ConcurrentHashMap&lt;br&gt;• Agrega estatísticas&lt;br&gt;• Display a cada 5s:&lt;br&gt; - Throughput&lt;br&gt; - Tempos médios&lt;br&gt; - Tamanhos de filas" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry x="683.1" y="540" width="166.9" height="180" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-1" target="0K4eb2koB2xQ8duQ1-_a-2" edge="1">
<mxGeometry x="-0.2105" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-1" target="0K4eb2koB2xQ8duQ1-_a-3" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="309" y="120" />
<mxPoint x="309" y="120" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-1" target="0K4eb2koB2xQ8duQ1-_a-4" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-2" target="0K4eb2koB2xQ8duQ1-_a-3" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-13" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-3" target="0K4eb2koB2xQ8duQ1-_a-4" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-14" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=none;startFill=0;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-2" target="0K4eb2koB2xQ8duQ1-_a-5" edge="1">
<mxGeometry x="0.125" y="100" relative="1" as="geometry">
<Array as="points">
<mxPoint x="66.10619469026548" y="446.11111111111114" />
<mxPoint x="66.10619469026548" y="446.11111111111114" />
</Array>
<mxPoint y="-1" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=none;startFill=0;exitX=1.005;exitY=0.63;exitDx=0;exitDy=0;exitPerimeter=0;align=center;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-5" edge="1">
<mxGeometry x="-0.0178" y="-49" relative="1" as="geometry">
<mxPoint x="139.55752212389382" y="588.0555555555555" as="sourcePoint" />
<mxPoint x="220" y="571" as="targetPoint" />
<Array as="points">
<mxPoint x="220" y="571" />
</Array>
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-19" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#b46504;strokeWidth=2;fillColor=#fad7ac;" parent="L62mICw2ZrYi1D68OOFe-13" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="390" y="580" as="sourcePoint" />
<mxPoint x="462.74" y="580.22" as="targetPoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-22" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.981;exitY=0.08;exitDx=0;exitDy=0;exitPerimeter=0;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-4" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry x="0.1427" y="-60" relative="1" as="geometry">
<Array as="points">
<mxPoint x="593" y="175" />
<mxPoint x="593" y="140" />
<mxPoint x="764" y="140" />
</Array>
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-4" value="&lt;b&gt;Cr3&lt;/b&gt; (IntersectionProcess)&lt;br&gt;Porta: 8003&lt;br&gt;Servidor + Cliente&lt;hr&gt;• ServerSocket (8003)&lt;br&gt;• Thread Semáforo - Sul&lt;br&gt;• Thread Semáforo - Oeste&lt;br&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" parent="L62mICw2ZrYi1D68OOFe-13" vertex="1">
<mxGeometry x="462.74" y="162.22" width="167.26" height="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-30" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;entryX=0.186;entryY=0.998;entryDx=0;entryDy=0;entryPerimeter=0;" parent="L62mICw2ZrYi1D68OOFe-13" target="0K4eb2koB2xQ8duQ1-_a-8" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="103" y="620" as="sourcePoint" />
<mxPoint x="710" y="730" as="targetPoint" />
<Array as="points">
<mxPoint x="103" y="730" />
<mxPoint x="714" y="730" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=none;startArrow=classic;startFill=1;endFill=0;" parent="L62mICw2ZrYi1D68OOFe-13" edge="1">
<mxGeometry x="-0.2214" y="26" relative="1" as="geometry">
<mxPoint x="293.8053097345133" y="486.6666666666666" as="sourcePoint" />
<mxPoint x="293.8053097345133" y="324.44444444444446" as="targetPoint" />
<Array as="points" />
<mxPoint x="-17" y="6" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#b46504;strokeWidth=2;endArrow=classic;startArrow=none;startFill=0;fillColor=#fad7ac;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="L62mICw2ZrYi1D68OOFe-13" target="0K4eb2koB2xQ8duQ1-_a-7" edge="1">
<mxGeometry x="0.3659" relative="1" as="geometry">
<mxPoint as="offset" />
<mxPoint x="541" y="324" as="sourcePoint" />
<mxPoint x="528.8495575221239" y="435.9722222222221" as="targetPoint" />
<Array as="points">
<mxPoint x="541" y="360" />
<mxPoint x="541" y="360" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.621;exitY=-0.003;exitDx=0;exitDy=0;exitPerimeter=0;" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-3" edge="1">
<mxGeometry x="0.1427" y="-60" relative="1" as="geometry">
<mxPoint x="330.53097345132744" y="141.94444444444443" as="sourcePoint" />
<mxPoint x="780" y="540" as="targetPoint" />
<Array as="points">
<mxPoint x="329" y="130" />
<mxPoint x="780" y="130" />
</Array>
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="L62mICw2ZrYi1D68OOFe-13" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="326" y="654" as="sourcePoint" />
<mxPoint x="683.1" y="700" as="targetPoint" />
<Array as="points">
<mxPoint x="326.1" y="700" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" parent="L62mICw2ZrYi1D68OOFe-13" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="556" y="650" as="sourcePoint" />
<mxPoint x="683.0973451327434" y="663.0833333333331" as="targetPoint" />
<Array as="points">
<mxPoint x="556" y="663" />
</Array>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -0,0 +1,177 @@
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0" version="29.2.6">
<diagram name="Arquitetura SD" id="QKeTeUWuUs8JeLsq44d-">
<mxGraphModel dx="891" dy="484" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="0K4eb2koB2xQ8duQ1-_a-27" parent="1" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#fff2cc;strokeColor=#d6b656;spacing=10;fontColor=#000000;" value="&lt;b&gt;MessageProtocol&lt;/b&gt;&lt;hr&gt;interface:&lt;br&gt;• getType()&lt;br&gt;• getPayload()&lt;br&gt;• getSourceNode()&lt;br&gt;• getDestinationNode()" vertex="1">
<mxGeometry height="120" width="180" x="30" y="30" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-28" parent="1" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#fff2cc;strokeColor=#d6b656;spacing=10;fontColor=#000000;" value="&lt;font style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;b style=&quot;background-color: transparent;&quot;&gt;Tipos de Mensagens&lt;/b&gt;&lt;br&gt;&lt;/font&gt;&lt;hr style=&quot;background-color: transparent;&quot;&gt;&lt;font style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;• VEHICLE_TRANSFER&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;• VEHICLE_SPAWN&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;• STATS_UPDATE&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;•&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;SIMULATION_START&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;•&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;SHUTDOWN&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;•&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;ROUTING_POLICY_CHANGE&lt;/span&gt;&lt;/font&gt;" vertex="1">
<mxGeometry height="130" width="200" x="20" y="170" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-26" parent="1" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;spacing=10;" value="&lt;b&gt;LEGENDA&lt;/b&gt;&lt;hr&gt;━━━► Comunicação síncrona&lt;br&gt;╌╌╌► Comunicação periódica&lt;br&gt;&lt;br&gt;&lt;b&gt;Cores:&lt;/b&gt;&lt;br&gt;🔵 Azul =&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;Criação do veículo&lt;/span&gt;&lt;div&gt;🟢 Verde = Transferência do veículo&lt;br&gt;🟠 Laranja = Chegada ao destino&lt;br&gt;🟣 Roxo =&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;Envio das estatísticas&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;b&gt;Serialização:&lt;/b&gt; JSON (Gson)&lt;br&gt;&lt;b&gt;Protocolo:&lt;/b&gt; TCP/IP&lt;/div&gt;" vertex="1">
<mxGeometry height="220" width="220" x="10" y="320" as="geometry" />
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-13" connectable="0" parent="1" style="group;strokeColor=light-dark(transparent,#CC6600);" value="" vertex="1">
<mxGeometry height="730" width="850" x="280" y="40" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-20" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.616;exitY=-0.011;exitDx=0;exitDy=0;entryX=0.661;entryY=-0.002;entryDx=0;entryDy=0;entryPerimeter=0;exitPerimeter=0;" target="0K4eb2koB2xQ8duQ1-_a-8" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="99" y="122" />
<mxPoint x="793" y="122" />
</Array>
<mxPoint x="794" y="530" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-1" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;CoordinatorProcess&lt;/b&gt;&lt;br&gt;(Cliente Socket)&lt;hr&gt;• VehicleGenerator&lt;br&gt;• Modelo Poisson&lt;br&gt;• Liga a Cr1-Cr5" vertex="1">
<mxGeometry height="101.38888888888889" width="176.28318584070794" x="205.6637168141593" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-2" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;Cr1&lt;/b&gt; (IntersectionProcess)&lt;br&gt;&lt;hr&gt;&lt;div&gt;• ServerSocket (8001)&lt;/div&gt;&lt;div&gt;• Eventos DES:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Este&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Sul&lt;/div&gt;&lt;div&gt;• Fila Eventos (DES)&lt;/div&gt;&lt;div&gt;• ReentrantLock&lt;/div&gt;&lt;div&gt;&lt;div&gt;• Objetos TrafficLight&lt;/div&gt;&lt;div&gt;• Pool Threads (I/O rede)&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;" vertex="1">
<mxGeometry height="162.22" width="160" y="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-3" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;Cr2&lt;/b&gt; (IntersectionProcess)&lt;br&gt;&lt;hr&gt;• ServerSocket (8002)&lt;br&gt;&lt;div&gt;• Eventos DES:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Oeste&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Este&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Sul&lt;/div&gt;&lt;div&gt;• Fila Eventos (DES)&lt;/div&gt;&lt;div&gt;• ReentrantLock&lt;/div&gt;&lt;div&gt;&lt;div&gt;• Objetos TrafficLight&lt;/div&gt;&lt;/div&gt;&lt;div&gt;• Pool Threads (I/O rede)&lt;/div&gt;" vertex="1">
<mxGeometry height="177.78" width="162.3" x="227.7" y="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-5" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;Cr4&lt;/b&gt; (IntersectionProcess)&lt;br&gt;&lt;hr&gt;&lt;div&gt;• ServerSocket (8004)&lt;/div&gt;&lt;div&gt;&lt;div&gt;• Eventos DES:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Este&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Norte&lt;/div&gt;&lt;div&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;• Objetos TrafficLight&lt;/div&gt;&lt;div&gt;• Pool Threads (I/O rede)&lt;/div&gt;&lt;/div&gt;" vertex="1">
<mxGeometry height="163.33" width="160" y="486.67" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-6" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;Cr5&lt;/b&gt; (IntersectionProcess)&lt;br&gt;&lt;hr&gt;• ServerSocket (8005)&lt;br&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;• Eventos DES:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Norte&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Este&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Sul&lt;/div&gt;• Fila Eventos (DES)&lt;br&gt;• ReentrantLock&lt;/div&gt;&lt;div&gt;&lt;div&gt;• Objetos TrafficLight&lt;/div&gt;&lt;div&gt;• Pool Threads (I/O rede)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;" vertex="1">
<mxGeometry height="173.33" width="169.65" x="220.35" y="486.67" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-7" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;ExitNode (S)&lt;/b&gt;&lt;div&gt;&lt;hr&gt;&lt;div&gt;• Server Socket (9001)&lt;br&gt;• Recebe veículos finais&lt;br&gt;• Calcula estatísticas:&lt;br&gt; - Tempo no sistema&lt;br&gt; - Tempo de espera&lt;br&gt; - Métricas por tipo&lt;br&gt;• Envia para o Dashboard&lt;/div&gt;&lt;/div&gt;" vertex="1">
<mxGeometry height="172.36" width="154.6" x="464.07" y="476.53" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-8" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;DashboardServer&lt;/b&gt;&lt;hr&gt;• Server Socket (9000)&lt;br&gt;&lt;div&gt;• Thread Pool (10 threads)&lt;br&gt;• ConcurrentHashMap&lt;br&gt;• Agrega estatísticas&lt;br&gt;• Display a cada segundo:&lt;br&gt; - Throughput&lt;br&gt; - Tempos médios&lt;br&gt; - Tamanhos de filas&lt;/div&gt;" vertex="1">
<mxGeometry height="180" width="166.9" x="683.1" y="540" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-9" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" target="0K4eb2koB2xQ8duQ1-_a-2" value="">
<mxGeometry relative="1" x="-0.2105" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-10" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" target="0K4eb2koB2xQ8duQ1-_a-3" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="309" y="120" />
<mxPoint x="309" y="120" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-11" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#0000FF;strokeWidth=2;" target="0K4eb2koB2xQ8duQ1-_a-4" value="">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-12" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;" target="0K4eb2koB2xQ8duQ1-_a-3" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="210" y="243" />
<mxPoint x="210" y="243" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-14" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=none;startFill=0;" target="0K4eb2koB2xQ8duQ1-_a-5" value="">
<mxGeometry relative="1" x="0.125" y="100" as="geometry">
<mxPoint y="-1" as="offset" />
<Array as="points">
<mxPoint x="66.10619469026548" y="446.11111111111114" />
<mxPoint x="66.10619469026548" y="446.11111111111114" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-16" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=none;startFill=0;align=center;" value="">
<mxGeometry relative="1" x="-0.0178" y="-49" as="geometry">
<mxPoint as="offset" />
<Array as="points">
<mxPoint x="220" y="571" />
</Array>
<mxPoint x="160" y="570" as="sourcePoint" />
<mxPoint x="220" y="571" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-19" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#b46504;strokeWidth=2;fillColor=#fad7ac;" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points" />
<mxPoint x="390" y="580" as="sourcePoint" />
<mxPoint x="462.74" y="580.22" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-22" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.981;exitY=0.08;exitDx=0;exitDy=0;exitPerimeter=0;" target="0K4eb2koB2xQ8duQ1-_a-8" value="">
<mxGeometry relative="1" x="0.1427" y="-60" as="geometry">
<mxPoint as="offset" />
<Array as="points">
<mxPoint x="593" y="175" />
<mxPoint x="593" y="140" />
<mxPoint x="764" y="140" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-4" parent="L62mICw2ZrYi1D68OOFe-13" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;align=left;verticalAlign=top;spacing=10;fontColor=#000000;" value="&lt;b&gt;Cr3&lt;/b&gt; (IntersectionProcess)&lt;div&gt;&lt;hr&gt;&lt;/div&gt;&lt;div&gt;• ServerSocket (8003)&lt;br&gt;&lt;div&gt;• Eventos DES:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Oeste&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;- Sul&lt;/div&gt;&lt;div&gt;• Fila Eventos (DES)&lt;/div&gt;• ReentrantLock&lt;/div&gt;&lt;div&gt;&lt;div&gt;• Objetos TrafficLight&lt;/div&gt;&lt;/div&gt;&lt;div&gt;• Pool Threads (I/O rede)&lt;/div&gt;" vertex="1">
<mxGeometry height="157.78" width="167.26" x="462.74" y="162.22" as="geometry" />
</mxCell>
<mxCell id="0K4eb2koB2xQ8duQ1-_a-30" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;entryX=0.186;entryY=0.998;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.638;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;" target="0K4eb2koB2xQ8duQ1-_a-8" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="102" y="730" />
<mxPoint x="714" y="730" />
</Array>
<mxPoint x="103" y="660" as="sourcePoint" />
<mxPoint x="710" y="730" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-2" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=none;startArrow=classic;startFill=1;endFill=0;entryX=0.409;entryY=0.993;entryDx=0;entryDy=0;entryPerimeter=0;" target="0K4eb2koB2xQ8duQ1-_a-3" value="">
<mxGeometry relative="1" x="-0.2214" y="26" as="geometry">
<mxPoint x="-17" y="6" as="offset" />
<Array as="points" />
<mxPoint x="293.8053097345133" y="486.6666666666666" as="sourcePoint" />
<mxPoint x="293.8053097345133" y="324.44444444444446" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-10" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.621;exitY=-0.003;exitDx=0;exitDy=0;exitPerimeter=0;" value="">
<mxGeometry relative="1" x="0.1427" y="-60" as="geometry">
<mxPoint as="offset" />
<Array as="points">
<mxPoint x="329" y="130" />
<mxPoint x="780" y="130" />
</Array>
<mxPoint x="330.53097345132744" y="141.94444444444443" as="sourcePoint" />
<mxPoint x="780" y="540" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-11" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;exitX=0.627;exitY=1.014;exitDx=0;exitDy=0;exitPerimeter=0;" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="327" y="700" />
</Array>
<mxPoint x="326" y="654" as="sourcePoint" />
<mxPoint x="683.1" y="700" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="L62mICw2ZrYi1D68OOFe-12" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#9933FF;strokeWidth=2;dashed=1;" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="556" y="663" />
</Array>
<mxPoint x="556" y="650" as="sourcePoint" />
<mxPoint x="683.0973451327434" y="663.0833333333331" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="J0awZyeCmWOCt0z9hVlQ-7" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=light-dark(#00AA00,#C98531);strokeWidth=2;endArrow=none;startArrow=classic;startFill=1;endFill=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" value="">
<mxGeometry relative="1" x="-0.2214" y="26" as="geometry">
<mxPoint x="-17" y="6" as="offset" />
<Array as="points" />
<mxPoint x="541" y="470" as="sourcePoint" />
<mxPoint x="541.17" y="320" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="J0awZyeCmWOCt0z9hVlQ-33" edge="1" parent="L62mICw2ZrYi1D68OOFe-13" source="0K4eb2koB2xQ8duQ1-_a-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#00AA00;strokeWidth=2;endArrow=classic;startArrow=classic;entryX=-0.001;entryY=0.513;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=0.454;exitDx=0;exitDy=0;exitPerimeter=0;" target="0K4eb2koB2xQ8duQ1-_a-4" value="">
<mxGeometry relative="1" as="geometry">
<Array as="points" />
<mxPoint x="391" y="243.13" as="sourcePoint" />
<mxPoint x="460" y="243" as="targetPoint" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
Diagrama de arquitetura.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

54
README.md Normal file
View File

@@ -0,0 +1,54 @@
# DTSS - Distributed Traffic Simulation System
**Sistemas Distribuídos 2025/2026**
**Autores:** David Alves, Leandro Afonso, Gabriel Moreira
Simulador de tráfego distribuído (Malha 3x3) com comunicação TCP/IP e modelo de eventos discretos.
### 📋 Pré-requisitos
* **Java 17+**
* **Maven 3.6+**
-----
### Build
Compilar e gerar o JAR executável:
```bash
cd main
mvn clean package
```
-----
### Execução
Inicia todos os processos (Dashboard, Coordenador, Nós, Saída) numa única instância.
```bash
cd main
mvn javafx:run
```
-----
### Cenários de Carga
**Arquivos disponíveis em `src/main/resources/`:**
* `simulation-low.properties` ($\lambda=0.2$)
* `simulation-medium.properties` ($\lambda=0.5$)
* `simulation-high.properties` ($\lambda=1.0$)
-----
### Troubleshooting Rápido
**Port already in use / Limpeza de Processos:**
Se a simulação falhar ou portas ficarem presas, matar todos os processos Java associados:
```bash
pkill -f "sd.IntersectionProcess|sd.dashboard.DashboardServer|sd.coordinator.CoordinatorProcess"
```

View File

@@ -1,712 +0,0 @@
\documentclass[12pt,a4paper]{article}
% Pacotes essenciais
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
% Configuração da página
\geometry{
left=2.5cm,
right=2.5cm,
top=2.5cm,
bottom=2.5cm
}
% Configuração de hyperlinks
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
pdftitle={Trabalho Prático - Sistemas Distribuídos},
pdfauthor={David Alves, Leandro Afonso, Gabriel Moreira},
}
% Configuração de código
\lstset{
basicstyle=\ttfamily\footnotesize,
breaklines=true,
frame=single,
numbers=left,
numberstyle=\tiny,
keywordstyle=\color{blue},
commentstyle=\color{green!60!black},
stringstyle=\color{red}
}
% Cabeçalho e rodapé
\pagestyle{fancy}
\fancyhf{}
\rhead{Sistemas Distribuídos}
\lhead{Trabalho Prático}
\rfoot{Página \thepage}
\begin{document}
% ============================================================
% PÁGINA DE TÍTULO
% ============================================================
\begin{titlepage}
\centering
\vspace*{2cm}
{\LARGE\bfseries Licenciatura em Segurança Informática\\e Redes de Computadores\par}
\vspace{1.5cm}
{\Large Unidade Curricular ``Sistemas Distribuídos''\par}
\vspace{0.5cm}
{\large Ano letivo 2024/2025\par}
\vspace{2cm}
{\huge\bfseries Trabalho Prático\par}
\vspace{0.5cm}
{\Large Simulação de Tráfego Urbano Distribuído\par}
\vspace{2cm}
{\large\bfseries Realizado por:\par}
\vspace{0.5cm}
{\large
David Alves, número de aluno 8240231\\
Leandro Afonso, número de aluno [A COMPLETAR]\\
Gabriel Moreira, número de aluno [A COMPLETAR]
\par}
\vspace{1.5cm}
{\large\bfseries Docente da UC:\par}
\vspace{0.3cm}
{\large Ronaldo Moreira Salles\par}
\vfill
{\large 8 de dezembro de 2024\par}
\end{titlepage}
% ============================================================
% ÍNDICE
% ============================================================
\tableofcontents
\newpage
% ============================================================
% INTRODUÇÃO
% ============================================================
\section{Introdução}
O presente trabalho tem como objetivo dotar os alunos com a capacidade de desenvolver uma aplicação distribuída em linguagem Java, simulando um sistema de tráfego urbano. O projeto é desenvolvido de modo a permitir avaliar e gerir as regras de controlo dos semáforos, tendo em conta diferentes cargas de tráfego.
A simulação implementa uma arquitetura de processos distribuídos que comunicam através de sockets TCP/IP, onde cada componente opera de forma autónoma enquanto contribui para o comportamento global do sistema. Este paradigma permite avaliar propriedades como escalabilidade, tolerância a falhas e sincronização distribuída em ambientes concorrentes.
% ============================================================
% O MODELO DE SIMULAÇÃO
% ============================================================
\section{O Modelo de Simulação}
O sistema retrata uma malha três por três, tendo três pontos de entrada (E1, E2 e E3), cinco cruzamentos (de Cr1 a Cr5) e um ponto de saída (S). As arestas representam as ruas e podem ser de sentido único ou duplo. Cada cruzamento é um processo separado, responsável pela gestão local do tráfego através de semáforos independentes que controlam três direções (Sul, Este e Oeste). O ponto de saída recolhe as estatísticas finais dos veículos que terminam o seu percurso.
\subsection{Geração de Veículos}
O processo coordenador (\texttt{CoordinatorProcess}) atua como o gerador de veículos, colocando-os no percurso através dos pontos de entrada seguindo o modelo de \textbf{Poisson} ($\lambda$ configurável). A simulação modela assim a chegada de veículos de forma realista, semelhante ao tráfego real. Esta abordagem significa que o número total de veículos gerados varia entre execuções. Como alternativa, o sistema permite também configurar um modelo de chegadas fixas, onde os veículos chegam em intervalos constantes e previsíveis.
\subsection{Características dos Veículos}
Cada veículo criado tem a probabilidade de ser:
\begin{itemize}
\item \textbf{Mota} (20\%): Tempo de travessia = $0.5 \times$ tempo base
\item \textbf{Carro} (60\%): Tempo de travessia = $1.0 \times$ tempo base
\item \textbf{Camião} (20\%): Tempo de travessia = $2.0 \times$ tempo base
\end{itemize}
Cada veículo possui um identificador único e uma rota predefinida que determina o seu percurso completo até ao nó de saída. As rotas são atribuídas segundo a política de encaminhamento configurada:
\begin{itemize}
\item \textbf{Random}: Escolha aleatória entre todas as rotas possíveis
\item \textbf{Shortest Path}: Seleção da rota com menor número de saltos
\item \textbf{Least Congested}: Escolha da rota com menor congestionamento atual
\end{itemize}
\subsection{Modelo de Eventos Discretos (DES)}
A simulação baseia-se num modelo de eventos discretos, onde cada cruzamento mantém uma fila de prioridade de eventos ordenados cronologicamente por timestamp. Os eventos incluem:
\begin{itemize}
\item Chegadas e partidas de veículos
\item Mudanças de estado dos semáforos
\item Atualizações de estatísticas
\end{itemize}
Cada semáforo opera como uma thread independente, alternando entre os estados \textbf{GREEN} (verde) e \textbf{RED} (vermelho), gerindo uma fila FIFO de veículos que aguardam passagem. Quando um veículo atravessa um cruzamento, é enviado para o processo do próximo cruzamento indicado na sua rota, onde é adicionado à fila do semáforo correspondente à direção necessária.
\subsection{Comunicação Distribuída}
A arquitetura distribuída permite que cada componente seja executado de forma independente. As comunicações são baseadas em sockets TCP/IP, com serialização das mensagens em JSON através da biblioteca \textbf{Gson}. Esta abordagem garante interoperabilidade e facilita a depuração do sistema.
% ============================================================
% ARQUITETURA DO SISTEMA E COMPONENTES
% ============================================================
\section{Arquitetura do Sistema e Componentes}
Foi desenvolvido um diagrama que retrata a arquitetura do projeto, ilustrando a topologia da rede viária e as conexões entre os diversos processos.
\subsection{Componentes Principais}
\subsubsection{Coordenador (\texttt{CoordinatorProcess})}
\begin{itemize}
\item \textbf{Porta}: Coordenação central sem socket servidor próprio (atua como cliente)
\item \textbf{Função}: Geração de veículos, gestão do relógio global de simulação, injeção de carga nos pontos de entrada
\item \textbf{Responsabilidades}:
\begin{itemize}
\item Implementação do modelo de Poisson para chegadas estocásticas
\item Seleção de rotas baseada na política configurada
\item Sincronização temporal da simulação
\end{itemize}
\end{itemize}
\subsubsection{Processos de Cruzamento (\texttt{IntersectionProcess})}
Cada cruzamento mantém um \texttt{ServerSocket} dedicado que aceita ligações de múltiplos clientes simultaneamente, criando uma thread para cada ligação estabelecida:
\begin{itemize}
\item \textbf{Cr1}: Porta 8001
\item \textbf{Cr2}: Porta 8002
\item \textbf{Cr3}: Porta 8003
\item \textbf{Cr4}: Porta 8004
\item \textbf{Cr5}: Porta 8005
\end{itemize}
\textbf{Responsabilidades}:
\begin{itemize}
\item Gestão local de semáforos (3 direções: Sul, Este, Oeste)
\item Processamento de eventos DES locais
\item Encaminhamento de veículos para o próximo destino
\item Reporte periódico de estatísticas ao Dashboard
\end{itemize}
\subsubsection{Nó de Saída (\texttt{ExitNodeProcess})}
\begin{itemize}
\item \textbf{Porta}: 9001
\item \textbf{Função}: Agregação final de métricas
\item \textbf{Responsabilidades}:
\begin{itemize}
\item Cálculo do tempo total de permanência no sistema
\item Throughput global
\item Estatísticas agregadas por tipo de veículo
\end{itemize}
\end{itemize}
\subsubsection{Servidor de Dashboard (\texttt{DashboardServer})}
\begin{itemize}
\item \textbf{Porta}: 9000
\item \textbf{Função}: Monitorização centralizada e visualização em tempo real
\item \textbf{Responsabilidades}:
\begin{itemize}
\item Agregação de estatísticas de todos os processos
\item Deteção de falhas através de heartbeats
\item Renderização da interface gráfica (JavaFX) ou CLI
\end{itemize}
\end{itemize}
\subsection{Sincronização e Concorrência}
O \texttt{DashboardServer} implementa um sistema de agregação com \textbf{10 threads concorrentes} (thread pool) que processam atualizações de estatísticas vindas dos cinco cruzamentos. Utiliza um \texttt{ConcurrentHashMap} para armazenar métricas por cruzamento, permitindo leituras simultâneas enquanto recebe atualizações. O frontend é atualizado a cada \textbf{5 segundos}.
A sincronização entre os processos ocorre através de \textbf{comunicação assíncrona}, onde cada processo continua a sua execução local enquanto envia e recebe mensagens. Os semáforos dentro de cada cruzamento operam de forma autónoma com ciclos independentes. O dashboard identifica a ausência de heartbeats para detetar falhas de processos.
% ============================================================
% CLASSES E MÉTODOS
% ============================================================
\section{Classes e Métodos}
O programa está organizado em diversos packages que contêm classes com responsabilidades distintas. Neste relatório são mencionadas as principais que sustentam o projeto, estando o resto da documentação apoiado em JavaDoc.
\subsection{Package \texttt{sd.model}}
\subsubsection{Classe \texttt{Vehicle}}
Representa cada veículo na simulação com os seguintes atributos:
\begin{itemize}
\item \texttt{vehicleId}: Identificador único
\item \texttt{vehicleType}: Tipo (MOTORCYCLE, CAR, TRUCK)
\item \texttt{entryTime}: Timestamp de entrada no sistema
\item \texttt{route}: Lista de nós que compõem o percurso completo
\end{itemize}
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{advanceRoute()}: Avança para o próximo nó na rota
\item \texttt{getCurrentDestination()}: Obtém o próximo cruzamento
\item \texttt{addWaitingTime(double time)}: Acumula tempo de espera em filas
\item \texttt{addCrossingTime(double time)}: Acumula tempo de travessia
\end{itemize}
\subsubsection{Classe \texttt{Intersection}}
Gere os cruzamentos, mantendo:
\begin{itemize}
\item Um mapa de semáforos por direção (\texttt{Map<Direction, TrafficLight>})
\item Uma tabela de encaminhamento que mapeia destinos para direções específicas
\end{itemize}
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{configureRoute(String destination, Direction direction)}: Define a tabela de routing
\item \texttt{receiveVehicle(Vehicle vehicle)}: Recebe veículos e coloca-os na fila do semáforo correspondente
\item \texttt{getTrafficLight(Direction direction)}: Obtém o semáforo de uma direção específica
\end{itemize}
\subsubsection{Classe \texttt{TrafficLight}}
Controla cada semáforo individualmente, utilizando locks (\texttt{ReentrantLock}) para garantir thread-safety.
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{addVehicle(Vehicle vehicle)}: Adiciona veículo à fila (FIFO)
\item \texttt{removeVehicle()}: Remove veículo da fila (apenas quando verde)
\item \texttt{changeState(TrafficLightState newState)}: Alterna entre GREEN e RED
\item \texttt{getQueueSize()}: Retorna o tamanho atual da fila
\end{itemize}
\subsubsection{Classe \texttt{Event} (no package \texttt{sd.des})}
Representa eventos discretos na simulação. Implementa \texttt{Comparable<Event>} para ordenação automática cronológica na fila de prioridade.
\textbf{Atributos:}
\begin{itemize}
\item \texttt{timestamp}: Momento em que o evento deve ocorrer
\item \texttt{eventType}: Tipo do evento (VEHICLE\_ARRIVAL, TRAFFIC\_LIGHT\_CHANGE, etc.)
\item \texttt{associatedData}: Payload específico do evento
\end{itemize}
\subsubsection{Classe \texttt{Message}}
Define a estrutura das mensagens trocadas entre processos.
\textbf{Atributos:}
\begin{itemize}
\item \texttt{messageId}: Identificador único da mensagem
\item \texttt{messageType}: Tipo da mensagem (VEHICLE\_TRANSFER, STATS\_UPDATE, etc.)
\item \texttt{sourceNode}: Nó de origem
\item \texttt{destinationNode}: Nó de destino
\item \texttt{payload}: Conteúdo serializado em JSON
\end{itemize}
\subsection{Package \texttt{sd.coordinator}}
\subsubsection{Classe \texttt{CoordinatorProcess}}
Conduz a simulação através do paradigma de eventos discretos distribuído.
\textbf{Responsabilidades:}
\begin{itemize}
\item Inicialização da topologia da rede
\item Geração de veículos segundo distribuição de Poisson
\item Injeção de carga nos pontos de entrada (E1, E2, E3)
\item Seleção de rotas com base na política configurada
\end{itemize}
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{initialize()}: Prepara o sistema, estabelece conexões com interseções
\item \texttt{run()}: Loop principal de geração de veículos
\item \texttt{generateAndInjectVehicle()}: Cria um novo veículo e injeta-o num ponto de entrada
\item \texttt{selectRouteForVehicle()}: Determina a rota com base na política ativa
\end{itemize}
\subsubsection{Classe \texttt{SocketClient}}
Facilita a comunicação de rede do lado do cliente.
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{connect(String host, int port)}: Estabelece ligação TCP
\item \texttt{send(Message message)}: Serializa e transmite mensagem
\item \texttt{close()}: Encerra ligação e liberta recursos
\end{itemize}
\subsection{Package \texttt{sd}}
\subsubsection{Classe \texttt{IntersectionProcess}}
Representa um nó de processamento autónomo (Worker Node) na malha distribuída.
\textbf{Arquitetura híbrida:}
\begin{itemize}
\item \textbf{Reativa (Network I/O)}: Threads dedicadas aceitam conexões TCP e injetam veículos nas filas
\item \textbf{Proativa (DES Engine)}: Thread de processamento de eventos gere a lógica temporal
\end{itemize}
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{initialize()}: Carrega configurações, cria semáforos e rotas
\item \texttt{startTrafficLightThreads()}: Inicia threads de controlo dos semáforos
\item \texttt{startServerSocket()}: Aceita conexões de veículos de outros processos
\item \texttt{sendVehicleToNextDestination(Vehicle vehicle)}: Encaminha veículos pela rede
\item \texttt{reportStatistics()}: Envia métricas ao Dashboard periodicamente
\item \texttt{shutdown()}: Encerra serviços e liberta recursos
\end{itemize}
\subsection{Package \texttt{sd.util}}
\subsubsection{Classe \texttt{VehicleGenerator}}
Responsável pela criação de veículos segundo o modelo de Poisson.
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{generateVehicle()}: Cria veículo com tipo e rota selecionados aleatoriamente
\item \texttt{getNextArrivalTime(double lambda)}: Calcula o momento da próxima chegada usando distribuição exponencial
\end{itemize}
\subsubsection{Classe \texttt{StatisticsCollector}}
Agrega métricas do sistema, rastreando veículos em trânsito e mantendo contadores globais.
\textbf{Métodos principais:}
\begin{itemize}
\item \texttt{recordVehicleGeneration(Vehicle vehicle)}: Regista criação de veículo
\item \texttt{recordVehicleArrival(Vehicle vehicle, String intersection)}: Regista chegada a cruzamento
\item \texttt{recordVehicleDeparture(Vehicle vehicle, String intersection)}: Regista partida de cruzamento
\item \texttt{recordVehicleCompletion(Vehicle vehicle)}: Regista conclusão do percurso
\item \texttt{getStatistics()}: Retorna snapshot das métricas atuais
\item \texttt{printStatistics()}: Gera relatórios com throughput, tempos médios, etc.
\end{itemize}
\subsection{Package \texttt{sd.config}}
\subsubsection{Classe \texttt{SimulationConfig}}
Carrega parâmetros do ficheiro \texttt{simulation.properties} (ou variantes \texttt{simulation-low.properties}, \texttt{simulation-medium.properties}, \texttt{simulation-high.properties}).
\textbf{Parâmetros configuráveis:}
\begin{itemize}
\item Duração da simulação
\item Taxa de chegada $\lambda$ (lambda)
\item Probabilidades de tipos de veículos
\item Tempos de travessia base
\item Tempos de ciclo dos semáforos
\item Política de encaminhamento
\end{itemize}
\subsection{Package \texttt{sd.routing}}
\subsubsection{Políticas de Encaminhamento}
O sistema suporta três estratégias de seleção de rotas:
\begin{itemize}
\item \texttt{RandomRouteSelector}: Escolha equiprovável entre todas as rotas disponíveis.
\item \texttt{ShortestPathRouteSelector}: Seleção da rota com menor número de saltos (hops).
\item \texttt{LeastCongestedRouteSelector}: Escolha da rota com menor congestionamento atual, baseada em feedback dos cruzamentos sobre tamanhos de filas.
\end{itemize}
% ============================================================
% AVALIAÇÃO DO DESEMPENHO DO SISTEMA
% ============================================================
\section{Avaliação do Desempenho do Sistema}
A avaliação do sistema baseia-se em métricas recolhidas pela classe \texttt{DashboardStatistics}, que monitoriza:
\begin{itemize}
\item Número de veículos gerados
\item Número de veículos que completaram o percurso
\item Taxa de conclusão (\%)
\item Tempo médio no sistema (segundos)
\item Tempo médio de espera acumulado em filas (segundos)
\item Throughput (veículos/segundo)
\end{itemize}
\subsection{Cenários de Carga}
Foram configurados três cenários de carga de tráfego, cada um executado 5 vezes para obter estatísticas fiáveis.
\subsubsection{Tráfego Leve (LOW LOAD)}
\textbf{Configuração:} \texttt{simulation-low.properties} - $\lambda = 0.2$ veículos/segundo
\begin{table}[H]
\centering
\caption{Métricas de Desempenho - Tráfego Leve}
\begin{tabular}{lrrrrr}
\toprule
\textbf{Métrica} & \textbf{Média} & \textbf{Desvio Padrão} & \textbf{IC 95\%} & \textbf{Mín} & \textbf{Máx} \\
\midrule
Veículos Gerados & 364.60 & 9.34 & [351.30, 377.90] & 350 & 373 \\
Veículos Completados & 219.60 & 31.19 & [175.22, 263.98] & 187 & 263 \\
Taxa de Conclusão (\%) & \textbf{60.38} & 9.71 & [46.57, 74.20] & 50.40 & 72.85 \\
Tempo Médio no Sistema (s) & \textbf{33.04} & 7.41 & [22.50, 43.58] & 23.36 & 42.28 \\
Tempo Médio de Espera (s) & 13.78 & 3.43 & [8.82, 18.73] & 9.72 & 17.53 \\
\bottomrule
\end{tabular}
\end{table}
\textbf{Análise:} Com carga leve, a rede opera abaixo da capacidade sem congestionamento significativo. A taxa de conclusão superior a 60\% e o tempo médio no sistema de apenas 33 segundos demonstram que o sistema consegue processar eficientemente o tráfego quando a chegada de veículos é esparsa.
\subsubsection{Tráfego Moderado (MEDIUM LOAD)}
\textbf{Configuração:} \texttt{simulation-medium.properties} - $\lambda = 0.5$ veículos/segundo
\begin{table}[H]
\centering
\caption{Métricas de Desempenho - Tráfego Moderado}
\begin{tabular}{lrrrrr}
\toprule
\textbf{Métrica} & \textbf{Média} & \textbf{Desvio Padrão} & \textbf{IC 95\%} & \textbf{Mín} & \textbf{Máx} \\
\midrule
Veículos Gerados & 927.20 & 32.48 & [880.97, 973.43] & 886 & 954 \\
Veículos Completados & 419.40 & 90.64 & [290.42, 548.38] & 312 & 535 \\
Taxa de Conclusão (\%) & \textbf{45.23} & 9.64 & [31.50, 58.95] & 34.74 & 56.08 \\
Tempo Médio no Sistema (s) & \textbf{44.48} & 6.81 & [34.79, 54.18] & 35.08 & 52.56 \\
Tempo Médio de Espera (s) & 21.05 & 4.73 & [13.55, 28.56] & 14.60 & 25.60 \\
\bottomrule
\end{tabular}
\end{table}
\textbf{Análise:} Com tráfego moderado, observa-se o início de congestionamento. A taxa de conclusão cai para 45\% e o tempo médio no sistema aumenta 34\% relativamente ao cenário leve. As filas começam a formar-se nos cruzamentos principais (Cr2 e Cr5).
\subsubsection{Tráfego Intenso (HIGH LOAD)}
\textbf{Configuração:} \texttt{simulation-high.properties} - $\lambda = 1.0$ veículos/segundo
\begin{table}[H]
\centering
\caption{Métricas de Desempenho - Tráfego Intenso}
\begin{tabular}{lrrrrr}
\toprule
\textbf{Métrica} & \textbf{Média} & \textbf{Desvio Padrão} & \textbf{IC 95\%} & \textbf{Mín} & \textbf{Máx} \\
\midrule
Veículos Gerados & 1813.80 & 41.93 & [1754.13, 1873.47] & 1782 & 1872 \\
Veículos Completados & 651.00 & 354.20 & [146.96, 1155.04] & 179 & 953 \\
Taxa de Conclusão (\%) & \textbf{35.92} & 19.44 & [8.25, 63.58] & 9.70 & 50.91 \\
Tempo Médio no Sistema (s) & \textbf{60.15} & 6.17 & [51.38, 68.93] & 53.09 & 65.41 \\
Tempo Médio de Espera (s) & 37.82 & 5.59 & [29.67, 45.96] & 31.51 & 44.58 \\
\bottomrule
\end{tabular}
\end{table}
\textbf{Análise:} Com tráfego intenso, a rede aproxima-se da saturação. A taxa de conclusão cai para apenas 36\% com elevada variabilidade ($\sigma = 19.44\%$), indicando comportamento instável. O tempo médio no sistema atinge 60 segundos, mas o aspecto mais crítico é o tempo médio de espera de 37.82 segundos, representando 63\% do tempo total no sistema. A alta variabilidade sugere que o sistema está perto do colapso, com algumas execuções a atingir apenas 9.7\% de taxa de conclusão.
\subsection{Análise Comparativa}
\begin{table}[H]
\centering
\caption{Comparação entre Cenários de Carga}
\begin{tabular}{lrrrr}
\toprule
\textbf{Cenário} & \textbf{$\lambda$ (v/s)} & \textbf{Taxa Conclusão (\%)} & \textbf{Tempo Sistema (s)} & \textbf{Tempo Espera (s)} \\
\midrule
Leve & 0.2 & 60.38 & 33.04 & 13.78 \\
Moderado & 0.5 & 45.23 & 44.48 & 21.05 \\
Intenso & 1.0 & 35.92 & 60.15 & 37.82 \\
\bottomrule
\end{tabular}
\end{table}
\textbf{Observações:}
\begin{enumerate}
\item \textbf{Relação não-linear}: Dobrar a taxa de chegada ($0.2 \rightarrow 0.5$) reduz a taxa de conclusão em 25\%, mas quadruplicar ($0.2 \rightarrow 1.0$) reduz apenas 40\%, sugerindo efeitos de saturação.
\item \textbf{Gargalos identificados}: Os cruzamentos Cr2 e Cr5 funcionam como pontos de convergência, acumulando os maiores tamanhos de fila.
\item \textbf{Tempo de espera dominante}: Em carga intensa, 63\% do tempo no sistema é gasto em filas.
\end{enumerate}
\subsection{Otimizações Testadas}
\subsubsection{Configuração de Ciclos de Semáforos}
Foram testadas diferentes configurações de temporização:
\textbf{Ciclos Longos} (verde 60s, vermelho 5s):
\begin{itemize}
\item Maior vazão (throughput) por ciclo
\item Aumento significativo da espera para direções em vermelho
\item Adequado para tráfego unidirecional dominante
\end{itemize}
\textbf{Ciclos Curtos} (verde 8-10s, vermelho 5s):
\begin{itemize}
\item Distribuição mais equitativa da capacidade
\item Redução da espera máxima
\item Perda de eficiência devido ao overhead de mudanças de estado
\end{itemize}
\textbf{Ciclos Otimizados} (diferenciados por cruzamento):
\begin{itemize}
\item Cr2 e Cr5: verde 30-40s (pontos de convergência)
\item Cr1, Cr3, Cr4: verde 15-20s (tráfego distribuído)
\item Melhor compromisso entre throughput e equidade
\end{itemize}
\subsubsection{Políticas de Encaminhamento}
\textbf{Random}: Baseline - distribuição uniforme da carga mas sem otimização.
\textbf{Shortest Path}: Minimiza latência individual mas pode criar hotspots nos caminhos mais curtos.
\textbf{Least Congested}: Balanceamento dinâmico da carga, requer feedback em tempo real dos cruzamentos. Reduz congestionamento mas pode aumentar latência individual ao escolher caminhos mais longos.
% ============================================================
% DASHBOARD
% ============================================================
\section{Dashboard}
O sistema de monitorização foi implementado utilizando \textbf{JavaFX} para a interface gráfica, fornecendo visualização em tempo real do estado da simulação.
\subsection{Características Principais}
\subsubsection{Interface Gráfica}
\textbf{Estatísticas Globais}: Painel superior com métricas agregadas do sistema
\begin{itemize}
\item Veículos gerados vs. completados
\item Taxa de conclusão em tempo real
\item Throughput atual
\item Tempo médio no sistema
\end{itemize}
\textbf{Tabelas Dinâmicas}:
\begin{itemize}
\item Estatísticas por tipo de veículo (Mota, Carro, Camião)
\item Métricas por interseção (Cr1-Cr5)
\item Tamanhos de fila por direção
\item Estados dos semáforos (cores indicativas)
\end{itemize}
\textbf{Controlos de Simulação}:
\begin{itemize}
\item Botão \textbf{Start}: Inicia todos os processos distribuídos
\item Botão \textbf{Stop}: Termina a simulação graciosamente
\item Indicador de estado do sistema
\item Heartbeat visual para cada processo
\end{itemize}
\subsubsection{Arquitetura de Concorrência}
O \texttt{DashboardServer} utiliza:
\begin{itemize}
\item \textbf{Thread Pool} com 10 threads concorrentes para processar atualizações
\item \texttt{ConcurrentHashMap} para armazenamento thread-safe de métricas
\item \texttt{ScheduledExecutorService} para atualizações periódicas da UI (intervalo de 5 segundos)
\item \texttt{Platform.runLater()} para marshalling seguro de atualizações para a UI thread do JavaFX
\end{itemize}
\subsubsection{Deteção de Falhas}
O sistema implementa monitorização de saúde através de:
\begin{itemize}
\item \textbf{Heartbeats}: Cada processo envia sinais periódicos (intervalo configurável)
\item \textbf{Timeout de conexão}: Identifica processos não-responsivos
\item \textbf{Indicadores visuais}: Marcação a vermelho de nós com falhas
\item \textbf{Logs de eventos}: Registo de todas as anomalias detetadas
\end{itemize}
\subsection{Análise em Batch}
O sistema inclui uma ferramenta de análise estatística (\texttt{MultiRunAnalyzer}) que:
\begin{itemize}
\item Executa múltiplas simulações automaticamente
\item Calcula médias, medianas, desvios padrão e intervalos de confiança (95\%)
\item Gera relatórios em formato texto e CSV
\item Permite comparação entre diferentes configurações
\end{itemize}
% ============================================================
% CONCLUSÃO
% ============================================================
\section{Conclusão}
O trabalho desenvolvido demonstra a implementação bem-sucedida de um sistema distribuído para simulação de tráfego urbano, cumprindo os objetivos pedagógicos da unidade curricular.
\subsection{Principais Conquistas}
\begin{enumerate}
\item \textbf{Arquitetura Distribuída Robusta}: Implementação de comunicação assíncrona entre processos autónomos através de sockets TCP/IP, com serialização JSON garantindo interoperabilidade.
\item \textbf{Modelo de Simulação Realista}: Utilização do modelo de eventos discretos (DES) com distribuição de Poisson para chegadas de veículos, aproximando-se de padrões de tráfego reais.
\item \textbf{Escalabilidade Demonstrada}: O sistema mantém-se funcional desde tráfego leve ($\lambda=0.2$) até tráfego intenso ($\lambda=1.0$), embora com degradação expectável de desempenho em saturação.
\item \textbf{Monitorização Abrangente}: Dashboard com visualização em tempo real e capacidade de análise estatística multi-execução, permitindo avaliação rigorosa do desempenho.
\item \textbf{Políticas de Encaminhamento Adaptativas}: Implementação de três estratégias distintas (Random, Shortest Path, Least Congested) demonstrando flexibilidade arquitetural.
\end{enumerate}
\subsection{Aprendizagens}
\begin{itemize}
\item \textbf{Sincronização Distribuída}: Gestão da complexidade inerente à coordenação de múltiplos processos autónomos sem relógio global centralizado.
\item \textbf{Concorrência e Thread-Safety}: Utilização apropriada de locks, estruturas de dados concorrentes e thread pools para garantir correção em ambiente multi-threaded.
\item \textbf{Trade-offs de Desempenho}: Compreensão das relações não-lineares entre carga de entrada, throughput e latência, especialmente em aproximação à saturação.
\item \textbf{Análise Quantitativa}: Aplicação de métodos estatísticos (intervalos de confiança, análise de variância) para avaliação rigorosa de sistemas estocásticos.
\end{itemize}
\subsection{Limitações e Trabalho Futuro}
\textbf{Limitações identificadas:}
\begin{itemize}
\item Rotas estáticas: Veículos não podem desviar-se em resposta a congestionamento dinâmico
\item Capacidade infinita de filas: Sistema não modela bloqueios físicos por falta de espaço
\item Ausência de prioridades: Todos os veículos são tratados igualmente (sem veículos de emergência)
\item Modelo de semáforos simplificado: Não considera fases de amarelo ou coordenação entre cruzamentos adjacentes
\end{itemize}
\textbf{Melhorias propostas:}
\begin{enumerate}
\item Implementação de encaminhamento adaptativo baseado em aprendizagem por reforço
\item Modelação de capacidades finitas com backpressure entre cruzamentos
\item Coordenação de semáforos através de ``ondas verdes'' para corredores prioritários
\item Integração de eventos externos (acidentes, obras, eventos especiais)
\item Visualização 3D da malha viária com animação de veículos em movimento
\end{enumerate}
\subsection{Conclusão Final}
O projeto cumpre integralmente os requisitos da unidade curricular, demonstrando competências na conceção, implementação e avaliação de sistemas distribuídos. Os resultados quantitativos obtidos através das análises multi-execução fornecem insights valiosos sobre o comportamento do sistema sob diferentes condições de carga, validando a abordagem arquitetural adotada.
A experiência adquirida na resolução de desafios de sincronização, gestão de concorrência e análise de desempenho constitui uma base sólida para o desenvolvimento de sistemas distribuídos de maior complexidade em contextos profissionais futuros.
% ============================================================
% BIBLIOGRAFIA
% ============================================================
\begin{thebibliography}{9}
\bibitem{tanenbaum2017}
Tanenbaum, A. S., \& Van Steen, M. (2017).
\textit{Distributed Systems: Principles and Paradigms} (3rd ed.).
Pearson.
\bibitem{coulouris2011}
Coulouris, G., Dollimore, J., Kindberg, T., \& Blair, G. (2011).
\textit{Distributed Systems: Concepts and Design} (5th ed.).
Addison-Wesley.
\bibitem{banks2009}
Banks, J., Carson, J. S., Nelson, B. L., \& Nicol, D. M. (2009).
\textit{Discrete-Event System Simulation} (5th ed.).
Pearson.
\bibitem{oracle2024java}
Oracle. (2024).
\textit{Java Platform, Standard Edition Documentation} (Version 17).
\url{https://docs.oracle.com/en/java/javase/17/}
\bibitem{goetz2006}
Goetz, B., Peierls, T., Bloch, J., Bowbeer, J., Holmes, D., \& Lea, D. (2006).
\textit{Java Concurrency in Practice}.
Addison-Wesley.
\bibitem{oracle2024javafx}
Oracle. (2024).
\textit{JavaFX Documentation} (Version 17).
\url{https://openjfx.io/javadoc/17/}
\bibitem{google2024gson}
Google. (2024).
\textit{Gson User Guide}.
\url{https://github.com/google/gson/blob/master/UserGuide.md}
\bibitem{law2000}
Law, A. M., \& Kelton, W. D. (2000).
\textit{Simulation Modeling and Analysis} (3rd ed.).
McGraw-Hill.
\end{thebibliography}
\vspace{1cm}
\noindent\textbf{Nota:} Este relatório foi elaborado com base na análise do código-fonte do projeto e nos resultados experimentais obtidos através de múltiplas execuções da simulação. Todos os valores estatísticos apresentados foram extraídos dos ficheiros de análise gerados pelo sistema (\texttt{analysis/LOW\_LOAD\_*.txt}, \texttt{analysis/MEDIUM\_LOAD\_*.txt}, \texttt{analysis/HIGH\_LOAD\_*.txt}).
\end{document}

View File

@@ -1,5 +0,0 @@
Execução,VeículosGerados,VeículosCompletados,TaxaConclusão,TempoMédioSistema,TempoMédioEspera,TempoMínimoSistema,TempoMáximoSistema
1,354,228,64.41,40.36,36.75,20.18,80.72
2,373,261,69.97,40.61,36.87,20.30,81.21
3,353,235,66.57,32.63,29.04,16.32,65.27
4,350,269,76.86,37.39,33.42,18.70,74.78
1 Execução VeículosGerados VeículosCompletados TaxaConclusão TempoMédioSistema TempoMédioEspera TempoMínimoSistema TempoMáximoSistema
2 1 354 228 64.41 40.36 36.75 20.18 80.72
3 2 373 261 69.97 40.61 36.87 20.30 81.21
4 3 353 235 66.57 32.63 29.04 16.32 65.27
5 4 350 269 76.86 37.39 33.42 18.70 74.78

View File

@@ -1,204 +0,0 @@
================================================================================
ANÁLISE ESTATÍSTICA MULTI-EXECUÇÃO
================================================================================
Configuração: simulation-low.properties
Número de Execuções: 4
Data da Análise: 2025-12-08 08:13:57
--------------------------------------------------------------------------------
MÉTRICAS GLOBAIS
--------------------------------------------------------------------------------
Veículos Gerados:
Média: 357.50 Desvio Padrão: 10.47
Mediana: 353.50 IC 95%: [340.84, 374.16]
Mín: 350.00 Máx: 373.00
Veículos Completados:
Média: 248.25 Desvio Padrão: 19.82
Mediana: 248.00 IC 95%: [216.71, 279.79]
Mín: 228.00 Máx: 269.00
Taxa de Conclusão (%):
Média: 69.45 Desvio Padrão: 5.44
Mediana: 68.27 IC 95%: [60.79, 78.11]
Mín: 64.41 Máx: 76.86
Tempo Médio no Sistema (segundos):
Média: 37.75 Desvio Padrão: 3.71
Mediana: 38.87 IC 95%: [31.85, 43.65]
Mín: 32.63 Máx: 40.61
Tempo Médio de Espera (segundos):
Média: 34.02 Desvio Padrão: 3.68
Mediana: 35.08 IC 95%: [28.16, 39.88]
Mín: 29.04 Máx: 36.87
--------------------------------------------------------------------------------
ANÁLISE POR TIPO DE VEÍCULO
--------------------------------------------------------------------------------
--- BIKE ---
Contagem de Veículos:
Média: 52.25 Desvio Padrão: 8.58
Mediana: 54.50 IC 95%: [38.60, 65.90]
Mín: 40.00 Máx: 60.00
Tempo Médio no Sistema (segundos): Sem dados
Tempo Médio de Espera (segundos):
Média: 43.39 Desvio Padrão: 19.65
Mediana: 39.45 IC 95%: [12.12, 74.65]
Mín: 25.04 Máx: 69.63
--- LIGHT ---
Contagem de Veículos:
Média: 151.25 Desvio Padrão: 8.34
Mediana: 152.50 IC 95%: [137.98, 164.52]
Mín: 141.00 Máx: 159.00
Tempo Médio no Sistema (segundos): Sem dados
Tempo Médio de Espera (segundos):
Média: 28.92 Desvio Padrão: 5.34
Mediana: 28.76 IC 95%: [20.43, 37.42]
Mín: 23.35 Máx: 34.82
--- HEAVY ---
Contagem de Veículos:
Média: 44.75 Desvio Padrão: 6.29
Mediana: 44.00 IC 95%: [34.74, 54.76]
Mín: 39.00 Máx: 52.00
Tempo Médio no Sistema (segundos): Sem dados
Tempo Médio de Espera (segundos):
Média: 43.02 Desvio Padrão: 13.73
Mediana: 47.91 IC 95%: [21.18, 64.86]
Mín: 22.83 Máx: 53.43
--------------------------------------------------------------------------------
ANÁLISE POR INTERSEÇÃO
--------------------------------------------------------------------------------
--- Cr1 ---
Tamanho Máximo da Fila:
Média: 0.25 Desvio Padrão: 0.50
Mediana: 0.00 IC 95%: [-0.55, 1.05]
Mín: 0.00 Máx: 1.00
Tamanho Médio da Fila:
Média: 0.25 Desvio Padrão: 0.50
Mediana: 0.00 IC 95%: [-0.55, 1.05]
Mín: 0.00 Máx: 1.00
Veículos Processados:
Média: 105.50 Desvio Padrão: 10.66
Mediana: 103.50 IC 95%: [88.54, 122.46]
Mín: 95.00 Máx: 120.00
--- Cr2 ---
Tamanho Máximo da Fila:
Média: 1.75 Desvio Padrão: 2.87
Mediana: 0.50 IC 95%: [-2.82, 6.32]
Mín: 0.00 Máx: 6.00
Tamanho Médio da Fila:
Média: 1.75 Desvio Padrão: 2.87
Mediana: 0.50 IC 95%: [-2.82, 6.32]
Mín: 0.00 Máx: 6.00
Veículos Processados:
Média: 119.00 Desvio Padrão: 11.17
Mediana: 122.50 IC 95%: [101.24, 136.76]
Mín: 103.00 Máx: 128.00
--- Cr3 ---
Tamanho Máximo da Fila: Sem dados
Tamanho Médio da Fila: Sem dados
Veículos Processados:
Média: 114.75 Desvio Padrão: 15.88
Mediana: 119.00 IC 95%: [89.48, 140.02]
Mín: 93.00 Máx: 128.00
--- Cr4 ---
Tamanho Máximo da Fila:
Média: 1.25 Desvio Padrão: 0.50
Mediana: 1.00 IC 95%: [0.45, 2.05]
Mín: 1.00 Máx: 2.00
Tamanho Médio da Fila:
Média: 1.25 Desvio Padrão: 0.50
Mediana: 1.00 IC 95%: [0.45, 2.05]
Mín: 1.00 Máx: 2.00
Veículos Processados:
Média: 63.00 Desvio Padrão: 11.75
Mediana: 62.00 IC 95%: [44.31, 81.69]
Mín: 50.00 Máx: 78.00
--- Cr5 ---
Tamanho Máximo da Fila:
Média: 4.50 Desvio Padrão: 2.89
Mediana: 4.50 IC 95%: [-0.09, 9.09]
Mín: 1.00 Máx: 8.00
Tamanho Médio da Fila:
Média: 4.50 Desvio Padrão: 2.89
Mediana: 4.50 IC 95%: [-0.09, 9.09]
Mín: 1.00 Máx: 8.00
Veículos Processados:
Média: 123.00 Desvio Padrão: 24.18
Mediana: 116.50 IC 95%: [84.53, 161.47]
Mín: 103.00 Máx: 156.00
--- ExitNode ---
Tamanho Máximo da Fila: Sem dados
Tamanho Médio da Fila: Sem dados
Veículos Processados:
Média: 248.25 Desvio Padrão: 19.82
Mediana: 248.00 IC 95%: [216.71, 279.79]
Mín: 228.00 Máx: 269.00
--------------------------------------------------------------------------------
RESUMOS INDIVIDUAIS DAS EXECUÇÕES
--------------------------------------------------------------------------------
Execução #1 [simulation-low.properties]:
Gerados: 354, Completados: 228 (64.4%)
Tempo Médio no Sistema: 40.36s
Tempo Médio de Espera: 36.75s
Execução #2 [simulation-low.properties]:
Gerados: 373, Completados: 261 (70.0%)
Tempo Médio no Sistema: 40.61s
Tempo Médio de Espera: 36.87s
Execução #3 [simulation-low.properties]:
Gerados: 353, Completados: 235 (66.6%)
Tempo Médio no Sistema: 32.63s
Tempo Médio de Espera: 29.04s
Execução #4 [simulation-low.properties]:
Gerados: 350, Completados: 269 (76.9%)
Tempo Médio no Sistema: 37.39s
Tempo Médio de Espera: 33.42s
================================================================================
FIM DO RELATÓRIO
================================================================================

View File

@@ -83,6 +83,19 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Maven Javadoc Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.12.0</version>
<configuration>
<source>17</source>
<encoding>UTF-8</encoding>
<doclint>none</doclint>
<failOnError>false</failOnError>
<failOnWarnings>false</failOnWarnings>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>