# Quickstart
Get up and running with this short quickstart.
### Prerequisites
The project uses .NET 8.0, so if not already on your system, install.
Use Git to clone the project, or download the zip from the Github link.
- .NET 8.0 SDK [https://dotnet.microsoft.com/en-us/download/dotnet/8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- Git [https://git-scm.com/downloads](https://git-scm.com/downloads)
- Python [https://www.python.org/downloads/](https://www.python.org/downloads/)
Mrgada uses .NET 8.0 and Serilog, which have known issues on Linux. Unfortunatly you will have to compile the dotnet project on a Windows machine inable to run on other platforms.
### Installation
Make a directory called ***my_scada_application*** and clone the mrgada repository.
```bash
cd my_scada_application
git clone https://github.com/maremrgazo/mrgada.git
```
## Siemens PLCs
Acknowledgments to [s7netplus](https://github.com/S7NetPlus/s7netplus) which is the backbone of this `collector` (More on collectors in Architecture), enabling reading and writting of bytes to and from Siemens PLCs.
### Compatibility
Bellow are compatible hardware and software options. Note that only the PLC type S7-1500 and TIA Portal 15.1 have been verified working.
`Software`
- TIA Portal 15.1
- TIA Portal 16
- TIA Portal 17
- TIA Portal 18
- TIA Portal 19
`Hardware`
- S7-200
- S7-300
- S7-400
- S7-1200
- S7-1500
### Importing dbs from TIA Portal
Create a new directory inside `my_scada_application\mrgada\Imports\S7`, and name it ***your_plcs_project_name***. This name will be used to access variables inside c#.
Example code for writing to the PLC:
```csharp
using static mrgada;
mrgada.your_plcs_project_name.your_database_name.your_variable_name.CV = 3.14;
```
Open your TIA Portal project and select one or more dbs you would wish to use in your SCADA application. Right click then select `*Generate source from blocks*` and press `*Including all depended blocks*` and copy the source to mrgada/S7/***your_plcs_project_name***
Change working directory to Imports/S7 and run python ImportS7dbs.py with the argument ***your_plcs_project_name***
```bash
cd Imports/S7
python ImportS7dbs.py your_plcs_project_name
```
## Simple program
```csharp
using static mrgada;
public class Program
{
public static void Main(string[] args)
{
var mrgadaServerIp = "0.0.0.0"; // replace with the ip you wish to host mrgada server
var mrgadaServerPort = 0; // replace with the port you wish to host mrgada server
var machineType = mrgada.MachineType.Server
mrgada.Init
(
mrgadaServerIp,
mrgadaServerPort,
machineType
);
var s7PlcType = mrgada.PlcType.S71500; // replace your plcs type
var s7PlcIp = "0.0.0.0"; // replace your plcs ip
var s7PlcRack = 0; // replace your plcs rack
var s7PlcSlot = 1; // replace your plcs slot
mrgada.your_plcs_project_name.Init // replace with your_plcs_project_name
(
s7PlcType,
s7PlcRack,
s7PlcSlot,
s7PlcIp
);
mrgada.Start(); // start mrgada
mrgada.your_plcs_project_name.OnFirstCollectorConnect += (sender) => {
// read from plc
Console.WriteLine
(
mrgada.your_plcs_project_name.your_db_name.your_variable_name.CV
);
// write to plc
mrgada.your_plcs_project_name.your_db_name.your_variable_name.CV = 3.14
// subscribe to the CV on changed event
mrgada.your_plcs_project_name.your_db_name.your_variable_name.OnValueChanged += (sender, newValue) => {
Console.WriteLine($"your_variable_name changed value to {newValue}");
};
}
Console.ReadLine();
mrgada.Stop(); // stop mrgada
}
}
```
Install dependencies
```bash
dotnet restore
```
Run the program
```bash
dotnet run
```
To see an example Historian SCADA application and HMI read the next chapter