This repository contains simple game for bilancing of the electric grid. It was designed by request of Aqualectra company for Kaya Kaya festival.
The code is for Visual Studio 2022.
It uses Blazor and component library Blazorise. I recommend to search the documentation of this library for knowledge of the components. It is available here. The demo containing all library components is here and I recommend to check the utilities documentation to understand basic tools for Aligments, Flex and other css related settings which are wrapped by Blazorise (it allows to switch between css providers easilly without changing of the styling in code).
The color theme can be override centrally like you can see in the VEFramework VEBlazor library. It need to define class with the color codes like this and then you can select the theme in the start of the App.razor.
The VEDriversLite.EntitiesBlocks library is used or energetic calculation. You can find more details in the VEFramework Wiki.
Software can run on multiple platforms based on the possibilities of the .NET 7 (later will be switched to the .NET 8).
There possibility to use just the virtual GameBoard and run the app in the cloud as you can see on the demo.
It is not clear now how to switch between HW dependent and not HW dependent game same as multiplayer and signleplayer in the server backend. Here is the component which simulate GameBoard. For the multiplayer as in online demo you need to also create new Player, Game and GameBoard instances for each game. With real HW you are keeping same ID of the GameBoard and you add new Player and Game. You can see this process in this GameStart component. If you do not add new GameBoard all players would submit the data to one GameBoard which is "testBoard" in default. Default configs are created here in LoadShedderCoreService.
The game can run in both "only software" or with physical hardware.
The game on the Kaya Kaya festival runned with combination of the physical board and data grabber with M5Core basic module - based on ESP32 with external two parallel ADC 16channel multiplexers 74HC4067PW-Q100J.
I have chosen the Automotive version because of bigger reliability. It also contains ESD protections and limits the current to the ADC of the MCU (internal resistance of MUX is about 80 Ohms). The HW was supersimplified now and it is not the best version. It needs to decrease the voltage on the dividers to just 3.3V and maybe add additional protection diodes.
The schematic will be added later after improvements. It is practically M5Core plugged to the MUXs with resistor divider. The data inputs of the MUXs can be put in parallel so the MCU drives them both same time. The outputs of the MUXs goes to separated ADC channels so the MCU can read them "same time".
The communication between the server and the MCU is through the Wi-Fi and HTTP API requests.
Photo of the hardware:
It contains two of MUXs in stack. I have used this PCB convertor. It is better to buy the ICs already soldered for example on Sparkfun.
One ADC input channel with plugged different value (linear line) to each ADC MUX input:
Noise on the ADC input:
Both ADC channels with some unpluged/different values:
The FW is very simple. It is written in the C/C++ in Arduino studio. You can find the firmware here.
For loading firmware to the M5Core module please check the documentation of the M5Stack.
The firmware needs to fill some wifi SSID and Pass to connect module and the server in the same network. You need to fill also server IP into the module.
Firmware can do averaging on median calculation for each input value. The measurement goes multiple time and then averaged/median value is provided for software. Here you can change sampling rate and amount of measurements for avg/med. Switch between the average and median must be done by uncomment/comment line here now. I will add it to defines later.
- Start with loading energy sources to the network until you will reach some suitable level (based on settings is 75MW now)
- Load the consumers up to the <10MW level.
- Bilance the network to get 0MW bilance.
Contribution is welcome. Easiest way is create fork of the repository. Then you can clone repository localy to your environment. The repository contains Developlment Branch which should be used to create branch from for the new issues.
If you have any request for feature or bug report please create issue for it. Then you can create branch for the specific issue. If you will solve the issue please create pull request so we can add the contribution to the main branch.
The online demo is available here.
If you have Visual Studio 2022 with the .NET 7 ASP.NET SDK you should be able to compile the project without any additional settings.
Most of the common settings you can do with appsettings.json or for debug mode appsettings.Development.json.
Please search the config file because most of the settings contstants are self explanatory.
The game contains GamePieces. These are pshysical bricks wich has some unique identification (in our case it is unique value of the resistor inside of GamePiece). This unique value is matched in the software with some predefined name, description, expected measured voltage, represented imaginary energy value in eGrid, etc. Those can be placed in the JSON config manually or you can load them with the registration utility in UI.
The list of the AllowedGamePieces is defined for the each GameBoard and its Positions.
Example of the configuration of one Position is here:
"1cfe7a44-515c-4beb-9044-c32ed8a9ea1c": {
"Id": "1cfe7a44-515c-4beb-9044-c32ed8a9ea1c",
"Name": "21-Jan_Thiel",
"DeviceId": "test",
"ChannelId": "27",
"GameBoardId": "testBoard",
"ChannelInputNumber": 27,
"ActualPlacedGamePiece": null,
"AllowedGamePieces": {
"399": {
"Id": "399",
"Name": "21-Jan_Thiel - 15 MW",
"Description": "",
"EnergyValue": 15000.0,
"IsPlugged": false,
"ExpectedVoltage": 399.0,
"ResistorsCombo": 0,
"ResistorsCombo1": 0,
"GamePieceType": 1
},
"913": {
"Id": "913",
"Name": "21-Jan_Thiel - 10 MW",
"Description": "",
"EnergyValue": 10000.0,
"IsPlugged": false,
"ExpectedVoltage": 913.0,
"ResistorsCombo": 0,
"ResistorsCombo1": 0,
"GamePieceType": 1
},
"535": {
"Id": "535",
"Name": "21-Jan_Thiel - 5 MW",
"Description": "",
"EnergyValue": 5000.0,
"IsPlugged": false,
"ExpectedVoltage": 535.0,
"ResistorsCombo": 0,
"ResistorsCombo1": 0,
"GamePieceType": 1
}
}
},
If you run the app you can use the Registration modal which is part of the DataDisplay component now. It should be separated to own component soon.