Skip to content

Commit

Permalink
Мультидокумент (kruzhok-team#423)
Browse files Browse the repository at this point in the history
Полный рефакторинг работы с данными, теперь разные сущности отвечают за работу с моделью данных и за работу с их отображением на канвасе
Возможность редактирования нескольких машин состояний одновременно
Количество редакторов теперь не ограничено
Теперь к каждому канвасу прикрепляется CanvasController, отвечающий за данные для отрисовки
Появился класс ModelController, который посредством сигналов передает события об изменениях в данных в CanvasController, который на эти данные подписаны
Появился схемотехнический экран, содержащий информацию обо всех компонентах каждой МС

---------
Co-authored-by: XidFanSan <fedya4444baskov.ru@gmail.com>
Co-authored-by: Roundabout1 <86153878+Roundabout1@users.noreply.github.com>
  • Loading branch information
L140-beep authored Nov 19, 2024
1 parent 83ded55 commit 01ee3a5
Show file tree
Hide file tree
Showing 125 changed files with 8,679 additions and 3,726 deletions.
10 changes: 5 additions & 5 deletions demos/CyberiadaSchemas/CyberiadaFormat-Blinker.graphml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pin/ 12
<node id="ctimer1">
<data key="dNote">formal</data>
<data key="dName"> CGML_COMPONENT </data>
<data key="dData">id/ timer1
<data key="dData">id/ Timer1

type/ Timer

Expand All @@ -73,7 +73,7 @@ description/ Программный таймер.
<data key="dName">Включен</data>
<data key="dData">entry/
LED1.on()
timer1.start(1000)
Timer1.start(1000)

</data>
<data key="dGeometry">
Expand All @@ -85,7 +85,7 @@ timer1.start(1000)
<data key="dName">Выключен</data>
<data key="dData">entry/
LED1.off()
timer1.start(1000)
Timer1.start(1000)

</data>
<data key="dGeometry">
Expand All @@ -108,13 +108,13 @@ timer1.start(1000)
<data key="dPivot"/>
</edge>
<edge id="edge3" source="diod1" target="diod2">
<data key="dData">timer1.timeout/</data>
<data key="dData">Timer1.timeout/</data>
<data key="dLabelGeometry">
<point x="389" y="193"/>
</data>
</edge>
<edge id="edge4" source="diod2" target="diod1">
<data key="dData">timer1.timeout/</data>
<data key="dData">Timer1.timeout/</data>
<data key="dLabelGeometry">
<point x="81.5" y="193.46"/>
</data>
Expand Down
236 changes: 236 additions & 0 deletions demos/blinker.graphml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">

<key id="gFormat" for="graphml" attr.name="format"
attr.type="string"/>
<key id="dName" for="node" attr.name="name" attr.type="string"/>
<key id="dVertex" for="node" attr.name="vertex" attr.type="string"/>
<key id="dStateMachine" for="graph" attr.name="stateMachine" attr.type="string"/>
<key id="dGeometry" for="node" attr.name="geometry"/>
<key id="dLabelGeometry" for="edge" attr.name="labelGeometry"/>
<key id="dPivot" for="edge" attr.name="pivot" attr.type="string"/>
<key id="dNote" for="node" attr.name="note" attr.type="string"/>
<key id="dData" for="node" attr.name="data" attr.type="string"/>
<key id="dData" for="edge" attr.name="data" attr.type="string"/>
<key id="dColor" for="edge" attr.name="color" attr.type="string"/>

<data key="gFormat">Cyberiada-GraphML-1.0</data>

<graph id="G" edgedefault="directed">
<data key="dStateMachine"/>
<node id="coreMeta">
<data key="dNote">formal</data>
<data key="dName">CGML_META</data>
<data key="dData">platform/ ArduinoUno

standardVersion/ 1.0

name/ Arduino Blinker

author/ Lapki IDE TEAM

description/ Включение и выключение лампочки по таймеру

</data>
</node>
<node id="cLED1">
<data key="dNote">formal</data>
<data key="dName"> CGML_COMPONENT </data>
<data key="dData">id/ LEDG1

type/ LED

name/ Светодиод

description/ Встроенный в плату светодиод, чтобы им мигать

pin/ 12

</data>
</node>

<node id="ctimer1">
<data key="dNote">formal</data>
<data key="dName"> CGML_COMPONENT </data>
<data key="dData">id/ timerG1

type/ Timer

name/ Таймер

description/ Программный таймер.

</data>
</node>

<node id="init">
<data key="dVertex">initial</data>
<data key="dGeometry">
<point x="20" y="30"> </point>
</data>
</node>

<node id="diod1">
<data key="dName">Включен</data>
<data key="dData">entry/
LEDG1.on()
timerG1.start(1000)

</data>
<data key="dGeometry">
<rect x="82" y="57" width="450.0" height="95"/>
</data>
</node>

<node id="diod2">
<data key="dName">Выключен</data>
<data key="dData">entry/
LEDG1.off()
timerG1.start(1000)

</data>
<data key="dGeometry">
<rect x="81" y="334" width="450" height="95" />
</data>
</node>

<node id="commentX">
<data key="dNote"/>
<data key="dData"> Включение и выключение лампочки по таймеру в МС G! </data>
<data key="dGeometry">
<point x="640" y="114" />
</data>
</node>
<edge id="init-edge" source="init" target="diod1"/>
<edge id="edge0" source="coreMeta" target="ctimer1">
<data key="dPivot"/>
</edge>
<edge id="edge1" source="coreMeta" target="cLED1">
<data key="dPivot"/>
</edge>
<edge id="edge3" source="diod1" target="diod2">
<data key="dData">timerG1.timeout/</data>
<data key="dColor">#F29727</data>
<data key="dLabelGeometry">
<point x="389" y="193"/>
</data>
</edge>
<edge id="edge4" source="diod2" target="diod1">
<data key="dData">timerG1.timeout/</data>
<data key="dLabelGeometry">
<point x="81.5" y="193.46"/>
</data>
<data key="dColor">#F24C3D</data>
</edge>
</graph>


<graph id="A" edgedefault="directed">
<data key="dStateMachine"/>
<node id="coreMeta">
<data key="dNote">formal</data>
<data key="dName">CGML_META</data>
<data key="dData">platform/ ArduinoUno

standardVersion/ 1.0

name/ Arduino Blinker

author/ Lapki IDE TEAM

description/ Включение и выключение лампочки по таймеру

</data>
</node>
<node id="cLEDA1">
<data key="dNote">formal</data>
<data key="dName"> CGML_COMPONENT </data>
<data key="dData">id/ LED1

type/ LED

name/ Светодиод

description/ Встроенный в плату светодиод, чтобы им мигать

pin/ 12

</data>
</node>

<node id="ctimerA1">
<data key="dNote">formal</data>
<data key="dName"> CGML_COMPONENT </data>
<data key="dData">id/ timer1

type/ Timer

name/ Таймер

description/ Программный таймер.

</data>
</node>

<node id="Ainit">
<data key="dVertex">initial</data>
<data key="dGeometry">
<point x="20" y="30"> </point>
</data>
</node>

<node id="Adiod1">
<data key="dName">Включен</data>
<data key="dData">entry/
LED1.on()
timer1.start(1000)

</data>
<data key="dGeometry">
<rect x="82" y="57" width="450.0" height="95"/>
</data>
</node>

<node id="Adiod2">
<data key="dName">Выключен</data>
<data key="dData">entry/
LED1.off()
timer1.start(1000)

</data>
<data key="dGeometry">
<rect x="81" y="334" width="450" height="95" />
</data>
</node>

<node id="AcommentX">
<data key="dNote"/>
<data key="dData"> Включение и выключение лампочки по таймеру в МС A! </data>
<data key="dGeometry">
<point x="640" y="114" />
</data>
</node>
<edge id="Ainit-edge" source="Ainit" target="Adiod1"/>
<edge id="Aedge0" source="coreMeta" target="ctimer1">
<data key="dPivot"/>
</edge>
<edge id="Aedge1" source="coreMeta" target="cLED1">
<data key="dPivot"/>
</edge>
<edge id="Aedge3" source="Adiod1" target="Adiod2">
<data key="dData">timer1.timeout/</data>
<data key="dColor">#F29727</data>
<data key="dLabelGeometry">
<point x="389" y="193"/>
</data>
</edge>
<edge id="Aedge4" source="Adiod2" target="Adiod1">
<data key="dData">timer1.timeout/</data>
<data key="dLabelGeometry">
<point x="81.5" y="193.46"/>
</data>
<data key="dColor">#F24C3D</data>
</edge>
</graph>

</graphml>
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@electron-toolkit/utils": "^1.0.2",
"@floating-ui/react": "^0.26.9",
"@floating-ui/react-dom": "^2.0.8",
"@kruzhok-team/cyberiadaml-js": "^1.1.5",
"@kruzhok-team/cyberiadaml-js": "^1.1.7",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-switch": "^1.0.3",
"@tweenjs/tween.js": "^23.1.1",
Expand Down
4 changes: 4 additions & 0 deletions schema/Elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"Component": {
"additionalProperties": false,
"properties": {
"position": {
"$ref": "#/definitions/Point"
},
"parameters": {
"additionalProperties": {
"type": "string"
Expand All @@ -62,6 +65,7 @@
},
"required": [
"type",
"position",
"parameters"
],
"type": "object"
Expand Down
7 changes: 6 additions & 1 deletion schema/Platforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
"description": {
"type": "string"
},
"position": {
"$ref": "#/definitions/Point"
},
"img": {
"type": "string"
},
Expand Down Expand Up @@ -125,7 +128,9 @@
"required": [
"signals",
"variables",
"methods"
"position",
"methods",
"parameters"
],
"type": "object"
},
Expand Down
2 changes: 1 addition & 1 deletion src/main/modules/ModuleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ModuleManager {
chprocess = spawn(modulePath);
}
chprocess.on('error', function (err) {
if (err.code == 'ENOENT') {
if (err.code === 'ENOENT') {
ModuleManager.moduleStatus.set(
module,
new ModuleStatus(2, `Файл ${modulePath} не найден.`)
Expand Down
1 change: 1 addition & 0 deletions src/renderer/public/img/common/statemachine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { useRef } from 'react';

import { MainContainer } from '@renderer/components';
import { CanvasEditor } from '@renderer/lib/CanvasEditor';

import { EditorContext } from './store/EditorContext';
import { ModelController } from './lib/data/ModelController';
import { ModelContext } from './store/ModelContext';

// TODO: а если у нас будет несколько редакторов?
export const App: React.FC = () => {
const { current: editor } = useRef(new CanvasEditor());

const { current: modelController } = useRef(ModelController.instance ?? new ModelController());
return (
<EditorContext.Provider value={editor}>
<ModelContext.Provider value={modelController}>
<MainContainer />
</EditorContext.Provider>
</ModelContext.Provider>
);
};
Loading

0 comments on commit 01ee3a5

Please sign in to comment.