This commit is contained in:
Xiangzhi Sheng 2017-04-13 13:28:46 +08:00
Родитель 90f29c79cb
Коммит 78fc9abc31
34 изменённых файлов: 492 добавлений и 358 удалений

Просмотреть файл

@ -2,6 +2,13 @@
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"bingMapsLocation": {
"type": "string",
"defaultValue": "westus",
"metadata": {
"description": "Not used - remove when portal updated"
}
},
"aadTenant": {
"type": "string",
"metadata": {
@ -27,11 +34,11 @@
"description": "Suffix added to Azure Storage hostname (examples: core.windows.net, core.cloudapi.de)"
}
},
"bingMapsLocation": {
"bingMapsApiKey": {
"type": "string",
"defaultValue": "westus",
"defaultValue": "0",
"metadata": {
"description": "Bing Maps region"
"description": "Bing Maps Api key - default is disabled"
}
},
"suiteName": {
@ -74,7 +81,7 @@
},
"iotHubSku": {
"type": "string",
"defaultValue": "S2",
"defaultValue": "S1",
"metadata": {
"description": "The Iothub Sku"
}
@ -168,8 +175,6 @@
"ehResourceId": "[resourceId('Microsoft.Eventhub/namespaces/authorizationRules', parameters('ehName'), variables('sbKeyName'))]",
"saVersion": "2015-10-01",
"webVersion": "2015-04-01",
"bingMapsName": "[concat(parameters('suiteName'), '-map')]",
"bingMapsVersion": "2016-08-18",
"webJobPlanName": "[concat(parameters('suiteName'), '-jobsplan')]",
"webJobSiteName": "[concat(parameters('suiteName'), '-jobhost')]",
"webPlanName": "[concat(parameters('suiteName'), '-plan')]",
@ -200,22 +205,6 @@
"databaseAccountOfferType": "[parameters('docDBSku')]"
}
},
{
"apiVersion": "[variables('bingMapsVersion')]",
"type": "Microsoft.BingMaps/mapApis",
"name": "[variables('bingMapsName')]",
"location": "[parameters('bingMapsLocation')]",
"plan": {
"publisher": "bingmaps",
"product": "mapapis",
"name": "internal1",
"promotionCode": null
},
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": { }
},
{
"apiVersion": "[variables('storageVersion')]",
"type": "Microsoft.Storage/storageAccounts",
@ -412,7 +401,7 @@
"Transformation": {
"Name": "AllToBlob",
"Properties": {
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG (Humidity) AS [AverageHumidity],\r\n MIN(Humidity) AS [MinimumHumidity],\r\n MAX(Humidity) AS [MaxHumidity],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG(Temperature) AS [AverageTemperature],\r\n MIN(Temperature) AS [MinimumTemperature],\r\n MAX(Temperature) AS [MaximumTemperature],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Temperature] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
"StreamingUnits": 1
}
}
@ -641,8 +630,7 @@
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageName'))]",
"[resourceId('Microsoft.DocumentDb/databaseAccounts', parameters('docDBName'))]",
"[resourceId('Microsoft.Devices/Iothubs', parameters('iotHubName'))]",
"[resourceId('Microsoft.BingMaps/mapApis', variables('bingMapsName'))]"
"[resourceId('Microsoft.Devices/Iothubs', parameters('iotHubName'))]"
]
},
{
@ -664,7 +652,6 @@
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageName'))]",
"[resourceId('Microsoft.DocumentDb/databaseAccounts', parameters('docDBName'))]",
"[resourceId('Microsoft.Devices/Iothubs', parameters('iotHubName'))]",
"[resourceId('Microsoft.BingMaps/mapApis', variables('bingMapsName'))]",
"[resourceId('Microsoft.StreamAnalytics/streamingjobs', concat(parameters('suiteName'), '-Telemetry'))]",
"[resourceId('Microsoft.StreamAnalytics/streamingjobs', concat(parameters('suiteName'), '-DeviceInfo'))]",
"[resourceId('Microsoft.StreamAnalytics/streamingjobs', concat(parameters('suiteName'), '-Rules'))]"
@ -725,7 +712,7 @@
"RulesEventHub.Name": "[variables('ehRuleOutName')]",
"RulesEventHub.ConnectionString": "[listkeys(variables('ehResourceId'), variables('ehVersion')).primaryConnectionString]",
"ObjectTypePrefix": "",
"MapApiQueryKey": "[listSecrets(variables('bingMapsName'), variables('bingMapsVersion')).QueryKey]",
"MapApiQueryKey": "[parameters('bingMapsApiKey')]",
"SolutionName": "[variables('webSiteName')]"
}
}
@ -763,7 +750,6 @@
}
},
{
"apiVersion": "[variables('webVersion')]",
"name": "Appsettings",
"type": "config",
@ -787,7 +773,7 @@
"RulesEventHub.Name": "[variables('ehRuleOutName')]",
"RulesEventHub.ConnectionString": "[listkeys(variables('ehResourceId'), variables('ehVersion')).primaryConnectionString]",
"ObjectTypePrefix": "",
"MapApiQueryKey": "[listSecrets(variables('bingMapsName'), variables('bingMapsVersion')).QueryKey]",
"MapApiQueryKey": "[parameters('bingMapsApiKey')]",
"SolutionName": "[variables('webSiteName')]"
}
}
@ -813,7 +799,7 @@
},
"bingMapsQueryKey": {
"type": "string",
"value": "[listSecrets(variables('bingMapsName'), variables('bingMapsVersion')).QueryKey]"
"value": "[parameters('bingMapsApiKey')]"
},
"storageConnectionString": {
"type": "string",

Просмотреть файл

@ -81,7 +81,7 @@
},
"iotHubSku": {
"type": "string",
"defaultValue": "S2",
"defaultValue": "S1",
"metadata": {
"description": "The Iothub Sku"
}
@ -401,7 +401,7 @@
"Transformation": {
"Name": "AllToBlob",
"Properties": {
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG (Humidity) AS [AverageHumidity],\r\n MIN(Humidity) AS [MinimumHumidity],\r\n MAX(Humidity) AS [MaxHumidity],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG(Temperature) AS [AverageTemperature],\r\n MIN(Temperature) AS [MinimumTemperature],\r\n MAX(Temperature) AS [MaximumTemperature],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Temperature] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
"StreamingUnits": 1
}
}

