Former-commit-id: fa6b7f38bac00760d03318d380e8dc8283f41fd1
TangShanKaiPing
wanggang 6 years ago
parent 0b5cb48240
commit a7f5aead33

@ -28,7 +28,7 @@
<PackageReference Include="MailKit" Version="2.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc4" />

@ -4,26 +4,6 @@
ViewData["IsHomePage"] = true;
var max = env.IsDevelopment() ? 10 : 1;
}
<div class="row">
<div class="col-md-12"><div class="callout callout-success"><h4>节点</h4></div></div>
@for (int i = 0; i < max; i++)
{
foreach (var item in Model.Nodes)
{
<div class="col-md-2 col-xs-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">@item.Name</h3>
<div class="pull-right box-tools">设备:@item.DeviceCount </div>
</div>
<a class="box-body" href="@Url.Action("Index","Device",new { nodeId=item.Id})" style="display:block;text-align:center;">
<img alt="@item.Name" src="@(item.Image??"/images/empty.png")" style="margin:0 auto;" />
</a>
</div>
</div>
}
}
</div>
<div class="row">
<div class="col-md-12"><div class="callout callout-success"><h4>分类</h4></div></div>
@foreach (var item in Model.Categories)
@ -57,4 +37,24 @@
</div>
</div>
}
</div>
<div class="row">
<div class="col-md-12"><div class="callout callout-success"><h4>节点</h4></div></div>
@for (int i = 0; i < max; i++)
{
foreach (var item in Model.Nodes)
{
<div class="col-md-2 col-xs-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">@item.Name</h3>
<div class="pull-right box-tools">设备:@item.DeviceCount </div>
</div>
<a class="box-body" href="@Url.Action("Index","Device",new { nodeId=item.Id})" style="display:block;text-align:center;">
<img alt="@item.Name" src="@(item.Image??"/images/empty.png")" style="margin:0 auto;" />
</a>
</div>
</div>
}
}
</div>

