Former-commit-id: 562eefe97dbdd4c4c0b9d4cb743a8a98c4b0714f
TangShanKaiPing
wanggang 6 years ago
parent cc8ee07c5c
commit 34fb198426

@ -1,13 +1,65 @@
using Swashbuckle.AspNetCore.Annotations;
using Application.Models;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.ComponentModel.DataAnnotations;
namespace FBeeService.Controllers
{
[SwaggerTag("调色灯")]
public class ColorLightController : SwitchController
{
public ColorLightController(IServiceProvider applicationService, DeviceService deviceService) : base(applicationService, deviceService)
protected readonly DeviceService _deviceService;
public ColorLightController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices, deviceService)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetBrightness([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [Range(0, 255)]int brightness)
{
try
{
this._deviceService.X83(sn, id, (byte)brightness);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetColor([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [Range(0, 255)]int hue, [Range(0, 255)]int saturation)
{
try
{
this._deviceService.X84(sn, id, (byte)hue, (byte)saturation);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetColorTemperature([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [Range(2700, 6500)]int colorTemperature)
{
try
{
this._deviceService.XA8(sn, id, (ushort)colorTemperature);
}
catch (Exception ex)
{
ex.PrintStack();
return ApiResponse.Error(ex.Message);
}
return ApiResponse.AsyncSuccess();
}
}
}

@ -170,10 +170,10 @@ namespace FBeeService.Controllers
return GetApiJson("/colorlight/");
}
[SwaggerOperation("调节亮度")]
[SwaggerOperation("亮度")]
[HttpGet]
[Route("/colorlight/23setbrightness")]
public ApiResponse SetBrightness([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [Range(0, 255)]int brightness)
public ApiResponse SetBrightness([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [SwaggerParameter("亮度")][Range(0, 255)]int brightness)
{
try
{
@ -187,10 +187,10 @@ namespace FBeeService.Controllers
return ApiResponse.AsyncSuccess();
}
[SwaggerOperation("调节亮度")]
[SwaggerOperation("颜色")]
[HttpGet]
[Route("/colorlight/24setcolor")]
public ApiResponse SetColor([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [Range(0, 255)]int hue, [Range(0, 255)]int saturation)
public ApiResponse SetColor([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [SwaggerParameter("色度")][Range(0, 255)]int hue, [SwaggerParameter("饱和度")][Range(0, 255)]int saturation)
{
try
{
@ -204,10 +204,10 @@ namespace FBeeService.Controllers
return ApiResponse.AsyncSuccess();
}
[SwaggerOperation("调节色温")]
[SwaggerOperation("色温")]
[HttpGet]
[Route("/colorlight/25setcolortemperature")]
public ApiResponse SetColorTemperature([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [Range(2700, 6500)]int colorTemperature)
public ApiResponse SetColorTemperature([SwaggerParameter("网关Id")]string sn, [SwaggerParameter("设备Id")]string id, [SwaggerParameter("色温")][Range(2700, 6500)]int colorTemperature)
{
try
{

@ -456,15 +456,15 @@ namespace FBeeService
{
if (zoneType == 0x0001)
{
deviceName = "1路开关";
deviceName = "路开关";
}
else if (zoneType == 0x0002)
{
deviceName = "2路开关";
deviceName = "路开关";
}
else if (zoneType == 0x0003)
{
deviceName = "3路开关";
deviceName = "路开关";
}
}
var infoNumber = $"fbee:{deviceType.RawDeviceId.ToString("x4")}:{zoneType.ToString("x2")}";
@ -485,15 +485,15 @@ namespace FBeeService
{
deviceInfo.ApiJson = this.GetApiJson("/Socket/");
}
else if (deviceName == "1路开关")
else if (deviceName == "路开关")
{
deviceInfo.ApiJson = this.GetApiJson("/Switch/");
}
else if (deviceName == "2路开关")
else if (deviceName == "路开关")
{
deviceInfo.ApiJson = this.GetApiJson("/Switch2/");
}
else if (deviceName == "3路开关")
else if (deviceName == "路开关")
{
deviceInfo.ApiJson = this.GetApiJson("/Switch3/");
}
@ -539,7 +539,7 @@ namespace FBeeService
device.AddorUpdateData(Keys.EndPoint, endpoint, DeviceDataType.Int, Keys.EndPoint, hidden: true);
if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
{
device.AddorUpdateData(Keys.State, switchState, DeviceDataType.Int, "状态");
device.AddorUpdateData(Keys.State, switchState == 0 ? "关" : (switchState == 1 ? "关" : "停"), DeviceDataType.String, "状态");
}
var battery = ms.ReadByte();
device.AddorUpdateData(Keys.Battery, battery, DeviceDataType.Int, Keys.Battery);
@ -643,7 +643,25 @@ namespace FBeeService
var device = this.GetDeviceByAddress(deviceRepo, sn, address);
if (device != null)
{
device.AddorUpdateData(Keys.State, ms.ReadInt(), DeviceDataType.Int, "状态");
if (device.Name.Contains("二路开关") || device.Name.Contains("三路开关"))
{
if (endpoint == 0x10)
{
device.AddorUpdateData(Keys.L1State, ms.ReadInt() == 0 ? "关" : "开", DeviceDataType.String, "L1状态");
}
else if (endpoint == 0x11)
{
device.AddorUpdateData(Keys.L2State, ms.ReadInt() == 0 ? "关" : "开", DeviceDataType.String, "L2状态");
}
else if (endpoint == 0x12)
{
device.AddorUpdateData(Keys.L3State, ms.ReadInt() == 0 ? "关" : "开", DeviceDataType.String, "L3状态");
}
}
else
{
device.AddorUpdateData(Keys.State, ms.ReadInt() == 0 ? "关" : "开", DeviceDataType.String, "状态");
}
deviceRepo.SaveChanges();
this.SendDevice(device);
}

@ -9,6 +9,9 @@
public const string Electricity = "Electricity";
public const string KeyPress = "KeyPress";
public const string State = "State";
public const string L1State = "L1State";
public const string L2State = "L2State";
public const string L3State = "L3State";
public const string Battery = "Battery";
public const string EndPointCount = "EndPointCount";
public const string Data = "Data";

@ -23,7 +23,7 @@
var deviceId = Convert.ToInt32(item.Data.FirstOrDefault(o => o.Key == "DeviceId").Value);
var address = item.Data.FirstOrDefault(o => o.Key == "Address").Value;
var voltage = item.Data.FirstOrDefault(o => o.Key == "Voltage")?.Value;
var state = Convert.ToInt32(item.Data.FirstOrDefault(o => o.Key == "State")?.Value);
var state = item.Data.FirstOrDefault(o => o.Key == "State")?.Value;
var battery = item.Data.FirstOrDefault(o => o.Key == "Battery")?.Value;
<tr>
<th>@(++index)</th>
@ -36,18 +36,7 @@
<td>
@if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
{
if (state == 0)
{
<text>关</text>
}
else if (state == 1)
{
<text>开</text>
}
else if (state == 2)
{
<text>停</text>
}
<text>@state</text>
}
@if (deviceId == 0x0106)
{

@ -156,7 +156,7 @@
<f7-list>
<f7-list-item title="用户名" :after="vm.UserName"></f7-list-item>
<f7-list-item title="昵称" :after="vm.NickName"></f7-list-item>
<f7-list-item link="/login/" title="注销1"></f7-list-item>
<f7-list-item link="/login/" title="注销"></f7-list-item>
</f7-list>
</f7-tab>
</f7-tabs>
@ -226,6 +226,242 @@
</div>
</div>
</template>
<template v-if="getDevices('窗帘').length">
<div class="block-title">窗帘</div>
<div class="block block-strong">
<div class="row">
<div class="col-100 tablet-50 desktop-25" v-for="device in getDevices('窗帘')">
<div class="list">
<ul>
<li>
<a class="item-link item-content"
:href="'/device/'+device.Number+'/name/'+device.Name">
<div class="item-media"> <img :src="'images/'+device.Icon+'.png'" /></div>
<div class="item-inner">
<div class="item-title">{{device.DisplayName||device.Name}}</div>
<div class="item-after"><span class="badge color-green">{{getData(device,"状态")}}</span></div>
</div>
</a>
</li>
</ul>
</div>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'On')"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Stop')"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Off')"></a>
</div>
</div>
<div class="row">
<div class="col-100 tablet-50 desktop-25"></div>
<div class="col-100 tablet-50 desktop-25">
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('窗帘','On')">批量开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('窗帘','Stop')">批量停</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('窗帘','Off')">批量关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('插座').length">
<div class="block-title">插座</div>
<div class="block block-strong">
<div class="row">
<div class="col-100 tablet-50 desktop-25" v-for="device in getDevices('插座')">
<div class="list">
<ul>
<li>
<a class="item-link item-content"
:href="'/device/'+device.Number+'/name/'+device.Name">
<div class="item-media"> <img :src="'images/'+device.Icon+'.png'" /></div>
<div class="item-inner">
<div class="item-title">{{device.DisplayName||device.Name}}</div>
<div class="item-after">
<span class="badge color-green">{{getData(device,"状态")}}</span>
</div>
</div>
</a>
</li>
</ul>
</div>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'On')" v-if="getData(device,'状态')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Off')" v-else></a>
</div>
</div>
<div class="row">
<div class="col-100 tablet-50 desktop-25"></div>
<div class="col-100 tablet-50 desktop-25">
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('插座','On')">批量开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('插座','Off')">批量关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('一路开关').length">
<div class="block-title">一路开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-100 tablet-50 desktop-25" v-for="device in getDevices('一路开关')">
<div class="list">
<ul>
<li>
<a class="item-link item-content"
:href="'/device/'+device.Number+'/name/'+device.Name">
<div class="item-media"> <img :src="'images/'+device.Icon+'.png'" /></div>
<div class="item-inner">
<div class="item-title">{{device.DisplayName||device.Name}}</div>
<div class="item-after">
<span class="badge color-green">{{getData(device,"状态")}}</span>
</div>
</div>
</a>
</li>
</ul>
</div>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'On')" v-if="getData(device,'状态')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Off')" v-else></a>
</div>
</div>
<div class="row">
<div class="col-100 tablet-50 desktop-25"></div>
<div class="col-100 tablet-50 desktop-25">
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('插座','On')">批量开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('插座','Off')">批量关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('二路开关').length">
<div class="block-title">二路开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-100 tablet-50 desktop-25" v-for="device in getDevices('二路开关')">
<div class="list">
<ul>
<li>
<a class="item-link item-content"
:href="'/device/'+device.Number+'/name/'+device.Name">
<div class="item-media"> <img :src="'images/'+device.Icon+'.png'" /></div>
<div class="item-inner">
<div class="item-title">{{device.DisplayName||device.Name}}</div>
<div class="item-after">
<span class="badge color-green">{{getData(device,"L1状态")}}</span>
<span class="badge color-green">{{getData(device,"L2状态")}}</span>
</div>
</div>
</a>
</li>
</ul>
</div>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'On')">全开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Off')">全关</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L1On')" v-if="getData(device,'状态4')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L1Off')" v-else></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L2On')" v-if="getData(device,'状态5')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L2Off')" v-else></a>
</div>
</div>
<div class="row">
<div class="col-100 tablet-50 desktop-25"></div>
<div class="col-100 tablet-50 desktop-25">
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('三路照明开关','On')">批量开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('三路照明开关','Off')">批量关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('三路开关').length">
<div class="block-title">三路开关</div>
<div class="block block-strong">
<div class="row">
<div class="col-100 tablet-50 desktop-25" v-for="device in getDevices('三路开关')">
<div class="list">
<ul>
<li>
<a class="item-link item-content"
:href="'/device/'+device.Number+'/name/'+device.Name">
<div class="item-media"> <img :src="'images/'+device.Icon+'.png'" /></div>
<div class="item-inner">
<div class="item-title">{{device.DisplayName||device.Name}}</div>
<div class="item-after">
<span class="badge color-green">{{getData(device,"L1状态")}}</span>
<span class="badge color-green">{{getData(device,"L2状态")}}</span>
<span class="badge color-green">{{getData(device,"L3状态")}}</span>
</div>
</div>
</a>
</li>
</ul>
</div>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'On')">全开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Off')">全关</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L1On')" v-if="getData(device,'状态4')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L1Off')" v-else></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L2On')" v-if="getData(device,'状态5')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L2Off')" v-else></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L3On')" v-if="getData(device,'状态6')==='关'"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'L3Off')" v-else></a>
</div>
</div>
<div class="row">
<div class="col-100 tablet-50 desktop-25"></div>
<div class="col-100 tablet-50 desktop-25">
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('三路照明开关','On')">批量开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('三路照明开关','Off')">批量关</a>
</div>
</div>
</div>
</div>
</template>
<template v-if="getDevices('调色灯').length">
<div class="block-title">调色灯</div>
<div class="block block-strong">
<div class="row">
<div class="col-100 tablet-50 desktop-25" v-for="device in getDevices('调色灯')">
<div class="list">
<ul>
<li>
<a class="item-link item-content"
:href="'/device/'+device.Number+'/name/'+device.Name">
<div class="item-media"> <img :src="'images/'+device.Icon+'.png'" /></div>
<div class="item-inner">
<div class="item-title">{{device.DisplayName||device.Name}}</div>
<div class="item-after"><span class="badge color-green">{{getData(device,"状态")}}</span></div>
</div>
</a>
</li>
</ul>
</div>
<div class="range-slider">
<!-- range input -->
<input type="range" min="0" max="100" step="1" value="10">
</div>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'On')"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Stop')"></a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="call(device.Id,'Off')"></a>
</div>
</div>
<div class="row">
<div class="col-100 tablet-50 desktop-25"></div>
<div class="col-100 tablet-50 desktop-25">
<div class="row">
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('窗帘','On')">批量开</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('窗帘','Stop')">批量停</a>
<a class="button button-large button-raised button-fill" href="javascript: ;" v-on:click="callAll('窗帘','Off')">批量关</a>
</div>
</div>
</div>
</div>
</template>
</f7-page>
</template>
<template id="page-device">

Loading…
Cancel
Save