Просмотреть файл

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@ -23,105 +23,69 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Factory
private static readonly Random Rand = new Random();
private static readonly List<string> DefaultDeviceNames = new List<string>
private static readonly SortedDictionary<string, string> DefaultDeviceNames = new SortedDictionary<string, string>
{
"CoolingSampleDevice001",
"CoolingSampleDevice002",
"CoolingSampleDevice003",
"CoolingSampleDevice004",
"CoolingSampleDevice005",
"CoolingSampleDevice006",
"CoolingSampleDevice007",
"CoolingSampleDevice008",
"CoolingSampleDevice009",
"CoolingSampleDevice010",
"CoolingSampleDevice011",
"CoolingSampleDevice012",
"CoolingSampleDevice013",
"CoolingSampleDevice014",
"CoolingSampleDevice015",
"CoolingSampleDevice016",
"CoolingSampleDevice017",
"CoolingSampleDevice018",
"CoolingSampleDevice019",
"CoolingSampleDevice020",
"CoolingSampleDevice021",
"CoolingSampleDevice022",
"CoolingSampleDevice023",
"CoolingSampleDevice024",
"CoolingSampleDevice025"
{ "CoolingDevice001", "制冷系统001" },
{ "CoolingDevice002", "制冷系统002" },
{ "CoolingDevice003", "制冷系统003" },
{ "CoolingDevice004", "制冷系统004" },
{ "CoolingDevice005", "制冷系统005" },
{ "CoolingDevice006", "制冷系统006" },
{ "CoolingDevice007", "制冷系统007" },
{ "CoolingDevice008", "制冷系统008" },
{ "CoolingDevice009", "制冷系统009" },
{ "CoolingDevice010", "制冷系统010" },
{ "CoolingDevice011", "制冷系统011" },
{ "CoolingDevice012", "制冷系统012" },
{ "CoolingDevice013", "制冷系统013" },
{ "CoolingDevice014", "制冷系统014" },
{ "CoolingDevice015", "制冷系统015" },
{ "CoolingDevice016", "制冷系统016" },
{ "CoolingDevice017", "制冷系统017" },
{ "CoolingDevice018", "制冷系统018" },
{ "CoolingDevice019", "制冷系统019" },
{ "CoolingDevice020", "制冷系统020" },
{ "CoolingDevice021", "制冷系统021" },
{ "CoolingDevice022", "制冷系统022" },
{ "CoolingDevice023", "制冷系统023" },
{ "CoolingDevice024", "制冷系统024" },
{ "CoolingDevice025", "制冷系统025" }
};
private static readonly List<string> FreeFirmwareDeviceNames = new List<string>
{
"CoolingSampleDevice001",
"CoolingSampleDevice002",
"CoolingSampleDevice003",
"CoolingSampleDevice004",
"CoolingSampleDevice005",
"CoolingSampleDevice006",
"CoolingSampleDevice007",
"CoolingSampleDevice008"
};
private static readonly IEnumerable<string> FreeFirmwareDeviceNames;
private static readonly List<string> HighTemperatureDeviceNames = new List<string>
{
"CoolingSampleDevice001",
"CoolingSampleDevice002",
"CoolingSampleDevice003",
"CoolingSampleDevice004",
"CoolingSampleDevice005"
};
private static readonly IEnumerable<string> HighTemperatureDeviceNames;
private class Location
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public Location(double latitude, double longitude)
{
Latitude = latitude;
Longitude = longitude;
}
public string Building { get; set; }
public string[] Floors { get; set; }
}
private static List<Location> _possibleDeviceLocations = new List<Location>{
new Location(47.659159, -122.141515), // Microsoft Red West Campus, Building A
new Location(47.593307, -122.332165), // 800 Occidental Ave S, Seattle, WA 98134
new Location(47.617025, -122.191285), // 11111 NE 8th St, Bellevue, WA 98004
new Location(47.583582, -122.130622), // 3003 160th Ave SE Bellevue, WA 98008
new Location(47.639511, -122.134376), // 15580 NE 31st St Redmond, WA 98008
new Location(47.644328, -122.137036), // 15255 NE 40th St Redmond, WA 98008
new Location(47.621573, -122.338101), // 320 Westlake Ave N, Seattle, WA 98109
new Location(47.642357, -122.137152), // 15010 NE 36th St, Redmond, WA 98052
new Location(47.614981, -122.195781), //500 108th Ave NE, Bellevue, WA 98004
new Location(47.642528, -122.130565), //3460 157th Ave NE, Redmond, WA 98052
new Location(47.617187, -122.191685), //11155 NE 8th St, Bellevue, WA 98004
new Location(47.677292, -122.093030), //18500 NE Union Hill Rd, Redmond, WA 98052
new Location(47.642528, -122.130565), //3600 157th Ave NE, Redmond, WA 98052
new Location(47.642876, -122.125492), //16070 NE 36th Way Bldg 33, Redmond, WA 98052
new Location(47.637376, -122.140445), //14999 NE 31st Way, Redmond, WA 98052
new Location(47.636121, -122.130254) //3009 157th Pl NE, Redmond, WA 98052
static SampleDeviceFactory()
{
FreeFirmwareDeviceNames = DefaultDeviceNames.Keys.Take(8);
HighTemperatureDeviceNames = DefaultDeviceNames.Keys.Take(5);
}
private static readonly List<Location> _possibleDeviceLocations = new List<Location>{
new Location { Latitude = 39.979393, Longitude = 116.310282, Building = "微软1号楼", Floors = new[] { "1F", "2F" } },
new Location { Latitude = 39.980554, Longitude = 116.310231, Building = "微软2号楼", Floors = new[] { "1F", "2F" } },
new Location { Latitude = 39.980646, Longitude = 116.308796, Building = "立方庭", Floors = new[] { "5F", "6F", "7F" } },
new Location { Latitude = 39.979622, Longitude = 116.312106, Building = "中国电子大厦", Floors = new[] { "1F", "2F", "10F", "11F" } },
new Location { Latitude = 39.980970, Longitude = 116.312422, Building = "新东方", Floors = new[] { "1F", "2F" } },
new Location { Latitude = 39.978241, Longitude = 116.309928, Building = "海兴大厦", Floors = new[] { "1F", "2F", "3F", "4F" } },
new Location { Latitude = 39.979828, Longitude = 116.308995, Building = "1+1大厦", Floors = new[] { "1F", "2F" } },
new Location { Latitude = 39.981661, Longitude = 116.309038, Building = "天创科技大厦", Floors = new[] { "1F", "2F" } }
};
private static List<string> _possibleBuildingTags = new List<string>
public static DeviceModel GetSampleSimulatedDevice(InitialDeviceConfig config)
{
"Building 40",
"Building 43"
};
DeviceModel device = DeviceCreatorHelper.BuildDeviceStructure(config.DeviceId, true, null);
private static List<string> _possibleFloorTags = new List<string>
{
"1F",
"2F",
};
public static DeviceModel GetSampleSimulatedDevice(string deviceId, string key)
{
DeviceModel device = DeviceCreatorHelper.BuildDeviceStructure(deviceId, true, null);
AssignDeviceProperties(device);
AssignDeviceProperties(device, config);
device.ObjectType = OBJECT_TYPE_DEVICE_INFO;
device.Version = VERSION_1_0;
device.IsSimulatedDevice = IS_SIMULATED_DEVICE;
@ -145,14 +109,14 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Factory
var device = DeviceCreatorHelper.BuildDeviceStructure(deviceId, false, null);
device.ObjectName = "IoT Device Description";
AssignDeviceProperties(device);
AssignDeviceProperties(device, null);
AssignTelemetry(device);
AssignCommands(device);
return device;
}
private static void AssignDeviceProperties(DeviceModel device)
private static void AssignDeviceProperties(DeviceModel device, InitialDeviceConfig config)
{
int randomId = Rand.Next(0, _possibleDeviceLocations.Count - 1);
if (device?.DeviceProperties == null)
@ -179,14 +143,14 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Factory
device.DeviceProperties.InstalledRAM = randomId + " MB";
// Choose a location among the 16 above and set Lat and Long for device properties
device.DeviceProperties.Latitude = _possibleDeviceLocations[randomId].Latitude;
device.DeviceProperties.Longitude = _possibleDeviceLocations[randomId].Longitude;
device.DeviceProperties.Latitude = config?.Latitude;
device.DeviceProperties.Longitude = config?.Longitude;
}
private static void AssignTelemetry(DeviceModel device)
{
device.Telemetry.Add(new Telemetry("Temperature", "Temperature", "double"));
device.Telemetry.Add(new Telemetry("Humidity", "Humidity", "double"));
device.Telemetry.Add(new Telemetry("Temperature", "温度", "double"));
device.Telemetry.Add(new Telemetry("Humidity", "湿度", "double"));
}
private static void AssignCommands(DeviceModel device)
@ -247,8 +211,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Factory
public static List<string> GetDefaultDeviceNames()
{
long milliTime = DateTime.Now.Millisecond;
return DefaultDeviceNames.Select(r => string.Concat(r, "_" + milliTime)).ToList();
return DefaultDeviceNames.Keys.ToList();
}
public static void AssignDefaultTags(DeviceModel device)
@ -258,8 +221,21 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Factory
device.Twin = new Twin();
}
device.Twin.Tags["Building"] = Random(_possibleBuildingTags);
device.Twin.Tags["Floor"] = Random(_possibleFloorTags);
string displayName;
if (DefaultDeviceNames.TryGetValue(device.DeviceProperties.DeviceID, out displayName))
{
device.Twin.Tags["DisplayName"] = displayName;
}
var location = Random(_possibleDeviceLocations);
device.Twin.Tags["Building"] = location.Building;
device.Twin.Tags["Floor"] = Random(location.Floors);
const double deltaLatitude = 0.006334;
const double deltaLongitude = 0.006933;
device.DeviceProperties.Longitude = location.Longitude + (Rand.NextDouble() - 0.5) / 2000 + deltaLongitude;
device.DeviceProperties.Latitude = location.Latitude + (Rand.NextDouble() - 0.5) / 2000 + deltaLatitude;
}
public static void AssignDefaultDesiredProperties(DeviceModel device)
@ -271,7 +247,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Factory
device.Twin = new Twin();
}
device.Twin.Properties.Desired.Set("Config.TemperatureMeanValue", 70);
device.Twin.Properties.Desired.Set("Config.TemperatureMeanValue", 30);
}
}