@ -22,8 +22,8 @@
<link rel="stylesheet" href="~/css/site.css">
<title>@HtmlTitle | @cfg["name"]</title>
</head>
<body class="hold-transition skin-blue-light layout-top-nav">
<div class="wrapper overlay-wrapper">
<body class="hold-transition skin-blue-light layout-top-nav fixed">
<div class="wrapper">
<header class="main-header">
<nav class="navbar navbar-static-top">
<div class="container">
@ -33,6 +33,8 @@
<i class="fa fa-bars"></i>
</button>
</div>
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
</div>
<div class="navbar-custom-menu">
@if (User.Identity.IsAuthenticated)
{

@ -1,5 +1,4 @@
@model string
@inject IConfiguration cfg
@inject IConfiguration cfg
@{
Layout = null;
}

@ -198,6 +198,48 @@
</div>
</div>
</template>
<template v-for="device in GetDevices('色暖灯')">
<div class="row">
<div class="col-md-12">
<div class="box box-solid btns">
<div class="box-header with-border">
<h3 class="box-title"><img src="/images/light2.png" style="height:16px;margin-right:10px;" />{{device.DisplayName||device.Name}}</h3>
<div class="box-tools pull-right">
<img v-if="GetDataValue(device.Number,'状态')=='开'" @click="CallApi(device.Number,'/WarmLight/Off')" src="/images/on.png" />
<img v-if="GetDataValue(device.Number,'状态')=='关'" @click="CallApi(device.Number,'/WarmLight/On')" src="/images/off.png" />
</div>
</div>
<div class="box-body" style="height:178px;">
<form method="get" action="/App/ExecApi">
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/WarmLight/SetBrightness" />
<div class="row">
<div class="col-md-2 col-xs-4">
<span class="label1">亮度</span>
</div>
<div class="col-md-10 col-xs-8">
<input @change="AjaxSubmit($event,device.Number,'亮度')" type="range" min="0" step="1" max="255" name="Brightness" :value="GetDataValue(device.Number,'亮度')" />
</div>
</div>
</form>
<form method="get" action="/App/ExecApi">
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/WarmLight/SetColor" />
<input type="hidden" name="Saturation" :value="GetDataValue(device.Number,'饱和度')" />
<div class="row">
<div class="col-md-2 col-xs-4">
<span class="label1">色调</span>
</div>
<div class="col-md-10 col-xs-8">
<input @change="AjaxSubmit($event,device.Number,'色调')" type="range" min="0" step="1" max="255" name="Hue" :value="GetDataValue(device.Number,'色调')" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</template>
<template v-for="device in GetDevices('调色灯')">
<div class="row">
@ -248,6 +290,7 @@
</div>
</div>
</template>
<template v-for="device in GetDevices('红外转发器')">
<div class="row">
<div class="col-md-12">

@ -371,14 +371,14 @@
<div class="box-header with-border">
<h3 class="box-title"><img src="/images/light2.png" style="height:18px;margin-right:10px;" />{{device.DisplayName||device.Name}}</h3>
<div class="box-tools pull-right">
<img v-if="GetDataValue(device.Number,'状态')=='开'" @click="CallApi(device.Number,'/ColorLight/Off')" src="/images/on.png" />
<img v-if="GetDataValue(device.Number,'状态')=='关'" @click="CallApi(device.Number,'/ColorLight/On')" src="/images/off.png" />
<img v-if="GetDataValue(device.Number,'状态')=='开'" @click="CallApi(device.Number,'/WarmLight/Off')" src="/images/on.png" />
<img v-if="GetDataValue(device.Number,'状态')=='关'" @click="CallApi(device.Number,'/WarmLight/On')" src="/images/off.png" />
</div>
</div>
<div class="box-body">
<form method="get" action="/App/Exec">
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/ColorLight/SetBrightness" />
<input type="hidden" name="Method" value="/WarmLight/SetBrightness" />
<div class="row">
<div class="col-md-3">
<span class="label1">亮度</span>
@ -390,7 +390,7 @@
</form>
<form method="get" action="/App/Exec">
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/ColorLight/SetColor" />
<input type="hidden" name="Method" value="/WarmLight/SetColor" />
<div class="row">
<div class="col-md-3">
<span class="label1">色调</span>

@ -12,4 +12,7 @@
<ItemGroup>
<EmbeddedResource Include="wwwroot\**\*" />
</ItemGroup>
<ItemGroup>
<None Remove="wwwroot\images\lamp.png" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -494,15 +494,15 @@
</ul>
</div>
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.GatewayNumber,device.Number,'/ColorLight/On')" v-if="getData(device,'状态')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.GatewayNumber,device.Number,'/ColorLight/Off')" v-else></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.GatewayNumber,device.Number,'/WarmLight/On')" v-if="getData(device,'状态')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.GatewayNumber,device.Number,'/WarmLight/Off')" v-else></a>
</div>
<div class="row">
<form class="ajax" method="get" :action="'http://'+vm.Login.Host+'/IoTCenter/App/Exec'">
<input type="hidden" name="ConnectionId" :value="vm.ConnectionId" />
<input type="hidden" name="Gateway" :value="device.GatewayNumber" />
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/ColorLight/SetBrightness" />
<input type="hidden" name="Method" value="/WarmLight/SetBrightness" />
<div class="list inline-labels no-hairlines-md">
<ul>
<li class="item-content item-input">
@ -525,7 +525,7 @@
<input type="hidden" name="ConnectionId" :value="vm.ConnectionId" />
<input type="hidden" name="Gateway" :value="device.GatewayNumber" />
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/ColorLight/SetColor" />
<input type="hidden" name="Method" value="/WarmLight/SetColor" />
<div class="list inline-labels no-hairlines-md">
<ul>
<li class="item-content item-input">
@ -559,7 +559,7 @@
<input type="hidden" name="ConnectionId" :value="vm.ConnectionId" />
<input type="hidden" name="Gateway" :value="device.GatewayNumber" />
<input type="hidden" name="Number" :value="device.Number" />
<input type="hidden" name="Method" value="/ColorLight/SetColorTemperature" />
<input type="hidden" name="Method" value="/WarmLight/SetColorTemperature" />
<div class="list inline-labels no-hairlines-md">
<ul>
<li class="item-content item-input">

