Skip to content

Commit 36dd186

Browse files
authored
Merge pull request #12 from riclolsen/master
Project IDX
2 parents 96f146b + 2d79f63 commit 36dd186

File tree

10 files changed

+2010
-128
lines changed

10 files changed

+2010
-128
lines changed

.idx/dev.nix

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,48 @@
7979
onCreate = {
8080
init-mongodb = "
8181
rm -rf ~/.emu/avd
82-
mkdir -p /mnt/ephemeral/mongodb/var/lib/mongo/ &&
83-
mkdir -p /mnt/ephemeral/mongodb/var/log/mongodb/ &&
82+
rm -rf ~/.androidsdkroot/* &&
83+
mkdir -p ~/mongodb/var/lib/mongo/ &&
84+
mkdir -p ~/mongodb/var/log/mongodb/ &&
8485
mongod -f ~/json-scada/platform-nix-idx/mongod.conf &&
8586
mongosh json_scada < ~/json-scada/mongo_seed/a_rs-init.js &&
8687
mongosh json_scada < ~/json-scada/mongo_seed/b_create-db.js &&
8788
mongoimport --db json_scada --collection protocolDriverInstances --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_instances.json &&
89+
mongoimport --db json_scada --collection protocolConnections --type json --file ~/json-scada/platform-nix-idx/demo_connections.json &&
8890
mongoimport --db json_scada --collection protocolConnections --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_connections_linux.json &&
8991
mongoimport --db json_scada --collection realtimeData --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_data.json &&
9092
mongoimport --db json_scada --collection processInstances --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_process_instances.json &&
93+
mongoimport --db json_scada --collection roles --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_roles.json &&
9194
mongoimport --db json_scada --collection users --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_users.json
9295
";
9396
init-postgresql = "
97+
mkdir -p ~/json-scada/grafana/data &&
98+
mkdir -p ~/json-scada/grafana/logs &&
99+
mkdir -p ~/json-scada/grafana/plugins &&
100+
mkdir -p ~/json-scada/log &&
94101
mkdir -p ~/postgres &&
95102
initdb -D ~/postgres &&
96103
cp ~/json-scada/platform-nix-idx/postgresql.conf ~/postgres/postgresql.conf &&
97104
cp ~/json-scada/platform-nix-idx/pg_hba.conf ~/postgres/pg_hba.conf &&
98-
/usr/bin/pg_ctl -D /home/user/postgres start &&
99-
/usr/bin/createuser -h localhost -s postgres &&
105+
/usr/bin/pg_ctl -D ~/postgres start >/dev/null 2>&1 &&
106+
/usr/bin/createuser -h localhost -s postgres ;
100107
psql -U postgres -w -h localhost -f ~/json-scada/sql/create_tables.sql template1 &&
101108
psql -U postgres -w -h localhost -f ~/json-scada/sql/metabaseappdb.sql metabaseappdb &&
102109
psql -U postgres -w -h localhost -f ~/json-scada/sql/grafanaappdb.sql grafanaappdb
103110
";
104-
build-jsonscada = "cd ~/json-scada/platform-linux && ./build.sh";
111+
build-jsonscada = "
112+
cd ~/json-scada/platform-nix-idx &&
113+
sh ./build.sh
114+
";
105115
};
106116
# Runs when the workspace is (re)started
107117
onStart = {
108118
# Example: start a background task to watch and re-build backend code
109119
# watch-backend = "npm run watch-backend";
110120
start-mongodb = "/usr/bin/mongod -f ~/json-scada/platform-nix-idx/mongod.conf";
111-
start-supervisor = "(supervisord -c ~/json-scada/platform-nix-idx/supervisord.conf &)";
121+
start-postgresql = "/usr/bin/pg_ctl -D ~/postgres start >/dev/null 2>&1";
122+
start-grafana = "grafana server target --config ~/json-scada/platform-nix-idx/grafana.ini --homepath /nix/store/454jp6ww3nr2k7jxfp4il4a3l9kq0l3h-grafana-10.2.8/share/grafana/ >/dev/null 2>&1 &";
123+
start-supervisor = "supervisord -c ~/json-scada/platform-nix-idx/supervisord.conf";
112124
};
113125
};
114126
};

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
171171
- [x] Install Script for RedHat/Rocky 9.4 Linux x86-64 and arm64
172172
- [ ] Linux Image / VM
173173
- [x] Supervisor (Linux process manager) examples
174-
- [ ] Project IDX Configuration
174+
- [x] Project IDX Configuration
175175
- [ ] InfluxDB Integration
176176
- [x] Telegraf Integration
177177
- [ ] Kafka Integration
@@ -186,6 +186,12 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
186186
- [ ] Managed Cloud Service
187187
- [ ] Supported LTS versions
188188

189+
## Spin up a free private instance on Google's Project IDX
190+
191+
With just a Google account, you can spin up a free private instance for test/dev on Google's Project IDX. This is a great way to get started with the project. This will build the code from the Github repo and deploy it to a private Linux VM on the cloud running protocols and providing a web UI for you to interact with. There will be a web-based code editor available for you to develop new apps and view/change the code on the VM. You can also get help from Google's Gemini AI for coding and other tasks. This is free and there no need to install any software on your local machine.
192+
193+
See details [here](https://github.com/riclolsen/json-scada/blob/master/platform-nix-idx/README.md).
194+
189195
## Online Demo (substations simulation)
190196

191197
- http://150.230.171.172

index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
173173
- [x] Install Script for RedHat/Rocky 9.4 Linux x86-64 and arm64
174174
- [ ] Linux Image / VM
175175
- [x] Supervisor (Linux process manager) examples
176-
- [ ] Project IDX Configuration
176+
- [x] Project IDX Configuration
177177
- [ ] InfluxDB Integration
178178
- [x] Telegraf Integration
179179
- [ ] Kafka Integration
@@ -188,6 +188,12 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
188188
- [ ] Managed Cloud Service
189189
- [ ] Supported LTS versions
190190

191+
## Spin up a free private instance on Google's Project IDX
192+
193+
With just a Google account, you can spin up a free private instance for test/dev on Google's Project IDX. This is a great way to get started with the project. This will build the code from the Github repo and deploy it to a private Linux VM on the cloud running protocols and providing a web UI for you to interact with. There will be a web-based code editor available for you to develop new apps and view/change the code on the VM. You can also get help from Google's Gemini AI for coding and other tasks. This is free and there no need to install any software on your local machine.
194+
195+
See details [here](platform-nix-idx/README.md).
196+
191197
## Online Demo (substations simulation)
192198

193199
- http://150.230.171.172

platform-nix-idx/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Project IDX Setup
2+
3+
Start a free instance for dev/test on Google's Project IDX platform with just a Google account.
4+
5+
1. Access the Project IDX platform, click on the "Get Started" button. Connect your Google account if asked.
6+
7+
[https://idx.dev](https://idx.dev)
8+
9+
2. Create a new Workspace importing a GitHub repository.
10+
11+
* URL: https://github.com/riclolsen/json-scada
12+
* Name: json-scada
13+
14+
Alternatively, you can fork the repo on Github and import it from there.
15+
16+
3. Wait for the workspace to be imported and built. This will take a while, do not click the recover button. When started, some terminals will open to initialize and build the project. Wait until all the tasks are finished and the workspace is ready. This will take some minutes.
17+
18+
4. Click the Project IDX button on left sidebar and select "Backend Ports". Click the "Open New Window" action for port 8080. This will give access to the web UI for the project. Login with admin/jsonscada credentials.
19+
20+
5. On the VSCode's terminal, control JSON-SCADA processes with the "supervisorctl" command.
21+
22+
```bash
23+
supervisorctl status
24+
supervisorctl start all
25+
supervisorctl stop all
26+
supervisorctl restart all
27+
supervisorctl stop iec104client
28+
supervisorctl start iec104client
29+
supervisorctl tail -f iec104client
30+
```
31+
32+
Open the Gemini chat with Ctrl+Shift+Space.
33+
34+
Notice that the provided free VM is a constrained environment with limited resources: 8GB RAM, 1-core CPUs, 10GB Disk.
35+
36+
More info for Project IDX [here](https://developers.google.com/idx).

platform-nix-idx/build.sh

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
3+
# Required tools:
4+
# Dotnet SDK 8.0+
5+
# Golang 1.21+
6+
# Node.js 20+
7+
8+
# call with argument linux-arm64 for ARM architecture
9+
10+
ARG1=${1:-linux-x64}
11+
12+
cd ..
13+
mkdir bin
14+
mkdir bin-wine
15+
16+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
17+
18+
# Dnp3Client is Windows-only (must run under Wine on Linux)
19+
#cp src/dnp3/Dnp3Client/Dependencies/OpenSSL/*.dll bin-wine/
20+
#cd src/dnp3/Dnp3Client
21+
#dotnet publish --self-contained --runtime win-x64 -p:PublishReadyToRun=true -c Release -o ../../../bin-wine/ Dnp3Client.csproj
22+
23+
cd src/libiec61850
24+
mkdir build
25+
cd build
26+
cmake ..
27+
make
28+
cp src/libiec61850.so src/libiec61850.so.1.6.0 ../../../bin/
29+
cd ../dotnet/core/2.0/IEC61850.NET.core.2.0
30+
dotnet publish --no-self-contained --runtime $ARG1 -c Release
31+
cd ../../../../../iec61850_client
32+
dotnet publish --no-self-contained --runtime $ARG1 -p:PublishReadyToRun=true -c Release -o ../../bin/
33+
34+
cd ../lib60870.netcore
35+
dotnet publish --no-self-contained --runtime $ARG1 -p:PublishReadyToRun=true -c Release -o ../../bin/
36+
37+
cd ../OPC-UA-Client
38+
dotnet restore
39+
dotnet publish --no-self-contained --runtime $ARG1 -p:PublishReadyToRun=true -c Release -o ../../bin/
40+
41+
#cd ../opcdaaehda-client-solution-net
42+
#dotnet build -f net8.0-windows DaAeHdaNetStandard.sln
43+
44+
#cd ../OPC-DA-Client
45+
#dotnet restore
46+
#dotnet publish --no-self-contained --runtime win-x64 -p:PublishReadyToRun=true -f net8.0-windows -c Release -o ../../bin-wine/ OPC-DA-Client.csproj
47+
48+
export GOBIN=~/json-scada/bin
49+
go env -w GO111MODULE=auto
50+
51+
cd ../calculations
52+
go mod tidy
53+
go build
54+
cp calculations ../../bin/
55+
56+
#cd ../i104m
57+
#go mod tidy
58+
#go build
59+
#cp i104m ../../bin/
60+
61+
cd ../plc4x-client
62+
go mod tidy
63+
go build
64+
cp plc4x-client ../../bin/
65+
66+
# release some disk space
67+
rm -rf ~/.cache
68+
rm -rf ~/.nuget
69+
70+
cd ../cs_data_processor
71+
npm install
72+
cd ../cs_custom_processor
73+
npm install
74+
cd ../grafana_alert2event
75+
npm install
76+
cd ../demo_simul
77+
npm install
78+
cd ../server_realtime_auth
79+
npm install
80+
cd ../updateUser
81+
npm install
82+
cd ../oshmi2json
83+
npm install
84+
cd ../oshmi_sync
85+
npm install
86+
cd ../shell-api
87+
npm install
88+
cd ../alarm_beep
89+
npm install
90+
cd ../telegraf-listener
91+
npm install
92+
cd ../mqtt-sparkplug
93+
npm install
94+
cd ../OPC-UA-Server
95+
npm install
96+
cd ../carbone-reports
97+
npm install
98+
cd ../backup-mongo
99+
npm install
100+
cd ../mongofw
101+
npm install
102+
cd ../mongowr
103+
npm install
104+
105+
cd ../AdminUI
106+
npm install
107+
npm run build
108+
rm -rf ~/json-scada/src/AdminUI/node_modules
109+
110+
#cd ../log-io/ui
111+
#npm install
112+
#npm run build
113+
#cd ../server
114+
#npm install
115+
#npm run build
116+
#cd ../inputs/file
117+
#npm install
118+
#npm run build
119+
120+
export NODE_OPTIONS=--max-old-space-size=10000
121+
122+
cd ../custom-developments/basic_bargraph
123+
npm install
124+
npm run build
125+
126+
# release some disk space
127+
rm -rf ~/json-scada/src/custom-developments/basic_bargraph/node_modules
128+
129+
cd ../../custom-developments/advanced_dashboard
130+
npm install
131+
npm run build
132+
133+
# release some disk space
134+
rm -rf ~/json-scada/src/custom-developments/advanced_dashboard/node_modules
135+
136+
cd ../../custom-developments/transformer_with_command
137+
npm install
138+
npm run build
139+
140+
# release some disk space
141+
rm -rf ~/json-scada/src/custom-developments/transformer_with_commands/node_modules
142+
143+
cd ~/json-scada/platform-nix-idx
144+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_id":{"$oid":"5ff3512268d80d68205b403f"},"protocolDriver":"OPC-UA","protocolDriverInstanceNumber":1,"protocolConnectionNumber":1003,"name":"OPCClient1","description":"OPC Client 1","enabled":true,"commandsEnabled":true,"endpointURLs":["opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"],"configFileName":"/home/user/json-scada/conf/Opc.Ua.DefaultClient.Config.xml","autoCreateTags":true,"useSecurity":false,"stats":null}

platform-nix-idx/dev.nix

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)