Просмотреть файл

@ -27,5 +27,9 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models
}
public string Key { get; set; }
public double? Longitude { get; set; }
public double? Latitude { get; set; }
}
}

Просмотреть файл

@ -12,5 +12,7 @@
public string HostName { get; set; }
public string DeviceId { get; set; }
public string Key { get; set; }
public double? Longitude { get; set; }
public double? Latitude { get; set; }
}
}

Просмотреть файл

@ -1,10 +1,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Configurations;
using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Helpers;
using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models;
using Microsoft.WindowsAzure.Storage.Table;
namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Repository
{
@ -30,7 +29,9 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Repositor
{
HostName = device.HostName,
DeviceId = device.DeviceId,
Key = device.Key
Key = device.Key,
Longitude = device.Longitude,
Latitude = device.Latitude
};
devices.Add(deviceConfig);
}
@ -64,12 +65,15 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Repositor
public async Task AddOrUpdateDeviceAsync(InitialDeviceConfig deviceConfig)
{
var deviceEnity = new DeviceListEntity()
var deviceEnity = new DeviceListEntity
{
DeviceId = deviceConfig.DeviceId,
HostName = deviceConfig.HostName,
Key = deviceConfig.Key
Key = deviceConfig.Key,
Longitude = deviceConfig.Longitude,
Latitude = deviceConfig.Latitude
};
var operation = TableOperation.InsertOrReplace(deviceEnity);
await _azureTableStorageClient.ExecuteAsync(operation);
}
@ -84,7 +88,9 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Repositor
{
DeviceId = device.DeviceId,
HostName = device.HostName,
Key = device.Key
Key = device.Key,
Longitude = device.Longitude,
Latitude = device.Latitude
};
}
return null;

Просмотреть файл