@ -1,87 +1,14 @@
using Application.Models;
using Infrastructure.Extensions;
using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc;
using IoTNode.DeviceServices.FBee;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers
{
[SwaggerTag("调色灯")]
public class ColorLightController : SwitchController
public class ColorLightController : WarmLightController
{
internal readonly FBeeService _deviceService;
public ColorLightController(IServiceProvider applicationServices, FBeeService deviceService) : base(applicationServices, deviceService)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse SetBrightness([SwaggerParameter("设备编号")]string number, [SwaggerParameter("亮度")][Range(0, 255)]int brightness)
{
if (number is null)
{
throw new ArgumentNullException(nameof(number));
}
try
{
var values = number.Split('-');
this._deviceService.X83(values[0], values[1], (byte)brightness);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse SetColor([SwaggerParameter("设备编号")]string number, [SwaggerParameter("色调")][Range(0, 255)]int hue, [SwaggerParameter("饱和度")][Range(0, 255)]int saturation)
{
if (number is null)
{
throw new ArgumentNullException(nameof(number));
}
try
{
var values = number.Split('-');
this._deviceService.X84(values[0], values[1], (byte)hue, (byte)saturation);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse SetColorTemperature([SwaggerParameter("设备编号")]string number, [SwaggerParameter("色温")][Range(2700, 6500)]int colorTemperature)
{
if (number is null)
{
throw new ArgumentNullException(nameof(number));
}
try
{
var values = number.Split('-');
this._deviceService.XA8(values[0], values[1], (ushort)colorTemperature);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
}
}

@ -0,0 +1,87 @@
using Application.Models;
using Infrastructure.Extensions;
using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers
{
[SwaggerTag("色暖灯")]
public class WarmLightController : SwitchController
{
internal readonly FBeeService _deviceService;
public WarmLightController(IServiceProvider applicationServices, FBeeService deviceService) : base(applicationServices, deviceService)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse SetBrightness([SwaggerParameter("设备编号")]string number, [SwaggerParameter("亮度")][Range(0, 255)]int brightness)
{
if (number is null)
{
throw new ArgumentNullException(nameof(number));
}
try
{
var values = number.Split('-');
this._deviceService.X83(values[0], values[1], (byte)brightness);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse SetColor([SwaggerParameter("设备编号")]string number, [SwaggerParameter("色调")][Range(0, 255)]int hue, [SwaggerParameter("饱和度")][Range(0, 255)]int saturation)
{
if (number is null)
{
throw new ArgumentNullException(nameof(number));
}
try
{
var values = number.Split('-');
this._deviceService.X84(values[0], values[1], (byte)hue, (byte)saturation);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")]
public ApiResponse SetColorTemperature([SwaggerParameter("设备编号")]string number, [SwaggerParameter("色温")][Range(2700, 6500)]int colorTemperature)
{
if (number is null)
{
throw new ArgumentNullException(nameof(number));
}
try
{
var values = number.Split('-');
this._deviceService.XA8(values[0], values[1], (ushort)colorTemperature);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
}
}

@ -14,7 +14,8 @@ namespace IoTNode.DeviceServices.FBee
List.Add(new DeviceId { RawDeviceId = 0x0106, Name = "光强检测器", CategoryName = "监测", CategoryNumber = "40", Icon = "light" });
List.Add(new DeviceId { RawDeviceId = 0x0163, Name = "红外转发器", CategoryName = "电器", CategoryNumber = "20", Icon = "control" });
List.Add(new DeviceId { RawDeviceId = 0x0202, Name = "窗帘", CategoryName = "电器", CategoryNumber = "20", Icon = "curtain" });
List.Add(new DeviceId { RawDeviceId = 0x0220, Name = "调色灯", CategoryName = "照明", CategoryNumber = "30", Icon = "curtain" });
List.Add(new DeviceId { RawDeviceId = 0x0210, Name = "调色灯", CategoryName = "照明", CategoryNumber = "30", Icon = "lamp" });
List.Add(new DeviceId { RawDeviceId = 0x0220, Name = "色暖灯", CategoryName = "照明", CategoryNumber = "30", Icon = "lamp" });
List.Add(new DeviceId { RawDeviceId = 0x0309, Name = "粉尘检测器", CategoryName = "监测", CategoryNumber = "40", Icon = "pm25" });
List.Add(new DeviceId { RawDeviceId = 0x0302, Name = "温湿度传感器", CategoryName = "监测", CategoryNumber = "40", Icon = "humiture" });
List.Add(new DeviceId { RawDeviceId = 0x0402, Name = "报警器", CategoryName = "安防", CategoryNumber = "10", Icon = "alarm" });

@ -555,6 +555,10 @@ namespace IoTNode.DeviceServices.FBee
{
return "/ColorLight/";
}
else if (deviceName == "色暖灯")
{
return "/WarmLight/";
}
else if (deviceName == "红外转发器")
{
return "/Ir/";
@ -730,7 +734,7 @@ namespace IoTNode.DeviceServices.FBee
}
/// <summary>
/// 0x83设置指定设备的颜色,即色调和饱和度
/// 0x84设置指定设备的颜色,即色调和饱和度
/// </summary>
public void X84(string sn, string ieee, [Range(0, 255)]byte hue, [Range(0, 255)]byte saturation)
{

@ -43,6 +43,8 @@ namespace IoTNode
new EFConfigurationValue { Id = "stream.flv", Value=$"{stream}/live"},
new EFConfigurationValue { Id = "stream.hls", Value=$"{stream}/live"},
new EFConfigurationValue { Id = "ffmpeg.args", Value=" -y -threads {0} -rtsp_transport tcp -use_wallclock_as_timestamps 1 -stimeout 3000000 -i \"{1}\" -fflags +genpts -c copy -f flv \"{2}\""},
new EFConfigurationValue { Id = "fbee.writelist", Value=""},
new EFConfigurationValue { Id = "camera.writelist", Value=""},
//
new EFConfigurationValue { Id = "name", Value= "物联网节点"},
new EFConfigurationValue { Id = "logo", Value= "/images/logo.png",Type= InputType.ImageUrl},

Loading…
Cancel
Save