This simulator can be used to simulate JSOn telemetry with specified properties and send telemetry data by specified protocol (Http, Mqtt, Azure Iot Hub, Azure Iot Center, Azure SignalR). All telemetry properties can be defined in configuration file appsettings.json.
cd EntityFX.IotPlatform.Simulator
dotnet build -c Release
cd EntityFX.IotPlatform.Simulator
dotnet run
or
cd EntityFX.IotPlatform.Simulator\bin\Release\net5.0
dotnet run EntityFX.IotPlatform.Simulator.dll
or
cd EntityFX.IotPlatform.Simulator\bin\Release\net5.0
./EntityFX.IotPlatform.Simulator.exe
To change configuration you can modify appsettings.json file.
Configuration:
{
"sendPeriod" : "00:00:00.5"
}"00:00:00.5" means will send telemetry each 500 milliseconds.
sendPeriod can be set in any TimeStamp format.
Property types:
- Number
- String
- Bool
- Timestamp
- DateTime
- Complex
- GeoLocation
Configuration fo properties:
{
"properties": {
"Property1": {
"type": "Number",
...
},
"Property2": {
"type": "String",
..
},
...
}
}Can generate numeric values by constant, enum, sequence, random.
For constant value:
{
"Temperature": {
"type": "Number",
"constant": 25
},
}For sequence value:
{
"Step1": {
"type": "Number",
"sequence": {
"from": 5,
"to": 9,
"step": 2
}
},
}from: inclusive
to: exclusive
step: value to increment, default is 1.
Will generate values like 5, 7, 5, 7, ...
For random sequence value:
{
"Step1": {
"type": "Number",
"randomSequence": {
"from": 10,
"to": 25,
"isDouble": false
},
"useNull": true
},
}from: inclusive
to: exclusive
Will generate random value in range from
10to25(exclusive).If
useNullis true then will generatenullrandomly.If
isDoubleis set then will generate in float format.
For enum value:
{
"Step1": {
"type": "Number",
"enum": [ 1, 2, 3, 5 ],
"useNull": true,
"random": true
},
}Will generate values like 1, 2, 3, 5, 1, 2, 3
or random from list if random is true
If useNull is true then will generate null then 1, 2, 3, 5, 1, 2, 3 or random value from the list.
Can generate string values by constant, enum abd guid.
For constant value:
{
"Name": {
"type": "String",
"constant": "John Doe"
},
}For enum value:
{
"Step1": {
"type": "Number",
"enum": [ "good", "warning", "critical" ],
"useNull": true,
"random": true
},
}Will generate values like
good,warning,criticalor random from the list ifrandomis true.If
useNullis true then will generatenull
For guid value:
{
"Step1": {
"type": "Number",
"enum": [ "good", "warning", "critical" ],
"useNull": true,
"random": true
},
}Can generate bool values by constant, random.
For constant value:
{
"IsOn": {
"type": "Bool",
"constant": true
},
}For random value:
{
"IsOpened": {
"type": "Bool",
"useNull": true,
"random": true
},
}Will generate random values
randomis true. Otherwise will generate sequentialfalse,true,false,true.If
useNullis true then will generatenull
Can generate timestamp (numeric value in milliseconds since January 01 1970) by constant, enum, sequence, random or current date.
For Curent timestamp:
{
"_ts": {
"type": "Timestamp",
"dateType": "now"
},
}or
{
"_ts": {
"type": "Timestamp",
"dateType": "utcNow"
},
}For sequence value:
{
"Step1": {
"type": "Timestamp",
"sequence": {
"from": 1620025640642,
"to": 1621025640642,
"step": 1000
}
},
}from: inclusive
to: exclusive
step: value to increment, default is 1.
For random sequence value:
{
"Step1": {
"type": "Timestamp",
"randomSequence": {
"from": 1620025640642,
"to": 1621025640642
},
"useNull": true
},
}from: inclusive
to: exclusive
Will generate random value in range.
If
useNullis true then will generatenullrandomly.
For enum value:
{
"Step1": {
"type": "Timestamp",
"enum": [ 1620025640642, 1620025990642 ],
"useNull": true,
"random": true
},
}Will generate random from list if
randomis true
If useNull is true then will generate null then 1, 2, 3, 5, 1, 2, 3 or random value from the list.
Can generate DatTime (string date Time value in ISO format) by constant, enum, sequence, random or current date.
For Curent datettime:
{
"Dt": {
"type": "DateTime",
"dateType": "now"
},
}or
{
"Dt": {
"type": "DateTime",
"dateType": "utcNow"
},
}
For Sequence datettime:
```json
{
"Dt1": {
"type": "DateTime",
"sequence": {
"from": "2000-01-01",
"to": "2030-01-01"
},
"random": true
},
}
or
```json
{
"Dt1": {
"type": "DateTime",
"sequence": {
"from": "2000-01-01",
"to": "2030-01-01",
"step" : "01:00:00"
}
},
}
> Sequentially increases time by 1 hour.
#### GeoLocation
Generates geolocation data:
```json
{
"lat": 55.3683346539588,
"lon": 51
}Configuraiton (latitude and longitude will be generated randomly and range can be restricted by latRandomSequence and lonRandomSequence):
{
"Location": {
"type": "GeoLocation",
"latRandomSequence": {
"from": 55,
"to": 57,
"isDouble": true
},
"lonRandomSequence": {
"from": 47,
"to": 52,
"isDouble": false
}
}
}
#### Complex type
Telemetry Sender Types:
- Http
- Mqtt
- Azure Iot Hub
- Azure Iot Center
- Azure SignalR
Sender Type configuration:
{
"telemetrySender": {
"_types": [ "Http", "Mqtt", "AzureSignalR", "AzureIotHub", "AzureIotCenter" ],
"type": "AzureIotHub"
}
}Http sender configuration example:
{
"telemetrySender": {
"Http": {
"Path": "https://your.uri",
"Method": "Post",
"RequestHeaders": {
"x-functions-key": "some-key-here",
"Auth": "Bearer ..."
}
}
}
}Method: Post or Put
RequestHeaders can contain any "key": "value" property.
Configuration:
{
"telemetrySender": {
"AzureSignalR": {
"Hub": "telemetry",
"Method": "Send",
"ConnectionStringName": "AzureSignalR"
},
},
"connectionStrings": {
"AzureSignalR": "Endpoint=https://your.uri;AccessKey=...;Version=1.0;"
}
}Hub: SignalR hub name
Method: Remote method to invoke (only support one parameter method with object type)
ConnectionStringName: SignalR Connection string which should be defined in connectionStrings section
Configuration to send telemetry to Azure Iot Hub.
Configuration:
{
"telemetrySender": {
"AzureIotHub": {
"HostName": "almaz-gdc.azure-devices.net",
"SymmetricKeys": {
"deviceId1": "sas-token"
}
}
}
}HostName: uri address of Azure Iot Hub
SymmetricKeys: "key": "value" properties, where key is Iot Hub device id and value is Iot Hub's device sas-token. You can use multiple Symmetric Keys but only one random key will be used per each telemetry send call.
AzureIotCenter configuration is used when you send telemetry to Azure IoT central with unknown address of it's IoT Hub.
{
"telemetrySender": {
"AzureIotCenter": {
"ProvisioningHost": "global.azure-devices-provisioning.net",
"IdScope": "your-id-scope",
"SymmetricKeys": {
"deviceId1": "sas-token"
}
}
}
}ProvisioningHost: Iot Center provisioning host.
IdScope: unique id of your Iot Central application
SymmetricKeys: "key": "value" properties, where key is Iot Hub device id and value is Iot Hub's device sas-token. You can use multiple Symmetric Keys but only one random key will be used per each telemetry send call.