|
|
@model List<Device>
|
|
|
@{
|
|
|
this.HtmlTitle = "设备列表";
|
|
|
var index = 0;
|
|
|
}
|
|
|
<div class="box">
|
|
|
<table class="table table-bordered">
|
|
|
<tr>
|
|
|
<th></th>
|
|
|
<th>编号</th>
|
|
|
<th>名称</th>
|
|
|
<th>类别</th>
|
|
|
<th>地址</th>
|
|
|
<th>电量</th>
|
|
|
<th>在线状态</th>
|
|
|
<th>设备状态</th>
|
|
|
<th>连接Id</th>
|
|
|
<th>操作</th>
|
|
|
<th>删除</th>
|
|
|
</tr>
|
|
|
@foreach (var item in Model)
|
|
|
{
|
|
|
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 = item.Data.FirstOrDefault(o => o.Key == "State")?.Value;
|
|
|
var battery = item.Data.FirstOrDefault(o => o.Key == "Battery")?.Value;
|
|
|
<tr>
|
|
|
<th>@(++index)</th>
|
|
|
<td>@item.Number</td>
|
|
|
<td>@item.Name</td>
|
|
|
<td>@deviceId</td>
|
|
|
<td>@address</td>
|
|
|
<td>@voltage/@battery</td>
|
|
|
<td>@Html.DisplayFor(o => item.IsOnline)</td>
|
|
|
<td>
|
|
|
@if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
|
|
|
{
|
|
|
<text>@state</text>
|
|
|
}
|
|
|
@if (deviceId == 0x0106)
|
|
|
{
|
|
|
<text>@item.Data.FirstOrDefault(o => o.Key == "Light")?.Value</text>
|
|
|
}
|
|
|
else if (deviceId == 0x0402)
|
|
|
{
|
|
|
<text>@item.Data.FirstOrDefault(o => o.Key == "Warning")?.Value</text>
|
|
|
}
|
|
|
else if (deviceId == 0x0309)
|
|
|
{
|
|
|
<span>温度:@item.Data.FirstOrDefault(o => o.Key == "Temperature")?.Value</span>
|
|
|
<span>湿度:@item.Data.FirstOrDefault(o => o.Key == "Humidity")?.Value</span>
|
|
|
<br />
|
|
|
<span>PM 1.0:@item.Data.FirstOrDefault(o => o.Key == "PM10")?.Value</span>
|
|
|
<span>PM 2.5:@item.Data.FirstOrDefault(o => o.Key == "PM25")?.Value</span>
|
|
|
<span>PM 10:@item.Data.FirstOrDefault(o => o.Key == "PM100")?.Value</span>
|
|
|
}
|
|
|
else if (deviceId == 0x0302)
|
|
|
{
|
|
|
<span>温度:@item.Data.FirstOrDefault(o => o.Key == "Temperature")?.Value</span>
|
|
|
<span>湿度:@item.Data.FirstOrDefault(o => o.Key == "Humidity")?.Value</span>
|
|
|
}
|
|
|
else if (deviceId == 0x0220)
|
|
|
{
|
|
|
<span>亮度:@item.Data.FirstOrDefault(o => o.Key == "Brightness")?.Value</span>
|
|
|
<br />
|
|
|
<span>色调: @item.Data.FirstOrDefault(o => o.Key == "Hue")?.Value</span>
|
|
|
<span>饱和度: @item.Data.FirstOrDefault(o => o.Key == "Saturation")?.Value</span>
|
|
|
<br />
|
|
|
<span>色温:@item.Data.FirstOrDefault(o => o.Key == "ColorTemperature")?.Value</span>
|
|
|
}
|
|
|
else if (deviceId == 0x0163)
|
|
|
{
|
|
|
var version = item.Data.FirstOrDefault(o => o.Key == "Version")?.Value;
|
|
|
if (!string.IsNullOrEmpty(version))
|
|
|
{
|
|
|
<span>版本:@version</span>
|
|
|
}
|
|
|
}
|
|
|
else if (deviceId == 0x0051)
|
|
|
{
|
|
|
var electricity = item.Data.FirstOrDefault(o => o.Key == "Electricity")?.Value;
|
|
|
if (!string.IsNullOrEmpty(electricity))
|
|
|
{
|
|
|
<span>电量:@electricity</span>
|
|
|
}
|
|
|
|
|
|
}
|
|
|
</td>
|
|
|
<td>@item.ConnectId</td>
|
|
|
<td>
|
|
|
@if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId))
|
|
|
{
|
|
|
<a class="btn btn-primary cmd" href="/api/x82?sn=@item.GatewayNumber&ieee=@item.Number&status=1">开</a>
|
|
|
<a class="btn btn-primary cmd" href="/api/x82?sn=@item.GatewayNumber&ieee=@item.Number&status=0">关</a>
|
|
|
}
|
|
|
@if (deviceId == 0x0202)
|
|
|
{
|
|
|
<a class="btn btn-primary cmd" href="/api/x82?sn=@item.GatewayNumber&ieee=@item.Number&status=2">停</a>
|
|
|
}
|
|
|
@if (deviceId == 0x0163)
|
|
|
{
|
|
|
<a class="btn btn-primary cmd" href="/ir/version?sn=@item.GatewayNumber&id=@item.Number">版本</a>
|
|
|
}
|
|
|
@if (deviceId == 0x0220)
|
|
|
{
|
|
|
<form action="/colorlight/23setbrightness">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<label>亮度:<input name="Brightness" type="range" step="1" min="0" max="255" value="@item.Data.FirstOrDefault(o => o.Key == "Brightness")?.Value" class="ajax" /></label>
|
|
|
</form>
|
|
|
<form action="/colorlight/24setcolor">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<label>色度:<input name="Hue" type="range" step="1" min="0" max="255" value="@item.Data.FirstOrDefault(o => o.Key == "Hue")?.Value" class="ajax" /></label>
|
|
|
<label>饱和度:<input name="Saturation" type="range" step="1" min="0" max="255" value="@item.Data.FirstOrDefault(o => o.Key == "Saturation")?.Value" class="ajax" /></label>
|
|
|
</form>
|
|
|
<form action="/colorlight/25setcolortemperature">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<label>色温:<input name="ColorTemperature" type="range" step="1" min="2700" max="6500" value="@item.Data.FirstOrDefault(o => o.Key == "ColorTemperature")?.Value" class="ajax" /></label>
|
|
|
</form>
|
|
|
}
|
|
|
@if (deviceId == 0x0163)
|
|
|
{
|
|
|
<h2>发射:</h2>
|
|
|
<form action="/ir/test">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<label>设备类型:</label><select name="type">
|
|
|
<option value="1">空调</option>
|
|
|
<option value="2">电视</option>
|
|
|
<option value="3">机顶盒</option>
|
|
|
<option value="4">DVD</option>
|
|
|
<option value="5">其他</option>
|
|
|
</select>
|
|
|
<label>按键值:</label><input type="text" name="code" class="ajax" />
|
|
|
</form>
|
|
|
<h2>空调:</h2>
|
|
|
<form action="/ir/control">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<fieldset>
|
|
|
<legend>开关:</legend>
|
|
|
<label>开:<input name="power" type="radio" value="2" class="ajax" /></label>
|
|
|
<label>关:<input name="power" type="radio" value="1" class="ajax" /></label>
|
|
|
</fieldset>
|
|
|
<fieldset>
|
|
|
<legend>模式</legend>
|
|
|
<label>制冷:<input name="pattern" type="radio" value="0" class="ajax" /></label>
|
|
|
<label>自动:<input name="pattern" type="radio" value="120" class="ajax" /></label>
|
|
|
<label>制热:<input name="pattern" type="radio" value="240" class="ajax" /></label>
|
|
|
<label>抽湿:<input name="pattern" type="radio" value="360" class="ajax" /></label>
|
|
|
<label>送风:<input name="pattern" type="radio" value="480" class="ajax" /></label>
|
|
|
</fieldset>
|
|
|
<fieldset>
|
|
|
<label>温度:<input name="temperature" type="range" step="1" min="1" max="15" value="1" class="ajax" /></label>
|
|
|
</fieldset>
|
|
|
<fieldset>
|
|
|
<legend>风向</legend>
|
|
|
<label>任意:<input name="direction" type="radio" value="0" class="ajax" /></label>
|
|
|
<label>手动:<input name="direction" type="radio" value="60" class="ajax" /></label>
|
|
|
<label>自动:<input name="direction" type="radio" value="75" class="ajax" /></label>
|
|
|
</fieldset>
|
|
|
<fieldset>
|
|
|
<legend>风量</legend>
|
|
|
<label>自动:<input name="wind" type="radio" value="0" class="ajax" /></label>
|
|
|
<label>高:<input name="wind" type="radio" value="15" class="ajax" /></label>
|
|
|
<label>中:<input name="wind" type="radio" value="30" class="ajax" /></label>
|
|
|
<label>低:<input name="wind" type="radio" value="45" class="ajax" /></label>
|
|
|
</fieldset>
|
|
|
</form>
|
|
|
<h2>电视:</h2>
|
|
|
<form action="/ir/test">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<input type="hidden" name="type" value="2" />
|
|
|
@{
|
|
|
var tvKeys = new string[] { "POWR","AV","1","2","3","4","5","6","7","8","9","0",
|
|
|
"返回","退出","静音","菜单","音量+","音量-","上","下","左","右",
|
|
|
"OK","CH+>>|","CH-|<<","快退","快进","录像","暂停","停止","红","绿","黄","蓝",
|
|
|
"自定义","自定义","自定义","自定义","自定义","自定义","自定义","自定义"};
|
|
|
}
|
|
|
@for (int i = 0; i < tvKeys.Length; i++)
|
|
|
{
|
|
|
|
|
|
<label>@tvKeys[i]:@(i + 1)<input name="code" type="radio" value="@(i+1)" class="ajax" /></label>
|
|
|
@if (i % 5 == 0)
|
|
|
{
|
|
|
<br />
|
|
|
}
|
|
|
}
|
|
|
</form>
|
|
|
<h2>学习:</h2>
|
|
|
<form action="/ir/study">
|
|
|
<input type="hidden" name="sn" value="@item.GatewayNumber" />
|
|
|
<input type="hidden" name="id" value="@item.Number" />
|
|
|
<input type="hidden" name="type" value="5" />
|
|
|
<label>按键值:</label><input min="511" max="610" type="text" name="code" class="ajax" />
|
|
|
</form>
|
|
|
}
|
|
|
</td>
|
|
|
<td><a class="btn btn-primary cmd" href="/api/x95?sn=@item.GatewayNumber&ieee=@item.Number">删除设备</a></td>
|
|
|
</tr>
|
|
|
}
|
|
|
</table>
|
|
|
</div>
|
|
|
@section scripts{
|
|
|
<script>
|
|
|
$('body').on('change', '.ajax', function () {
|
|
|
var form = $(this).parents('form');
|
|
|
var url = form.attr('action') + '?' + form.serialize();
|
|
|
$.getJSON(url, function (response) {
|
|
|
console.log(response);
|
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
|
var err = textStatus + ", " + error;
|
|
|
alert(err);
|
|
|
});
|
|
|
return false;
|
|
|
});
|
|
|
</script>
|
|
|
} |