Skip to content

Commit

Permalink
Merge pull request #12 from riclolsen/master
Browse files Browse the repository at this point in the history
Project IDX
  • Loading branch information
riclolsen authored Dec 5, 2024
2 parents 96f146b + 2d79f63 commit 36dd186
Show file tree
Hide file tree
Showing 10 changed files with 2,010 additions and 128 deletions.
24 changes: 18 additions & 6 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,36 +79,48 @@
onCreate = {
init-mongodb = "
rm -rf ~/.emu/avd
mkdir -p /mnt/ephemeral/mongodb/var/lib/mongo/ &&
mkdir -p /mnt/ephemeral/mongodb/var/log/mongodb/ &&
rm -rf ~/.androidsdkroot/* &&
mkdir -p ~/mongodb/var/lib/mongo/ &&
mkdir -p ~/mongodb/var/log/mongodb/ &&
mongod -f ~/json-scada/platform-nix-idx/mongod.conf &&
mongosh json_scada < ~/json-scada/mongo_seed/a_rs-init.js &&
mongosh json_scada < ~/json-scada/mongo_seed/b_create-db.js &&
mongoimport --db json_scada --collection protocolDriverInstances --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_instances.json &&
mongoimport --db json_scada --collection protocolConnections --type json --file ~/json-scada/platform-nix-idx/demo_connections.json &&
mongoimport --db json_scada --collection protocolConnections --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_connections_linux.json &&
mongoimport --db json_scada --collection realtimeData --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_data.json &&
mongoimport --db json_scada --collection processInstances --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_process_instances.json &&
mongoimport --db json_scada --collection roles --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_roles.json &&
mongoimport --db json_scada --collection users --type json --file ~/json-scada/demo-docker/mongo_seed/files/demo_users.json
";
init-postgresql = "
mkdir -p ~/json-scada/grafana/data &&
mkdir -p ~/json-scada/grafana/logs &&
mkdir -p ~/json-scada/grafana/plugins &&
mkdir -p ~/json-scada/log &&
mkdir -p ~/postgres &&
initdb -D ~/postgres &&
cp ~/json-scada/platform-nix-idx/postgresql.conf ~/postgres/postgresql.conf &&
cp ~/json-scada/platform-nix-idx/pg_hba.conf ~/postgres/pg_hba.conf &&
/usr/bin/pg_ctl -D /home/user/postgres start &&
/usr/bin/createuser -h localhost -s postgres &&
/usr/bin/pg_ctl -D ~/postgres start >/dev/null 2>&1 &&
/usr/bin/createuser -h localhost -s postgres ;
psql -U postgres -w -h localhost -f ~/json-scada/sql/create_tables.sql template1 &&
psql -U postgres -w -h localhost -f ~/json-scada/sql/metabaseappdb.sql metabaseappdb &&
psql -U postgres -w -h localhost -f ~/json-scada/sql/grafanaappdb.sql grafanaappdb
";
build-jsonscada = "cd ~/json-scada/platform-linux && ./build.sh";
build-jsonscada = "
cd ~/json-scada/platform-nix-idx &&
sh ./build.sh
";
};
# Runs when the workspace is (re)started
onStart = {
# Example: start a background task to watch and re-build backend code
# watch-backend = "npm run watch-backend";
start-mongodb = "/usr/bin/mongod -f ~/json-scada/platform-nix-idx/mongod.conf";
start-supervisor = "(supervisord -c ~/json-scada/platform-nix-idx/supervisord.conf &)";
start-postgresql = "/usr/bin/pg_ctl -D ~/postgres start >/dev/null 2>&1";
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 &";
start-supervisor = "supervisord -c ~/json-scada/platform-nix-idx/supervisord.conf";
};
};
};
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
- [x] Install Script for RedHat/Rocky 9.4 Linux x86-64 and arm64
- [ ] Linux Image / VM
- [x] Supervisor (Linux process manager) examples
- [ ] Project IDX Configuration
- [x] Project IDX Configuration
- [ ] InfluxDB Integration
- [x] Telegraf Integration
- [ ] Kafka Integration
Expand All @@ -186,6 +186,12 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
- [ ] Managed Cloud Service
- [ ] Supported LTS versions

## Spin up a free private instance on Google's Project IDX

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.

See details [here](https://github.com/riclolsen/json-scada/blob/master/platform-nix-idx/README.md).

## Online Demo (substations simulation)

- http://150.230.171.172
Expand Down
8 changes: 7 additions & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
- [x] Install Script for RedHat/Rocky 9.4 Linux x86-64 and arm64
- [ ] Linux Image / VM
- [x] Supervisor (Linux process manager) examples
- [ ] Project IDX Configuration
- [x] Project IDX Configuration
- [ ] InfluxDB Integration
- [x] Telegraf Integration
- [ ] Kafka Integration
Expand All @@ -188,6 +188,12 @@ To provide an easy to use, fully-featured, scalable, and portable SCADA/IIoT-I4.
- [ ] Managed Cloud Service
- [ ] Supported LTS versions

## Spin up a free private instance on Google's Project IDX

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.

See details [here](platform-nix-idx/README.md).

## Online Demo (substations simulation)

- http://150.230.171.172
Expand Down
36 changes: 36 additions & 0 deletions platform-nix-idx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Project IDX Setup

Start a free instance for dev/test on Google's Project IDX platform with just a Google account.

1. Access the Project IDX platform, click on the "Get Started" button. Connect your Google account if asked.

[https://idx.dev](https://idx.dev)

2. Create a new Workspace importing a GitHub repository.

* URL: https://github.com/riclolsen/json-scada
* Name: json-scada

Alternatively, you can fork the repo on Github and import it from there.

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.

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.

5. On the VSCode's terminal, control JSON-SCADA processes with the "supervisorctl" command.

```bash
supervisorctl status
supervisorctl start all
supervisorctl stop all
supervisorctl restart all
supervisorctl stop iec104client
supervisorctl start iec104client
supervisorctl tail -f iec104client
```

Open the Gemini chat with Ctrl+Shift+Space.

Notice that the provided free VM is a constrained environment with limited resources: 8GB RAM, 1-core CPUs, 10GB Disk.

More info for Project IDX [here](https://developers.google.com/idx).
144 changes: 144 additions & 0 deletions platform-nix-idx/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash

# Required tools:
# Dotnet SDK 8.0+
# Golang 1.21+
# Node.js 20+

# call with argument linux-arm64 for ARM architecture

ARG1=${1:-linux-x64}

cd ..
mkdir bin
mkdir bin-wine

export DOTNET_CLI_TELEMETRY_OPTOUT=1

# Dnp3Client is Windows-only (must run under Wine on Linux)
#cp src/dnp3/Dnp3Client/Dependencies/OpenSSL/*.dll bin-wine/
#cd src/dnp3/Dnp3Client
#dotnet publish --self-contained --runtime win-x64 -p:PublishReadyToRun=true -c Release -o ../../../bin-wine/ Dnp3Client.csproj

cd src/libiec61850
mkdir build
cd build
cmake ..
make
cp src/libiec61850.so src/libiec61850.so.1.6.0 ../../../bin/
cd ../dotnet/core/2.0/IEC61850.NET.core.2.0
dotnet publish --no-self-contained --runtime $ARG1 -c Release
cd ../../../../../iec61850_client
dotnet publish --no-self-contained --runtime $ARG1 -p:PublishReadyToRun=true -c Release -o ../../bin/

cd ../lib60870.netcore
dotnet publish --no-self-contained --runtime $ARG1 -p:PublishReadyToRun=true -c Release -o ../../bin/

cd ../OPC-UA-Client
dotnet restore
dotnet publish --no-self-contained --runtime $ARG1 -p:PublishReadyToRun=true -c Release -o ../../bin/

#cd ../opcdaaehda-client-solution-net
#dotnet build -f net8.0-windows DaAeHdaNetStandard.sln

#cd ../OPC-DA-Client
#dotnet restore
#dotnet publish --no-self-contained --runtime win-x64 -p:PublishReadyToRun=true -f net8.0-windows -c Release -o ../../bin-wine/ OPC-DA-Client.csproj

export GOBIN=~/json-scada/bin
go env -w GO111MODULE=auto

cd ../calculations
go mod tidy
go build
cp calculations ../../bin/

#cd ../i104m
#go mod tidy
#go build
#cp i104m ../../bin/

cd ../plc4x-client
go mod tidy
go build
cp plc4x-client ../../bin/

# release some disk space
rm -rf ~/.cache
rm -rf ~/.nuget

cd ../cs_data_processor
npm install
cd ../cs_custom_processor
npm install
cd ../grafana_alert2event
npm install
cd ../demo_simul
npm install
cd ../server_realtime_auth
npm install
cd ../updateUser
npm install
cd ../oshmi2json
npm install
cd ../oshmi_sync
npm install
cd ../shell-api
npm install
cd ../alarm_beep
npm install
cd ../telegraf-listener
npm install
cd ../mqtt-sparkplug
npm install
cd ../OPC-UA-Server
npm install
cd ../carbone-reports
npm install
cd ../backup-mongo
npm install
cd ../mongofw
npm install
cd ../mongowr
npm install

cd ../AdminUI
npm install
npm run build
rm -rf ~/json-scada/src/AdminUI/node_modules

#cd ../log-io/ui
#npm install
#npm run build
#cd ../server
#npm install
#npm run build
#cd ../inputs/file
#npm install
#npm run build

export NODE_OPTIONS=--max-old-space-size=10000

cd ../custom-developments/basic_bargraph
npm install
npm run build

# release some disk space
rm -rf ~/json-scada/src/custom-developments/basic_bargraph/node_modules

cd ../../custom-developments/advanced_dashboard
npm install
npm run build

# release some disk space
rm -rf ~/json-scada/src/custom-developments/advanced_dashboard/node_modules

cd ../../custom-developments/transformer_with_command
npm install
npm run build

# release some disk space
rm -rf ~/json-scada/src/custom-developments/transformer_with_commands/node_modules

cd ~/json-scada/platform-nix-idx

1 change: 1 addition & 0 deletions platform-nix-idx/demo_connections.json
Original file line number Diff line number Diff line change
@@ -0,0 +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}
115 changes: 0 additions & 115 deletions platform-nix-idx/dev.nix

This file was deleted.

Loading

0 comments on commit 36dd186

Please sign in to comment.