@ -11,13 +11,16 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
private readonly IActionMappingRepository _actionMappingRepository;
private readonly IDeviceRulesRepository _rulesRepository;
private const string _ruleOutputAlarmTemp = "AlarmTemp";
private const string _ruleOutputAlarmHumidity = "AlarmHumidity";
public const string RuleOutputAlarmTemperature = "温度告警";
public const string RuleOutputAlarmHumidity = "湿度告警";
private List<string> _availableRuleOutputs = new List<string>()
public const string ActionIdSendMessage = "发送消息";
public const string ActionIdRaiseAlert = "触发警报";
private List<string> _availableRuleOutputs = new List<string>()
{
_ruleOutputAlarmTemp,
_ruleOutputAlarmHumidity
RuleOutputAlarmTemperature,
RuleOutputAlarmHumidity
};
public ActionMappingLogic(IActionMappingRepository actionMappingRepository, IDeviceRulesRepository rulesRepository)
@ -53,16 +56,16 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
var am1 = new ActionMapping()
{
RuleOutput = _ruleOutputAlarmTemp,
ActionId = "Send Message"
RuleOutput = RuleOutputAlarmTemperature,
ActionId = ActionIdSendMessage
};
await _actionMappingRepository.SaveMappingAsync(am1);
var am2 = new ActionMapping()
{
RuleOutput = _ruleOutputAlarmHumidity,
ActionId = "Raise Alarm"
RuleOutput = RuleOutputAlarmHumidity,
ActionId = ActionIdRaiseAlert
};
await _actionMappingRepository.SaveMappingAsync(am2);
@ -82,7 +85,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
List<DeviceRule> rules = await rulesTask;
var results = new List<ActionMappingExtended>();
foreach(var mapping in mappings)
foreach (var mapping in mappings)
{
var mappingExtended = new ActionMappingExtended();
mappingExtended.RuleOutput = mapping.RuleOutput;
@ -100,7 +103,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
public async Task SaveMappingAsync(ActionMapping action)
{
await _actionMappingRepository.SaveMappingAsync(action);
await _actionMappingRepository.SaveMappingAsync(action);
}
public async Task<string> GetActionIdFromRuleOutputAsync(string ruleOutput)

Просмотреть файл

@ -139,11 +139,13 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
{
try
{
await _virtualDeviceStorage.AddOrUpdateDeviceAsync(new InitialDeviceConfig()
await _virtualDeviceStorage.AddOrUpdateDeviceAsync(new InitialDeviceConfig
{
DeviceId = device.DeviceProperties.DeviceID,
HostName = _configProvider.GetConfigurationSettingValue("iotHub.HostName"),
Key = securityKeys.PrimaryKey
Key = securityKeys.PrimaryKey,
Longitude = device.DeviceProperties.Longitude,
Latitude = device.DeviceProperties.Latitude
});
}
catch (Exception ex)
@ -792,7 +794,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
List<string> sampleIds = SampleDeviceFactory.GetDefaultDeviceNames();
foreach (string id in sampleIds)
{
DeviceModel device = DeviceCreatorHelper.BuildDeviceStructure(id, true, null);
DeviceModel device = DeviceCreatorHelper.BuildDeviceStructure(id, true, null);
SecurityKeys generatedSecurityKeys = _securityKeyGenerator.CreateRandomKeys();
SampleDeviceFactory.AssignDefaultTags(device);
SampleDeviceFactory.AssignDefaultDesiredProperties(device);
@ -869,13 +871,11 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
maxLong = -122.3;
}
double offset = 0.05;
result.DeviceLocationList = locationList;
result.MinimumLatitude = minLat - offset;
result.MaximumLatitude = maxLat + offset;
result.MinimumLongitude = minLong - offset;
result.MaximumLongitude = maxLong + offset;
result.MinimumLatitude = minLat;
result.MaximumLatitude = maxLat;
result.MinimumLongitude = minLong;
result.MaximumLongitude = maxLong;
return result;
}

Просмотреть файл

@ -159,15 +159,9 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
{
DeviceRule temperatureRule = await GetNewRuleAsync(deviceId);
temperatureRule.DataField = DeviceRuleDataFields.Temperature;
temperatureRule.RuleOutput = "AlarmTemp";
temperatureRule.Threshold = 60.0d;
temperatureRule.RuleOutput = ActionMappingLogic.RuleOutputAlarmTemperature;
temperatureRule.Threshold = 27.0d;
await SaveDeviceRuleAsync(temperatureRule);
DeviceRule humidityRule = await GetNewRuleAsync(deviceId);
humidityRule.DataField = DeviceRuleDataFields.Humidity;
humidityRule.RuleOutput = "AlarmHumidity";
humidityRule.Threshold = 48.0d;
await SaveDeviceRuleAsync(humidityRule);
}
}

Просмотреть файл

@ -10,7 +10,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
/// <summary>
/// Gets or sets the covered period's average humidity.
/// </summary>
public double? AverageHumidity
public double? AverageTemperature
{
get;
set;
@ -29,7 +29,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
/// <summary>
/// Gets or sets the covered period's maximum humidity.
/// </summary>
public double? MaximumHumidity
public double? MaximumTemperature
{
get;
set;
@ -38,7 +38,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
/// <summary>
/// Gets or sets the covered period's minimum humidity.
/// </summary>
public double? MinimumHumidity
public double? MinimumTemperature
{
get;
set;

Просмотреть файл

@ -1,8 +1,9 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastructure.BusinessLogic;
using Newtonsoft.Json;
namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastructure.Repository
{
@ -19,10 +20,10 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
}
// Currently this dictionary is not editable in the app
private Dictionary<string,string> actionIds = new Dictionary<string, string>()
private Dictionary<string, string> actionIds = new Dictionary<string, string>()
{
{ "Send Message", "" },
{ "Raise Alarm", "" }
{ ActionMappingLogic.ActionIdSendMessage, "" },
{ ActionMappingLogic.ActionIdRaiseAlert, "" }
};
public async Task<bool> AddActionEndpoint(string actionId, string endpoint)
@ -48,7 +49,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
public async Task<bool> ExecuteLogicAppAsync(string actionId, string deviceId, string measurementName, double measuredValue)
{
if(actionIds.ContainsKey(actionId) && !string.IsNullOrEmpty(actionIds[actionId]))
if (actionIds.ContainsKey(actionId) && !string.IsNullOrEmpty(actionIds[actionId]))
{
return await Task.Run(async () =>
{
@ -68,12 +69,12 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
}
});
}
else
else
{
Trace.TraceWarning("ExecuteLogicAppAsync no event endpoint defined for actionId '{0}'", actionId);
Trace.TraceWarning("ExecuteLogicAppAsync no event endpoint defined for actionId '{0}'", actionId);
return false;
}
}
}
}

Просмотреть файл

@ -29,20 +29,20 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
new DeviceListFilter
{
Id = "00000000-0000-0000-0000-000000000000",
Name = "All Devices",
Name = "全部设备",
Clauses = new List<Clause>()
},
new DeviceListFilter
{
Id = "00000000-0000-0000-0000-000000000001",
Name = "Unhealthy devices",
Name = "温度异常设备",
Clauses = new List<Clause>
{
new Clause
{
ColumnName = "reported.Config.TemperatureMeanValue",
ClauseType = ClauseType.GT,
ClauseValue = "60",
ClauseValue = "27",
ClauseDataType = TwinDataType.Number
}
}
@ -50,7 +50,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
new DeviceListFilter
{
Id = "00000000-0000-0000-0000-000000000002",
Name = "Old firmware devices",
Name = "旧固件设备",
Clauses = new List<Clause>
{
new Clause

Просмотреть файл

@ -294,34 +294,34 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
model.DeviceId = str;
}
if (strdict.TryGetValue("averagehumidity", out str) &&
if (strdict.TryGetValue("averagetemperature", out str) &&
double.TryParse(
str,
NumberStyles.Float,
CultureInfo.InvariantCulture,
out number))
{
model.AverageHumidity = number;
model.AverageTemperature = number;
}
if (strdict.TryGetValue("maxhumidity", out str) &&
if (strdict.TryGetValue("maximumtemperature", out str) &&
double.TryParse(
str,
NumberStyles.Float,
CultureInfo.InvariantCulture,
out number))
{
model.MaximumHumidity = number;
model.MaximumTemperature = number;
}
if (strdict.TryGetValue("minimumhumidity", out str) &&
if (strdict.TryGetValue("minimumtemperature", out str) &&
double.TryParse(
str,
NumberStyles.Float,
CultureInfo.InvariantCulture,
out number))
{
model.MinimumHumidity = number;
model.MinimumTemperature = number;
}
if (strdict.TryGetValue("timeframeminutes", out str) &&

Просмотреть файл

@ -538,6 +538,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Average of device temperature.
/// </summary>
public static string AverageOfDeviceTemperature {
get {
return ResourceManager.GetString("AverageOfDeviceTemperature", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to IoT Hub Hostname.
/// </summary>
@ -1501,6 +1510,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Device.
/// </summary>
public static string DeviceDisplayNameHeader {
get {
return ResourceManager.GetString("DeviceDisplayNameHeader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Device ID.
/// </summary>
@ -3427,6 +3445,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Max of device temperature.
/// </summary>
public static string MaxOfDeviceTemperature {
get {
return ResourceManager.GetString("MaxOfDeviceTemperature", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Metadata.
/// </summary>
@ -3517,6 +3544,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Min of device temperature.
/// </summary>
public static string MinOfDeviceTemperature {
get {
return ResourceManager.GetString("MinOfDeviceTemperature", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Minutes.
/// </summary>
@ -3562,15 +3598,6 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to MSISDN.
/// </summary>
public static string MSISDN {
get {
return ResourceManager.GetString("MSISDN", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Months.
/// </summary>
@ -3607,6 +3634,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to MSISDN.
/// </summary>
public static string MSISDN {
get {
return ResourceManager.GetString("MSISDN", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name Your Filter.
/// </summary>
@ -3940,15 +3976,6 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Operator Code.
/// </summary>
public static string OperatorCode {
get {
return ResourceManager.GetString("OperatorCode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to OPERATIONS.
/// </summary>
@ -3958,6 +3985,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Operator Code.
/// </summary>
public static string OperatorCode {
get {
return ResourceManager.GetString("OperatorCode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Operator.
/// </summary>
@ -5434,6 +5470,15 @@ namespace GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Interval (s).
/// </summary>
public static string TelemetryIntervalHeader {
get {
return ResourceManager.GetString("TelemetryIntervalHeader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Temperature.
/// </summary>
@ -5640,7 +5685,7 @@ namespace GlobalResources {
return ResourceManager.GetString("UpdateTwin", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Upload.
/// </summary>

Просмотреть файл

@ -1528,8 +1528,7 @@
<comment>Tile subheading.</comment>
</data>
<data name="ApiRegistrationTitle" xml:space="preserve">
<value>Jasper API Registration</value>
<comment>Panel heading. {Locked="Jasper"}{Locked="API"}</comment>
<value>API Registration</value>
</data>
<data name="CellularConnViewTitle" xml:space="preserve">
<value>Cellular Conn</value>
@ -1776,9 +1775,6 @@
<data name="ApiRegistrationSelectOptionInitial" xml:space="preserve">
<value>Select provider</value>
</data>
<data name="ApiRegistrationTitle" xml:space="preserve">
<value>API Registration</value>
</data>
<data name="EricssonHelpLink" xml:space="preserve">
<value>https://www.ericsson.com/microsoft-iot</value>
</data>
@ -2672,4 +2668,24 @@
<value>-- select a locale --</value>
<comment>Dropdown label.</comment>
</data>
<data name="AverageOfDeviceTemperature" xml:space="preserve">
<value>Average of device temperature</value>
<comment>Read-only field label.</comment>
</data>
<data name="MaxOfDeviceTemperature" xml:space="preserve">
<value>Max of device temperature</value>
<comment>Read-only field label.</comment>
</data>
<data name="MinOfDeviceTemperature" xml:space="preserve">
<value>Min of device temperature</value>
<comment>Read-only field label.</comment>
</data>
<data name="DeviceDisplayNameHeader" xml:space="preserve">
<value>Device</value>
<comment>Table column header.</comment>
</data>
<data name="TelemetryIntervalHeader" xml:space="preserve">
<value>Interval (s)</value>
<comment>Table column header.</comment>
</data>
</root>

Просмотреть файл

@ -2497,7 +2497,7 @@
<comment>Table column header.</comment>
</data>
<data name="BuildingHeader" xml:space="preserve">
<value>Building</value>
<value>地址</value>
<comment>Table column header.</comment>
</data>
<data name="PleaseNameYourFilter" xml:space="preserve">
@ -2508,4 +2508,24 @@
<value>The filter name must be unique.</value>
<comment>Error message.</comment>
</data>
<data name="AverageOfDeviceTemperature" xml:space="preserve">
<value>平均温度</value>
<comment>Read-only field label.</comment>
</data>
<data name="MaxOfDeviceTemperature" xml:space="preserve">
<value>最高温度</value>
<comment>Read-only field label.</comment>
</data>
<data name="MinOfDeviceTemperature" xml:space="preserve">
<value>最低温度</value>
<comment>Read-only field label.</comment>
</data>
<data name="DeviceDisplayNameHeader" xml:space="preserve">
<value>设备</value>
<comment>Table column header.</comment>
</data>
<data name="TelemetryIntervalHeader" xml:space="preserve">
<value>采样间隔 (s)</value>
<comment>Table column header.</comment>
</data>
</root>

Просмотреть файл

@ -122,8 +122,8 @@
var onXhr = function onXhr(e, settings, data) {
if (handleRequestError(settings)) {
if (typeof IoTApp.MapPane === "object" && data) {
IoTApp.MapPane.setDeviceLocationData(
if (typeof IoTApp.BaiduMapPane === "object" && data) {
IoTApp.BaiduMapPane.setDeviceLocationData(
data.minLatitude,
data.minLongitude,
data.maxLatitude,

Просмотреть файл

@ -0,0 +1,86 @@
IoTApp.createModule('IoTApp.BaiduMapPane', (function () {
"use strict";
var self = this;
var map;
var pinInfobox;
var boundsSet = false;
var init = function () {
self.map = new BMap.Map("deviceMap");
self.map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
self.map.addControl(new BMap.MapTypeControl());
self.map.addControl(new BMap.ScaleControl({
anchor: BMAP_ANCHOR_TOP_LEFT
}));
self.map.addControl(new BMap.NavigationControl({
anchor: BMAP_ANCHOR_TOP_LEFT,
type: BMAP_NAVIGATION_CONTROL_SMALL
}));
self.map.setCurrentCity("北京");
self.map.enableScrollWheelZoom(true);
}
var bindDeviceToMarker = function (marker, deviceId) {
marker.addEventListener("click", function (e) {
marker.openInfoWindow(new BMap.InfoWindow(deviceId));
IoTApp.Dashboard.DashboardDevicePane.setSelectedDevice(deviceId);
});
}
var setDeviceLocationData = function setDeviceLocationData(minLatitude, minLongitude, maxLatitude, maxLongitude, deviceLocations) {
if (!self.map) {
return;
}
if (!boundsSet) {
boundsSet = true;
var points = [
new BMap.Point(minLongitude, minLatitude),
new BMap.Point(maxLongitude, maxLatitude)
];
self.map.setViewport(points);
}
self.map.clearOverlays();
for (var i = 0; i < deviceLocations.length; i++) {
var icon;
switch (deviceLocations[i].status) {
case 1:
icon = new BMap.Icon(resources.cautionStatusIcon, new BMap.Size(17, 17));
break;
case 2:
icon = new BMap.Icon(resources.criticalStatusIcon, new BMap.Size(17, 17));
break;
default:
icon = new BMap.Icon(resources.allClearStatusIcon, new BMap.Size(17, 17));
break;
}
var point = new BMap.Point(deviceLocations[i].longitude, deviceLocations[i].latitude);
var marker = new BMap.Marker(point);
marker.setIcon(icon);
bindDeviceToMarker(marker, deviceLocations[i].deviceId);
self.map.addOverlay(marker);
}
}
return {
init: init,
setDeviceLocationData: setDeviceLocationData
}
}), [jQuery, resources]);
$(function () {
"use strict";
IoTApp.BaiduMapPane.init();
});

Просмотреть файл

@ -62,9 +62,9 @@
if (telemetryHistoryRefreshData) {
if (data.deviceTelemetrySummaryModel) {
telemetryHistoryRefreshData(
data.deviceTelemetrySummaryModel.minimumHumidity || 0.0,
data.deviceTelemetrySummaryModel.maximumHumidity || 0.0,
data.deviceTelemetrySummaryModel.averageHumidity || 0.0);
data.deviceTelemetrySummaryModel.minimumTemperature || 0.0,
data.deviceTelemetrySummaryModel.maximumTemperature || 0.0,
data.deviceTelemetrySummaryModel.averageTemperature || 0.0);
} else {
telemetryHistoryRefreshData(0.0, 0.0, 0.0);
}

Просмотреть файл

@ -3,24 +3,28 @@
function initTelemetryHistorySummary() {
'use strict';
var averageDeviceHumidityContainer;
var averageDeviceHumidityControl;
var averageDeviceHumidityLabel;
var averageHumidityVisual;
var lastAvgHumidity;
var lastMaxHumidity;
var lastMinHumidity;
var maxDeviceHumidityContainer;
var maxDeviceHumidityControl;
var maxDeviceHumidityLabel;
var maxHumidityVisual;
var maxValue;
var minDeviceHumidityContainer;
var minDeviceHumidityControl;
var minDeviceHumidityLabel;
var minHumidityVisual;
var minValue;
var lastLeftGaugeValue;
var lastMiddleGaugeValue;
var lastRightGaugeValue;
var leftGaugeContainer;
var leftGaugeControl;
var leftGaugeLabel;
var leftGaugeVisual;
var middleGaugeContainer;
var middleGaugeControl;
var middleGaugeLabel;
var middleGaugeVisual;
var rightGaugeContainer;
var rightGaugeControl;
var rightGaugeLabel;
var rightGaugeVisual;
var createDataView = function createDataView(indicatedValue) {
var categoryMetadata;
@ -135,33 +139,33 @@
maxValue = telemetryHistorySummarySettings.gaugeMaxValue;
minValue = telemetryHistorySummarySettings.gaugeMinValue;
averageDeviceHumidityContainer = telemetryHistorySummarySettings.averageDeviceHumidityContainer;
averageDeviceHumidityControl = telemetryHistorySummarySettings.averageDeviceHumidityControl;
averageDeviceHumidityLabel = telemetryHistorySummarySettings.averageDeviceHumidityLabel;
maxDeviceHumidityContainer = telemetryHistorySummarySettings.maxDeviceHumidityContainer;
maxDeviceHumidityControl = telemetryHistorySummarySettings.maxDeviceHumidityControl;
maxDeviceHumidityLabel = telemetryHistorySummarySettings.maxDeviceHumidityLabel;
minDeviceHumidityContainer = telemetryHistorySummarySettings.minDeviceHumidityContainer;
minDeviceHumidityControl = telemetryHistorySummarySettings.minDeviceHumidityControl;
minDeviceHumidityLabel = telemetryHistorySummarySettings.minDeviceHumidityLabel;
rightGaugeContainer = telemetryHistorySummarySettings.rightGaugeContainer;
rightGaugeControl = telemetryHistorySummarySettings.rightGaugeControl;
rightGaugeLabel = telemetryHistorySummarySettings.rightGaugeLabel;
leftGaugeContainer = telemetryHistorySummarySettings.leftGaugeContainer;
leftGaugeControl = telemetryHistorySummarySettings.leftGaugeControl;
leftGaugeLabel = telemetryHistorySummarySettings.leftGaugeLabel;
middleGaugeContainer = telemetryHistorySummarySettings.middleGaugeContainer;
middleGaugeControl = telemetryHistorySummarySettings.middleGaugeControl;
middleGaugeLabel = telemetryHistorySummarySettings.middleGaugeLabel;
averageHumidityVisual = createVisual(averageDeviceHumidityControl);
maxHumidityVisual = createVisual(maxDeviceHumidityControl);
minHumidityVisual = createVisual(minDeviceHumidityControl);
rightGaugeVisual = createVisual(rightGaugeControl);
leftGaugeVisual = createVisual(leftGaugeControl);
middleGaugeVisual = createVisual(middleGaugeControl);
};
var redraw = function redraw() {
var height;
var width;
if (minDeviceHumidityControl &&
minHumidityVisual &&
(lastMinHumidity || (lastMinHumidity === 0))) {
height = minDeviceHumidityControl.height();
width = minDeviceHumidityControl.width();
if (middleGaugeControl &&
middleGaugeVisual &&
(lastMiddleGaugeValue || (lastMiddleGaugeValue === 0))) {
height = middleGaugeControl.height();
width = middleGaugeControl.width();
minHumidityVisual.update({
dataViews: [createDataView(lastMinHumidity)],
middleGaugeVisual.update({
dataViews: [createDataView(lastMiddleGaugeValue)],
viewport: {
height: height,
width: width
@ -170,14 +174,14 @@
});
}
if (maxDeviceHumidityControl &&
maxHumidityVisual &&
(lastMaxHumidity || (lastMaxHumidity === 0))) {
height = maxDeviceHumidityControl.height();
width = maxDeviceHumidityControl.width();
if (leftGaugeControl &&
leftGaugeVisual &&
(lastLeftGaugeValue || (lastLeftGaugeValue === 0))) {
height = leftGaugeControl.height();
width = leftGaugeControl.width();
maxHumidityVisual.update({
dataViews: [createDataView(lastMaxHumidity)],
leftGaugeVisual.update({
dataViews: [createDataView(lastLeftGaugeValue)],
viewport: {
height: height,
width: width
@ -186,14 +190,14 @@
});
}
if (averageDeviceHumidityControl &&
averageHumidityVisual &&
(lastAvgHumidity || (lastAvgHumidity === 0))) {
height = averageDeviceHumidityControl.height();
width = averageDeviceHumidityControl.width();
if (rightGaugeControl &&
rightGaugeVisual &&
(lastRightGaugeValue || (lastRightGaugeValue === 0))) {
height = rightGaugeControl.height();
width = rightGaugeControl.width();
averageHumidityVisual.update({
dataViews: [createDataView(lastAvgHumidity)],
rightGaugeVisual.update({
dataViews: [createDataView(lastRightGaugeValue)],
viewport: {
height: height,
width: width
@ -212,49 +216,49 @@
padding = 0;
if (averageDeviceHumidityContainer &&
averageDeviceHumidityLabel &&
averageDeviceHumidityControl) {
if (rightGaugeContainer &&
rightGaugeLabel &&
rightGaugeControl) {
height =
averageDeviceHumidityContainer.height() -
averageDeviceHumidityLabel.height() -
rightGaugeContainer.height() -
rightGaugeLabel.height() -
padding;
width = averageDeviceHumidityContainer.width() - padding;
width = rightGaugeContainer.width() - padding;
averageDeviceHumidityControl.height(height);
averageDeviceHumidityControl.width(width);
rightGaugeControl.height(height);
rightGaugeControl.width(width);
}
if (maxDeviceHumidityContainer &&
maxDeviceHumidityLabel &&
maxDeviceHumidityControl) {
if (leftGaugeContainer &&
leftGaugeLabel &&
leftGaugeControl) {
height =
maxDeviceHumidityContainer.height() -
maxDeviceHumidityLabel.height() -
leftGaugeContainer.height() -
leftGaugeLabel.height() -
padding;
width = maxDeviceHumidityContainer.width() - padding;
width = leftGaugeContainer.width() - padding;
maxDeviceHumidityControl.height(height);
maxDeviceHumidityControl.width(width);
leftGaugeControl.height(height);
leftGaugeControl.width(width);
}
if (minDeviceHumidityContainer &&
minDeviceHumidityLabel &&
minDeviceHumidityControl) {
if (middleGaugeContainer &&
middleGaugeLabel &&
middleGaugeControl) {
height =
minDeviceHumidityContainer.height() -
minDeviceHumidityLabel.height() -
middleGaugeContainer.height() -
middleGaugeLabel.height() -
padding;
width = minDeviceHumidityContainer.width() - padding;
width = middleGaugeContainer.width() - padding;
minDeviceHumidityControl.height(height);
minDeviceHumidityControl.width(width);
middleGaugeControl.height(height);
middleGaugeControl.width(width);
}
redraw();
@ -262,16 +266,16 @@
var updateTelemetryHistorySummaryData =
function updateTelemetryHistorySummaryData(
minHumidity,
maxHumidity,
avgHumidity) {
minTemperature,
maxTemperature,
avgTemperature) {
lastAvgHumidity = avgHumidity;
lastMaxHumidity = maxHumidity;
lastMinHumidity = minHumidity;
lastRightGaugeValue = avgTemperature;
lastLeftGaugeValue = maxTemperature;
lastMiddleGaugeValue = minTemperature;
redraw();
};
};
return {
init: init,

Просмотреть файл

@ -28,6 +28,7 @@
/// <reference path="views/dashboard/alerthistory.js" />
/// <reference path="views/dashboard/dashboarddevicepane.js" />
/// <reference path="views/dashboard/jobindicators.js" />
/// <reference path="views/dashboard/baidumappane.js" />
/// <reference path="views/dashboard/mappane.js" />
/// <reference path="views/dashboard/telemetryhistory.js" />
/// <reference path="views/dashboard/telemetryhistorysummary.js" />

Просмотреть файл

@ -33,27 +33,15 @@
<div class="dashboard_content">
<div class="dashboard_left_column">
<div>
@{if (!string.IsNullOrWhiteSpace(Model.MapApiQueryKey))
{
<div>
<div id="deviceMap" class="dashboard_device_map">
<script charset="UTF-8" type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"></script>
<script type="text/javascript" src="~/Scripts/IoTHelperScripts.js?ver=@Constants.JSVersion"></script>
s<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=aozuxR9KIO4MdeSbZGTCRwH8F71d0xEi"></script>
<script src="~/Scripts/Views/Dashboard/MapPane.js?ver=@Constants.JSVersion"></script>
<script>
resources.alertHistoryType = "dashboard_alert_history--static_height";
</script>
@*<script type="text/javascript" src="~/Scripts/IoTHelperScripts.js?ver=@Constants.JSVersion"></script>*@
<script type="text/javascript" src="~/Scripts/Views/Dashboard/BaiduMapPane.js"></script>
<script>resources.alertHistoryType = "dashboard_alert_history--static_height";</script>
</div>
}
else
{
<img class="static_map" id="staticMap" src="~/Content/img/map_copyrights.png" alt="Map Img" />
<script>
resources.alertHistoryType = "dashboard_alert_history--dynamic_height";
</script>
}
}
</div>
</div>
@{
Html.RenderPartial("_AlertHistory");

Просмотреть файл

@ -1,15 +1,16 @@
@using GlobalResources
<div class="dashboard_telemetry_history_summary">
<div id="maxDeviceHumidityContainer" class="dashboard_telemetry_history_summary__dashboard_telemetry_history_gauge dashboard_telemetry_history_gauge--leftGauge">
<h5 class="telemetry_summary_gauge_control__gauge_header" id="maxDeviceHumidityLabel">@Strings.MaxOfDevicesHumidity</h5>
<div id="maxDevicehumidity" class="dashboard_telemetry_history_gauge__telemetry_summary_gauge_control"></div>
</div><div id="minDeviceHumidityContainer" class="dashboard_telemetry_history_summary__dashboard_telemetry_history_gauge dashboard_telemetry_history_gauge--centerGauge">
<h5 class="telemetry_summary_gauge_control__gauge_header" id="maxDeviceHumidityLabel">@Strings.MinOfDevicesHumidity</h5>
<div id="minDeviceHumidity" class="dashboard_telemetry_history_gauge__telemetry_summary_gauge_control"></div>
<div id="leftGaugeContainer" class="dashboard_telemetry_history_summary__dashboard_telemetry_history_gauge dashboard_telemetry_history_gauge--leftGauge">
<h5 class="telemetry_summary_gauge_control__gauge_header" id="leftGaugeLabel">@Strings.MaxOfDeviceTemperature</h5>
<div id="leftGauge" class="dashboard_telemetry_history_gauge__telemetry_summary_gauge_control"></div>
</div>
<div id="avgDeviceHumidityContainer" class="dashboard_telemetry_history_summary__dashboard_telemetry_history_gauge dashboard_telemetry_history_gauge--rightGauge">
<h5 class="telemetry_summary_gauge_control__gauge_header" id="avgDeviceHumidityLabel">@Strings.AverageOfDeviceHumidity</h5>
<div id="averageDeviceHumidity" class="dashboard_telemetry_history_gauge__telemetry_summary_gauge_control"></div>
<div id="middleGaugeContainer" class="dashboard_telemetry_history_summary__dashboard_telemetry_history_gauge dashboard_telemetry_history_gauge--centerGauge">
<h5 class="telemetry_summary_gauge_control__gauge_header" id="leftGaugeLabel">@Strings.MinOfDeviceTemperature</h5>
<div id="middleGauge" class="dashboard_telemetry_history_gauge__telemetry_summary_gauge_control"></div>
</div>
<div id="avgDeviceTemperatureContainer" class="dashboard_telemetry_history_summary__dashboard_telemetry_history_gauge dashboard_telemetry_history_gauge--rightGauge">
<h5 class="telemetry_summary_gauge_control__gauge_header" id="avgDeviceTemperatureLabel">@Strings.AverageOfDeviceTemperature</h5>
<div id="rightGauge" class="dashboard_telemetry_history_gauge__telemetry_summary_gauge_control"></div>
</div>
</div>
<script src="~/Scripts/Views/Dashboard/TelemetryHistorySummary.js?ver=@Constants.JSVersion"></script>
@ -19,17 +20,17 @@
'use strict';
var telemetryHistorySummarySettings = {
averageDeviceHumidityContainer: $('#avgDeviceHumidityContainer'),
averageDeviceHumidityControl: $('#averageDeviceHumidity'),
averageDeviceHumidityLabel: $('#avgDeviceHumidityLabel'),
gaugeMaxValue: 100,
gaugeMinValue: 0,
maxDeviceHumidityContainer: $('#maxDeviceHumidityContainer'),
maxDeviceHumidityControl: $('#maxDevicehumidity'),
maxDeviceHumidityLabel: $('#maxDeviceHumidityLabel'),
minDeviceHumidityContainer: $('#minDeviceHumidityContainer'),
minDeviceHumidityControl: $('#minDeviceHumidity'),
minDeviceHumidityLabel: $('#maxDeviceHumidityLabel')
leftGaugeContainer: $('#leftGaugeContainer'),
leftGaugeControl: $('#leftGauge'),
leftGaugeLabel: $('#leftGaugeLabel'),
middleGaugeContainer: $('#middleGaugeContainer'),
middleGaugeControl: $('#middleGauge'),
middleGaugeLabel: $('#leftGaugeLabel'),
rightGaugeContainer: $('#avgDeviceTemperatureContainer'),
rightGaugeControl: $('#rightGauge'),
rightGaugeLabel: $('#avgDeviceTemperatureLabel')
};
IoTApp.Dashboard.TelemetryHistorySummary.init(telemetryHistorySummarySettings);

Просмотреть файл

@ -566,6 +566,7 @@
<Content Include="Scripts\powerbi-visuals.all.min.js" />
<Content Include="Scripts\Views\Advanced\Advanced.js" />
<Content Include="Scripts\Views\Dashboard\AlertHistory.js" />
<Content Include="Scripts\Views\Dashboard\BaiduMapPane.js" />
<Content Include="Scripts\Views\Dashboard\DashboardDevicePane.js" />
<Content Include="Scripts\Views\Dashboard\JobIndicators.js" />
<Content Include="Scripts\Views\Dashboard\MapPane.js" />

Просмотреть файл

@ -18,8 +18,10 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.
{
new DeviceListColumns { Name = "tags.HubEnabledState", Alias = Strings.StatusHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "deviceId", Alias = Strings.DeviceIdHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "tags.DisplayName", Alias = Strings.DeviceDisplayNameHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "reported.System.Manufacturer", Alias = Strings.ManufactureHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "reported.System.FirmwareVersion", Alias = Strings.FirmwareHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "reported.Config.TelemetryInterval", Alias = Strings.TelemetryIntervalHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "tags.Building", Alias = Strings.BuildingHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "reported.Config.TemperatureMeanValue", Alias = Strings.TemperatureHeader.ToUpperInvariant() },
new DeviceListColumns { Name = "reported.Method.UpdateFirmware.Status", Alias = Strings.FwStatusHeader.ToUpperInvariant() }

Просмотреть файл

@ -127,7 +127,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Simulator.WebJob
var telemetry = _telemetryController as ITelemetryWithTemperatureMeanValue;
if (telemetry != null)
{
telemetry.TemperatureMeanValue = 34.5;
telemetry.TemperatureMeanValue = 19;
}
await UpdateReportedTemperatureMeanValue();

Просмотреть файл

@ -53,7 +53,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Simulator.WebJob
int peakFrequencyInTicks = Convert.ToInt32(Math.Ceiling((double)PEAK_FREQUENCY_IN_SECONDS / REPORT_FREQUENCY_IN_SECONDS));
_temperatureGenerator = new SampleDataGenerator(33, 36, 42, peakFrequencyInTicks);
_temperatureGenerator = new SampleDataGenerator(18, 20, 21, peakFrequencyInTicks);
_humidityGenerator = new SampleDataGenerator(20, 50);
_externalTemperatureGenerator = new SampleDataGenerator(-20, 120);

Просмотреть файл

@ -44,9 +44,9 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Simulator.WebJob
_steps = new List<DMTaskStep>
{
new DMTaskStep { CurrentState = DMTaskState.FU_PENDING, ExecuteTime = TimeSpan.Zero, NextState = DMTaskState.FU_DOWNLOADING },
new DMTaskStep { CurrentState = DMTaskState.FU_DOWNLOADING, ExecuteTime = TimeSpan.FromSeconds(20), NextState = DMTaskState.FU_APPLYING },
new DMTaskStep { CurrentState = DMTaskState.FU_APPLYING, ExecuteTime = TimeSpan.FromSeconds(20), NextState = DMTaskState.FU_REBOOTING },
new DMTaskStep { CurrentState = DMTaskState.FU_REBOOTING, ExecuteTime = TimeSpan.FromSeconds(20), NextState = DMTaskState.DM_IDLE }
new DMTaskStep { CurrentState = DMTaskState.FU_DOWNLOADING, ExecuteTime = TimeSpan.FromSeconds(1), NextState = DMTaskState.FU_APPLYING },
new DMTaskStep { CurrentState = DMTaskState.FU_APPLYING, ExecuteTime = TimeSpan.FromSeconds(1), NextState = DMTaskState.FU_REBOOTING },
new DMTaskStep { CurrentState = DMTaskState.FU_REBOOTING, ExecuteTime = TimeSpan.FromSeconds(1), NextState = DMTaskState.DM_IDLE }
};
}

Просмотреть файл

@ -122,7 +122,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Simulator.WebJob
protected virtual void InitDeviceInfo(InitialDeviceConfig config)
{
DeviceModel initialDevice = SampleDeviceFactory.GetSampleSimulatedDevice(config.DeviceId, config.Key);
DeviceModel initialDevice = SampleDeviceFactory.GetSampleSimulatedDevice(config);
DeviceProperties = initialDevice.DeviceProperties;
Commands = initialDevice.Commands ?? new List<Command>();
Telemetry = initialDevice.Telemetry ?? new List<Common.Models.Telemetry>();

Просмотреть файл

@ -20,7 +20,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
[Fact]
public async void ExecuteLogicAppAsyncTest()
{
var actionId = "Send Message";
var actionId = "发送消息";
var deviceId = "TestDeviceID";
var measurementName = "TestMeasurementName";
var measuredValue = 10.0;

Просмотреть файл

@ -5,7 +5,6 @@ using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastr
using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastructure.Repository;
using Moq;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoMoq;
using Xunit;
namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infrastructure
@ -48,10 +47,10 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
Assert.True(await _actionMappingLogic.InitializeDataIfNecessaryAsync());
Assert.Equal(2, savedMappings.Count);
Assert.Equal("Send Message", savedMappings[0].ActionId);
Assert.Equal("AlarmTemp", savedMappings[0].RuleOutput);
Assert.Equal("Raise Alarm", savedMappings[1].ActionId);
Assert.Equal("AlarmHumidity", savedMappings[1].RuleOutput);
Assert.Equal(ActionMappingLogic.ActionIdSendMessage, savedMappings[0].ActionId);
Assert.Equal(ActionMappingLogic.RuleOutputAlarmTemperature, savedMappings[0].RuleOutput);
Assert.Equal(ActionMappingLogic.ActionIdRaiseAlert, savedMappings[1].ActionId);
Assert.Equal(ActionMappingLogic.RuleOutputAlarmHumidity, savedMappings[1].RuleOutput);
}
[Fact]
@ -95,8 +94,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
var ret = await _actionMappingLogic.GetAvailableRuleOutputsAsync();
Assert.NotNull(ret);
Assert.Equal(2, ret.Count);
Assert.Equal("AlarmTemp", ret[0]);
Assert.Equal("AlarmHumidity", ret[1]);
Assert.Equal(ActionMappingLogic.RuleOutputAlarmTemperature, ret[0]);
Assert.Equal(ActionMappingLogic.RuleOutputAlarmHumidity, ret[1]);
}
}
}

Просмотреть файл

@ -271,11 +271,10 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
{
}
}
var offset = 0.05;
var minLat = latitudes.Min() - offset;
var maxLat = latitudes.Max() + offset;
var minLong = longitudes.Min() - offset;
var maxLong = longitudes.Max() + offset;
var minLat = latitudes.Min();
var maxLat = latitudes.Max();
var minLong = longitudes.Min();
var maxLong = longitudes.Max();
var res = this._deviceLogic.ExtractLocationsData(listOfDevices);
Assert.NotNull(res);
@ -289,10 +288,10 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
Assert.NotNull(res);
Assert.Equal(JsonConvert.SerializeObject(new List<DeviceLocationModel>()),
JsonConvert.SerializeObject(res.DeviceLocationList));
Assert.Equal(47.6 - offset, res.MinimumLatitude);
Assert.Equal(47.6 + offset, res.MaximumLatitude);
Assert.Equal(-122.3 - offset, res.MinimumLongitude);
Assert.Equal(-122.3 + offset, res.MaximumLongitude);
Assert.Equal(47.6, res.MinimumLatitude);
Assert.Equal(47.6, res.MaximumLatitude);
Assert.Equal(-122.3, res.MinimumLongitude);
Assert.Equal(-122.3, res.MaximumLongitude);
}
[Fact]

Просмотреть файл

@ -113,7 +113,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
Assert.Equal(desiredY.DisplayOrder, 2);
var reportedZ = res.Single(m => m.Name == "properties.reported.z");
Assert.Equal(reportedZ.Value, now.ToString(CultureInfo.InvariantCulture));
Assert.Equal(reportedZ.Value, now.ToString(CultureInfo.DefaultThreadCurrentCulture));
Assert.Equal(reportedZ.IsEditable, false);
Assert.Equal(reportedZ.DisplayOrder, 3);

Просмотреть файл

@ -70,7 +70,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
var minTime = new DateTime(year, month, date);
var blobReader = new Mock<IBlobStorageReader>();
var blobData = "deviceid,averagehumidity,minimumhumidity,maxhumidity,timeframeminutes" + Environment.NewLine +
var blobData = "deviceid,averagetemperature,minimumtemperature,maximumtemperature,timeframeminutes" + Environment.NewLine +
"test2,37.806204872115607,37.806204872115607,37.806204872115607,5";
var stream = new MemoryStream(Encoding.UTF8.GetBytes(blobData));
var blobContents = new BlobContents {Data = stream, LastModifiedTime = DateTime.UtcNow};
@ -84,9 +84,9 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
await deviceTelemetryRepository.LoadLatestDeviceTelemetrySummaryAsync("test2", minTime);
Assert.NotNull(telemetrySummaryList);
Assert.Equal(telemetrySummaryList.DeviceId, "test2");
Assert.Equal(telemetrySummaryList.AverageHumidity, 37.806204872115607);
Assert.Equal(telemetrySummaryList.MinimumHumidity, 37.806204872115607);
Assert.Equal(telemetrySummaryList.MaximumHumidity, 37.806204872115607);
Assert.Equal(telemetrySummaryList.AverageTemperature, 37.806204872115607);
Assert.Equal(telemetrySummaryList.MinimumTemperature, 37.806204872115607);
Assert.Equal(telemetrySummaryList.MaximumTemperature, 37.806204872115607);
Assert.Equal(telemetrySummaryList.TimeFrameMinutes, 5);
}
}