diff --git a/docs/资料/物联网中心/设备接入/力创/命令文档整洁版.xlsx b/docs/资料/物联网中心/设备接入/力创/命令文档整洁版.xlsx index 56e023c5..4e5fba88 100644 Binary files a/docs/资料/物联网中心/设备接入/力创/命令文档整洁版.xlsx and b/docs/资料/物联网中心/设备接入/力创/命令文档整洁版.xlsx differ diff --git a/docs/资料/物联网中心/设备接入/力创/客户用zigbee系列产品寄存器列表V1.4(20170424).xls b/docs/资料/物联网中心/设备接入/力创/客户用zigbee系列产品寄存器列表V1.4(20170424).xls new file mode 100644 index 00000000..24057954 Binary files /dev/null and b/docs/资料/物联网中心/设备接入/力创/客户用zigbee系列产品寄存器列表V1.4(20170424).xls differ diff --git a/projects/Infrastructure/Extensions/HelperExtensions.cs b/projects/Infrastructure/Extensions/HelperExtensions.cs index a334622e..c6f2ab4b 100644 --- a/projects/Infrastructure/Extensions/HelperExtensions.cs +++ b/projects/Infrastructure/Extensions/HelperExtensions.cs @@ -14,9 +14,9 @@ namespace Infrastructure.Extensions var physicalAddress = NetworkInterface .GetAllNetworkInterfaces() .Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback) - .Select(nic => nic.GetPhysicalAddress()) - .FirstOrDefault(); - return physicalAddress.ToString().ToLower(); + .Select(nic => nic.GetPhysicalAddress().ToString()) + .FirstOrDefault(o => !string.IsNullOrEmpty(o)); + return physicalAddress.ToLower(); } public static List GetLocalIPList(this Helper helper) diff --git a/projects/IoT/IoT.Shared/Views/Device/Details.cshtml b/projects/IoT/IoT.Shared/Views/Device/Details.cshtml index e889384a..b9930840 100644 --- a/projects/IoT/IoT.Shared/Views/Device/Details.cshtml +++ b/projects/IoT/IoT.Shared/Views/Device/Details.cshtml @@ -1,4 +1,4 @@ -@model Device +@model Device @{ Layout = null; HtmlTitle = Model.Name; diff --git a/projects/IoT/IoT.Shared/Views/Home/Node.cshtml b/projects/IoT/IoT.Shared/Views/Home/Node.cshtml index c133ad3a..8c1af0be 100644 --- a/projects/IoT/IoT.Shared/Views/Home/Node.cshtml +++ b/projects/IoT/IoT.Shared/Views/Home/Node.cshtml @@ -1,4 +1,4 @@ -@model Node +@model Node @{ Layout = null; HtmlTitle = Model?.Name; @@ -170,7 +170,7 @@ -
+
开关 @@ -212,9 +212,9 @@
- - - + + +
@@ -261,6 +261,50 @@
+
+
+
+ 插座 +
+
+ + +
+
+
+
+
+
+
{{d.DisplayName}} {{getDeviceDataValue(d,"状态")}}
+
+ + +
+
+
+
+
+
+
+ 插座 +
+
+ + +
+
+
+
+
+
+
{{d.DisplayName}} {{getDeviceDataValue(d,"状态")}}
+
+ + +
+
+
+
diff --git a/projects/IoT/IoT.Shared/wwwroot/js/iot.js b/projects/IoT/IoT.Shared/wwwroot/js/iot.js index 6febb4b3..b64e697f 100644 --- a/projects/IoT/IoT.Shared/wwwroot/js/iot.js +++ b/projects/IoT/IoT.Shared/wwwroot/js/iot.js @@ -2,6 +2,8 @@ var rtmpPlayer; var flvPlayer; var hlsPlayer; var app; +var timer; +var decodedFrames; var vm = new Vue({ el: '#app', data: { @@ -28,7 +30,9 @@ var vm = new Vue({ this.play2(); } $('#callback').on('popup:closed', function (e, popover) { - closePlayer(); + if ($(this).has('video').length) { + closePlayer(); + } }); }, updated: function () { @@ -167,56 +171,58 @@ var vm = new Vue({ var url = '/Command/Sence/?node=' + this.model.Number + '&id=' + id; getJsonExt(url); }, + playFlv: function (url) { + $('#video-container').html(''); + var videoElement = document.getElementById('player'); + try { + if (flvPlayer != null) { + closePlayer(); + } + flvPlayer = flvjs.createPlayer({ + type: 'flv', + url: url, + isLive: true, + cors: true + }, { + enableWorker: true, + enableStashBuffer: false, + stashInitialSize: 1, + fixAudioTimestampGap: false, + //lazyLoad: false + }); + flvPlayer.attachMediaElement(videoElement); + flvPlayer.load(); + timer = setInterval(function () { + console.log('.'); + if (flvPlayer.statisticsInfo.speed == 0) { + console.log('reload1'); + closePlayer(); + vm.playFlv(url); + } + else if (decodedFrames && flvPlayer.statisticsInfo.decodedFrames <= decodedFrames) { + console.log('reload2'); + closePlayer(); + vm.playFlv(url); + } + else if (flvPlayer.buffered.end(0) - flvPlayer.currentTime > 1) { + console.log('reset currentTime'); + flvPlayer.currentTime = flvPlayer.buffered.end(0) - 0.001; + } + decodedFrames = flvPlayer.statisticsInfo.decodedFrames; + }, 10 * 1000); + } catch (e) { + console.log(e); + } + }, play: function (id) { var hasFlash = navigator.plugins['Shockwave Flash']; var device = _.chain(this.model.Devices).filter(function (o) { return o.Id == id; }).first().value(); var key = (hasFlash ? "rtmp" : (flvjs.isSupported() ? 'flv' : 'hls')) + (isNode ? '1' : '2'); var url = _.chain(device.Data).filter(function (o) { return o.Key === key; }).first().value().Value; console.log(url); - if (hasFlash) { - try { - if (rtmpPlayer != null) { - closePlayer(); - } - $('#video-container').html('
'); - app.popup.open('#callback'); - rtmpPlayer = new Clappr.Player({ - source: url, - parentId: "#player", - autoPlay: true, - plugins: { 'playback': [RTMP] }, - rtmpConfig: { - swfPath: '/lib/clappr/clappr-rtmp-plugin/assets/RTMP.swf', - scaling: 'stretch', - playbackType: 'live', - bufferTime: 1, - startLevel: 0 - }, - }); - } catch (e) { - console.log(e); - } - } - else if (flvjs.isSupported()) { - $('#video-container').html(''); + if (flvjs.isSupported()) { app.popup.open('#callback'); - var videoElement = document.getElementById('player'); - try { - if (flvPlayer != null) { - closePlayer(); - } - flvPlayer = flvjs.createPlayer({ - type: 'flv', - url: url, - isLive: true, - cors: true, - enableStashBuffer: true - }); - flvPlayer.attachMediaElement(videoElement); - flvPlayer.load(); - } catch (e) { - console.log(e); - } + this.playFlv(url); } else if (Hls.isSupported()) { $('#video-container').html(''); @@ -248,18 +254,7 @@ var vm = new Vue({ var url = _.chain(device.Data).filter(function (o) { return o.Key === key; }).first().value().Value; if (flvjs.isSupported()) { - $('#video-container').html(''); - var videoElement = document.getElementById('player'); - var player = flvjs.createPlayer({ - type: 'flv', - url: url, - isLive: true, - cors: true, - enableStashBuffer: true - }); - player.attachMediaElement(videoElement); - player.load(); - + this.playFlv(url); } else if (Hls.isSupported()) { $('#video-container').html(''); @@ -282,6 +277,10 @@ var vm = new Vue({ }); function closePlayer() { console.log('close player'); + if (timer) { + clearInterval(timer); + timer = null; + } if (rtmpPlayer != null) { rtmpPlayer.destroy() } diff --git a/projects/IoT/IoT.UI.Shard/IoT.UI.Shard.csproj b/projects/IoT/IoT.UI.Shard/IoT.UI.Shard.csproj index 6828f54e..47dcb1b6 100644 --- a/projects/IoT/IoT.UI.Shard/IoT.UI.Shard.csproj +++ b/projects/IoT/IoT.UI.Shard/IoT.UI.Shard.csproj @@ -1,9 +1,7 @@  - netcoreapp2.2 true - true diff --git a/projects/IoT/IoTNode/appsettings.json b/projects/IoT/IoTNode/appsettings.json index d3a1c293..6d6ea20e 100644 --- a/projects/IoT/IoTNode/appsettings.json +++ b/projects/IoT/IoTNode/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.21", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/IoT/IoTServices/APService/appsettings.json b/projects/IoT/IoTServices/APService/appsettings.json index 39ea51ab..bb4a50c0 100644 --- a/projects/IoT/IoTServices/APService/appsettings.json +++ b/projects/IoT/IoTServices/APService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.20", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/IoT/IoTServices/LiChuangService/Controllers/HomeController.cs b/projects/IoT/IoTServices/LiChuangService/Controllers/HomeController.cs index 33720b93..fdda474c 100644 --- a/projects/IoT/IoTServices/LiChuangService/Controllers/HomeController.cs +++ b/projects/IoT/IoTServices/LiChuangService/Controllers/HomeController.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net.Http; +using System.Threading.Tasks; using Application.Domain.Entities; using Application.Models; using Infrastructure.Data; @@ -29,8 +30,11 @@ namespace LiChuangService.Controllers public IActionResult Index() { - Policy.Timeout(3).Execute(() => this._deviceService.Notify()); - return View(new EditButtonModel { Name = "test" }); + Task.Run(() => + { + this._deviceService.Notify(); + }); + return View(); } #region api diff --git a/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService.cs b/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService.cs index 47257aff..986e7425 100644 --- a/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService.cs +++ b/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService.cs @@ -50,8 +50,8 @@ namespace LiChuangService { try { - //Console.WriteLine("timer ..."); - //Policy.Timeout(3).Execute(() => Notify()); + Console.WriteLine("timer ..."); + Notify(); } catch (Exception ex) { @@ -65,54 +65,69 @@ namespace LiChuangService public void Notify() { Console.WriteLine("notify start ..."); - this.CheckConnection(); - this.SearchAddress(); + try + { + this.CheckConnection(); + this.SearchAddress(); + } + catch (Exception ex) + { + ex.PrintStack(); + } Console.WriteLine("notify end ..."); } public void Switch2AllOn(string id) { - this.Command16(new byte[] { this.GetNumber(id), 0x0f, 0x00, 0x0f, 0x00, 0x03, 0x01, 0x07 }); + this.Command16(new byte[] { this.GetNumber(id), 0x0f, 0x00, 0x00, 0x00, 0x03, 0x01, 0x07 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x02); } public void Switch2AllOff(string id) { - this.Command16(new byte[] { this.GetNumber(id), 0x0f, 0x00, 0x0f, 0x00, 0x03, 0x01, 0x00 }); + this.Command16(new byte[] { this.GetNumber(id), 0x0f, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x02); } public void Switch2L1On(string id) { this.Command16(new byte[] { this.GetNumber(id), 0x05, 0x00, 0x00, 0xff, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x02); } public void Switch2L1Off(string id) { this.Command16(new byte[] { this.GetNumber(id), 0x05, 0x00, 0x00, 0x00, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x02); } public void Switch2L2On(string id) { - this.Command16(new byte[] { this.GetNumber(id), 0x01, 0x05, 0x00, 0x01, 0xff, 0x00 }); + this.Command16(new byte[] { this.GetNumber(id), 0x05, 0x00, 0x01, 0xff, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x02); } public void Switch2L2Off(string id) { - this.Command16(new byte[] { this.GetNumber(id), 0x01, 0x05, 0x00, 0x01, 0x00, 0x00 }); + this.Command16(new byte[] { this.GetNumber(id), 0x05, 0x00, 0x01, 0x00, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x02); } public void SocketOn(string id) { this.Command16(new byte[] { this.GetNumber(id), 0x05, 0x00, 0x00, 0xff, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x10); } public void SocketOff(string id) { this.Command16(new byte[] { this.GetNumber(id), 0x05, 0x00, 0x00, 0x00, 0x00 }); + this.SearchSwitchStatus(this.GetNumber(id), 0x10); } private byte GetNumber(string id) { - return Convert.ToByte(id.Replace(this._addressValue, "")); + return Convert.ToByte(id.Split("-")[1]); } private void CheckConnection() @@ -179,7 +194,7 @@ namespace LiChuangService if (command == 0x0c)//16位地址 { this._address = data.ToList().Skip(5).Take(8).ToArray(); - this._addressValue = BitConverter.ToString(this._address).Replace("-", " "); + this._addressValue = BitConverter.ToString(this._address).Replace("-", ""); this.SearchNodeStatus(); } else if (command == 0x15)//节点状态 @@ -201,7 +216,7 @@ namespace LiChuangService else if (command == 0x17)//读取 { var nodeNumber = data[14]; - if (data.Length > 18 && data[18] == 0xff) + if (data.Length == 22 && data[18] == 0xff)//读类型命令返回值 { var nodeType = data[17]; this._types[nodeNumber] = nodeType; @@ -225,7 +240,7 @@ namespace LiChuangService Console.WriteLine($"unknown type:{nodeType}"); } } - else + if (data[15] == 0x01) { var nodeType = this._types[nodeNumber]; var statusData = data[17]; @@ -235,20 +250,20 @@ namespace LiChuangService Console.WriteLine($"~~~node {nodeNumber},switch 2 status:{statusData}"); var switchStatus = statusData.ToBitString(); - model = CreateModel("二路灯开关", this._addressValue + nodeNumber, "switch2", "switch"); - model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status1", Name = "L1状态", Value = switchStatus[6] == '1' ? "开" : "关", DisplayOrder = 1 }); - model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status2", Name = "L2状态", Value = switchStatus[7] == '1' ? "开" : "关", DisplayOrder = 2 }); + model = CreateModel("二路灯开关", this._addressValue + "-" + nodeNumber, "switch2", "switch"); + model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status1", Name = "L1状态", Value = switchStatus[7] == '1' ? "开" : "关", DisplayOrder = 1 }); + model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status2", Name = "L2状态", Value = switchStatus[6] == '1' ? "开" : "关", DisplayOrder = 2 }); } else if (nodeType == 0x03) { Console.WriteLine($"~~~node {nodeNumber},socket 1 status:{statusData}"); - model = CreateModel("一路插座", this._addressValue + nodeNumber, "socket1", "socket"); + model = CreateModel("一路插座", this._addressValue + "-" + nodeNumber, "socket1", "socket"); model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status", Name = "状态", Value = statusData == 0x01 ? "开" : "关", DisplayOrder = 1 }); } else if (nodeType == 0x04) { Console.WriteLine($"~~~node {nodeNumber},socket 2 status:{statusData}"); - model = CreateModel("二路插座", this._addressValue + nodeNumber, "socket2", "switch"); + model = CreateModel("二路插座", this._addressValue + "-" + nodeNumber, "socket2", "switch"); model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status", Name = "状态", Value = statusData == 0x01 ? "开" : "关", DisplayOrder = 1 }); } else diff --git a/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService2.cs b/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService2.cs deleted file mode 100644 index 628c55e5..00000000 --- a/projects/IoT/IoTServices/LiChuangService/Infrastructure/DeviceService2.cs +++ /dev/null @@ -1,294 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Net.Sockets; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Application.Domain.Entities; -using Infrastructure.Data; -using Infrastructure.Extensions; -using Infrastructure.Models; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Polly; -using RJCP.IO.Ports; - -namespace LiChuangService -{ - public class DeviceService2 : IDisposable - { - private readonly IHostingEnvironment _env; - private readonly IConfiguration _configuration; - private readonly IHttpClientFactory _httpClientFactory; - private readonly IServiceProvider _applicationServices; - private CancellationTokenSource _tokenSource; - private static readonly object lockObject = new Object(); - - public DeviceService2(IHostingEnvironment env, IServiceProvider applicationServices, IConfiguration configuration, IHttpClientFactory httpClientFactory) - { - this._env = env; - this._applicationServices = applicationServices; - this._configuration = configuration; - this._httpClientFactory = httpClientFactory; - this._tokenSource = new CancellationTokenSource(); - } - - public void Start() - { - Task.Run(async () => - { - while (!_tokenSource.IsCancellationRequested) - { - try - { - Console.WriteLine("timer ..."); - Policy.Timeout(3).Execute(() => Notify()); - } - catch (Exception ex) - { - ex.PrintStack(); - } - await Task.Delay(this._configuration.GetValue("timer.seconds") * 1000); - } - }); - } - - public void Exec(string code) - { - using (var scope = _applicationServices.CreateScope()) - { - var repo = scope.ServiceProvider.GetService>(); - var button = repo.ReadOnlyTable().FirstOrDefault(o => o.Name == code); - if (button != null) - { - this.Exec(button); - } - } - } - - public void Exec(Button button) - { - using (var src = new SerialPortStream(button.SerialPort, button.Baud, button.Data, (RJCP.IO.Ports.Parity)button.Partity, (RJCP.IO.Ports.StopBits)button.StopBits)) - { - src.Open(); - var data = button.Message.HexToBytes(); - src.Write(data, 0, data.Length); - src.Flush(); - src.Close(); - } - } - - public void Notify() - { - Console.WriteLine("notify start ..."); - lock (lockObject) - { - try - { - using (var client = new TcpClient()) - { - var tcpIp = this._configuration["tcp.ip"]; - var tcpPort = this._configuration.GetValue("tcp.port"); - client.Connect(tcpIp, tcpPort); - using (var stream = client.GetStream()) - { - var addressData = this.GetAddress(stream); - var address = BitConverter.ToString(addressData).Replace("-", ""); - Console.WriteLine($"address:{address}"); - var nodesStatus = GetNodeStatus(stream, addressData); - Console.WriteLine($"nodes:{BitConverter.ToString(nodesStatus)}"); - - for (int i = 0; i < nodesStatus.Length; i++) - { - if (nodesStatus[i] == 0x01) - { - Console.WriteLine($"node online:{i + 1}"); - NotifyModel model = null; - var type = GetNodeType(stream, addressData, i + 1); - if (type == 2) - { - var switchStatusData = GetSwitchStatus(stream, addressData, i + 1); - var switchStatus = switchStatusData.ToBitString(); - model = CreateModel("二路灯开关", address + i, "switch2", "switch"); - model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status", Name = "L1状态", Value = switchStatus[7] == '1' ? "开" : "关", DisplayOrder = 1 }); - model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status", Name = "L2状态", Value = switchStatus[6] == '1' ? "开" : "关", DisplayOrder = 2 }); - } - else if (type == 3) - { - var switchStatusData = GetSwitchStatus(stream, addressData, i + 1); - model = CreateModel("一路插座", address + i, "socket1", "socket"); - model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status", Name = "状态", Value = switchStatusData == 0x01 ? "开" : "关", DisplayOrder = 1 }); - } - else if (type == 4) - { - var switchStatusData = GetSwitchStatus(stream, addressData, i + 1); - model = CreateModel("二路插座", address + i, "socket2", "switch"); - model.Data.Add(new DataModel { Type = DataValueType.Text.ToString(), Key = "status", Name = "状态", Value = switchStatusData == 0x01 ? "开" : "关", DisplayOrder = 1 }); - } - var url = $"http://{this._configuration["node.url"]}/Notify"; - Console.WriteLine(url); - var hc = this._httpClientFactory.CreateClient(); - var task = this._httpClientFactory.CreateClient().PostAsync(url, new FormUrlEncodedContent(model.ToList())); - task.Wait(); - using (var response = task.Result) - { - using (var content = response.Content) - { - var value = content.ReadAsStringAsync().Result; - Console.WriteLine($"end:{url}:{value}"); - } - } - } - else if (nodesStatus[i] == 0x02) - { - Console.WriteLine($"node offline:{i + 1}"); - } - } - } - } - } - catch (Exception ex) - { - ex.PrintStack(); - } - } - Console.WriteLine("notify end ..."); - } - - public void SwitchAllOn(string id) - { - //throw new NotImplementedException(); - } - - public void SwitchAllOff(string id) - { - //throw new NotImplementedException(); - } - - private NotifyModel CreateModel(string name, string number, string path, string icon) - { - var host = string.IsNullOrEmpty(this._configuration["server.ip"]) ? Helper.Instance.GetLocalIP().ToString() : this._configuration["server.ip"]; - var port = Convert.ToInt32(Regex.Match(this._configuration["server.urls"], @"(?<=:)\d+").Value); - - return new NotifyModel - { - CategoryName = "电器", - CategoryNumber = "20", - Name = name, - Number = number, - Icon = icon, - IsOnline = true, - BaseUrl = $"http://{host}:{port}/{path}", - ApiPath = "/api" - }; - } - - private byte[] Command(byte[] data) - { - var command = new List { 0xfe, 0xa5, 0x00 }; - command.Add((byte)data.Length); - command.AddRange(data); - command.Add((byte)command.Skip(2).Select(o => Convert.ToInt32(o)).Sum()); - return command.ToArray(); - } - - private byte[] Data(byte[] data, bool crc16 = false) - { - var command = new List { 0xfe, 0xa5, 0x01 }; - command.Add((byte)data.Length); - command.AddRange(data); - if (crc16) - { - var crc = Crc16.ComputeChecksum(data); - command.Add(crc[1]); - command.Add(crc[0]); - } - else - { - command.Add((byte)command.Skip(2).Select(o => Convert.ToInt32(o)).Sum()); - } - return command.ToArray(); - } - - private byte[] GetAddress(NetworkStream stream) - { - var list = new List() { 0x0c }; - this.Write(stream, Command(list.ToArray())); - var buffer = new byte[256]; - var length = stream.Read(buffer); - Console.WriteLine($">address:{BitConverter.ToString(buffer, 0, length)}"); - var address = buffer.Skip(5).Take(8).ToArray(); - return address; - } - - private byte[] GetNodeStatus(NetworkStream stream, byte[] address) - { - var list = new List() { 0x15 }; - list.AddRange(address); - list.Add(0x00); - this.Write(stream, Command(list.ToArray())); - var buffer = new byte[256]; - var length = stream.Read(buffer); - Console.WriteLine($">node status:{BitConverter.ToString(buffer, 0, length)}"); - var status = buffer.Skip(14).Take(100).ToArray(); - return status; - } - - private byte GetNodeType(NetworkStream stream, byte[] address, int i) - { - var list = new List() { 0x16 }; - list.AddRange(address); - list.Add(0x00); - var modbusdata = new List { - (byte)i,0x03,0x00,0x0f,0x00,0x01 - }.ToArray(); - var modbus = new List(); - modbus.AddRange(modbusdata); - var crc = Crc16.ComputeChecksum(modbusdata); - modbus.Add(crc[1]); - modbus.Add(crc[0]); - list.AddRange(modbus); - this.Write(stream, Data(list.ToArray())); - var buffer = new byte[256]; - var length = stream.Read(buffer); - Console.WriteLine($">type:{BitConverter.ToString(buffer, 0, length)}"); - return buffer.Skip(14 + 3).Take(1).ToArray()[0]; - } - - private byte GetSwitchStatus(NetworkStream stream, byte[] address, int i) - { - var list = new List() { 0x16 }; - list.AddRange(address); - list.Add(0x00); - var modbusdata = new List { - (byte)i, 0x01,0x00,0x00,0x00,0x04 - }.ToArray(); - var modbus = new List(); - modbus.AddRange(modbusdata); - var crc = Crc16.ComputeChecksum(modbusdata); - modbus.Add(crc[1]); - modbus.Add(crc[0]); - list.AddRange(modbus); - this.Write(stream, Data(list.ToArray())); - var buffer = new byte[256]; - var length = stream.Read(buffer); - Console.WriteLine($">device status:{BitConverter.ToString(buffer, 0, length)}"); - return buffer.Skip(17).Take(1).ToArray()[0]; - } - - private void Write(NetworkStream stream, byte[] data) - { - Thread.Sleep(200); - stream.Write(data); - } - - public void Dispose() - { - Console.WriteLine("LiChuangService dispose..."); - this._tokenSource.Cancel(); - } - } -} \ No newline at end of file diff --git a/projects/IoT/IoTServices/LiChuangService/Program.cs b/projects/IoT/IoTServices/LiChuangService/Program.cs index 782e5773..52d659fa 100644 --- a/projects/IoT/IoTServices/LiChuangService/Program.cs +++ b/projects/IoT/IoTServices/LiChuangService/Program.cs @@ -22,10 +22,10 @@ namespace LiChuangService new EFConfigurationValue { Id = "email:port", Value= "25"}, new EFConfigurationValue { Id = "email:user", Value= "admin@nbaxp.com"}, new EFConfigurationValue { Id = "email:password", Value= "aA123456"}, - new EFConfigurationValue { Id = "server.ip", Value= "192.168.3.84" }, + new EFConfigurationValue { Id = "server.ip", Value= "" }, new EFConfigurationValue { Id = "server.urls", Value= "http://*:8008" }, new EFConfigurationValue { Id = "node.url", Value= "127.0.0.1:8002"}, - new EFConfigurationValue { Id = "timer.seconds", Value="5"}, + new EFConfigurationValue { Id = "timer.seconds", Value="600"}, new EFConfigurationValue { Id = "tcp.ip", Value="192.168.3.233"}, new EFConfigurationValue { Id = "tcp.port", Value="4001"}, // diff --git a/projects/IoT/IoTServices/LiChuangService/Views/Home/Index.cshtml b/projects/IoT/IoTServices/LiChuangService/Views/Home/Index.cshtml index 6eb4cc85..e69de29b 100644 --- a/projects/IoT/IoTServices/LiChuangService/Views/Home/Index.cshtml +++ b/projects/IoT/IoTServices/LiChuangService/Views/Home/Index.cshtml @@ -1,3 +0,0 @@ -@model SPService.Applicaiton.Models.EditButtonModel -

@ViewBag.Result

-@Html.EditorForModel() \ No newline at end of file diff --git a/projects/IoT/IoTServices/LiChuangService/appsettings.json b/projects/IoT/IoTServices/LiChuangService/appsettings.json index 58b53bb6..d7dce16e 100644 --- a/projects/IoT/IoTServices/LiChuangService/appsettings.json +++ b/projects/IoT/IoTServices/LiChuangService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.20", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Information" @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "database.mysql.connection": "Server=127.0.0.1;Port=3306;Database=iotnode;Uid=root;Pwd=root;", + "database.mysql.connection": "Server=127.0.0.1;Port=3306;Database=data;Uid=root;Pwd=root;", "database.sqlite.connection": "Data Source=data.db" }, "AppSettings": { diff --git a/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties b/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties index 9907d5ba..bc6d7077 100644 --- a/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties +++ b/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties @@ -1,4 +1,4 @@ -version=1.0.0-beta.21 +version=1.0.0-beta.100 server.host=127.0.0.1 server.port=8003 spring.thymeleaf.cache=false diff --git a/projects/IoT/IoTServices/ONVIFService/Infrastructure/OnvifService.cs b/projects/IoT/IoTServices/ONVIFService/Infrastructure/OnvifService.cs index 4232e8e1..5b3e1876 100644 --- a/projects/IoT/IoTServices/ONVIFService/Infrastructure/OnvifService.cs +++ b/projects/IoT/IoTServices/ONVIFService/Infrastructure/OnvifService.cs @@ -24,13 +24,6 @@ namespace ONVIFService { private readonly IHostingEnvironment _env; private readonly IConfiguration _configuration; - private readonly string _local_rtmp; - private readonly string _local_flv; - private readonly string _local_hls; - private readonly string _remote_rtmp; - private readonly string _remote_flv; - private readonly string _remote_hls; - private readonly IHttpClientFactory _httpClientFactory; private readonly IServiceProvider _applicationServices; private CancellationTokenSource _tokenSource; @@ -42,12 +35,6 @@ namespace ONVIFService this._env = env; this._applicationServices = applicationServices; this._configuration = configuration; - this._local_rtmp = this._configuration["stream.local.rtmp"]; - this._local_flv = this._configuration["stream.local.flv"]; - this._local_hls = this._configuration["stream.local.hls"]; - this._remote_rtmp = this._configuration["stream.remote.rtmp"]; - this._remote_flv = this._configuration["stream.remote.flv"]; - this._remote_hls = this._configuration["stream.remote.hls"]; this._httpClientFactory = httpClientFactory; this._tokenSource = new CancellationTokenSource(); this._onvifDeviceManagement = new OnvifDeviceManagement(httpClientFactory); @@ -95,12 +82,12 @@ namespace ONVIFService { Name = "摄像头", Number = ipCamera.Id, - Rtmp1 = $"rtmp://{_local_rtmp}/live/{ipCamera.Id}", - Flv1 = $"http://{_local_flv}/live/{ipCamera.Id}.flv", - Hls1 = $"http://{_local_hls}/live/{ipCamera.Id}.m3u8", - Rtmp2 = $"rtmp://{_remote_rtmp}/live/{ipCamera.Id}", - Flv2 = $"http://{_remote_flv}/live/{ipCamera.Id}.flv", - Hls2 = $"http://{_remote_hls}/live/{ipCamera.Id}.m3u8", + Rtmp1 = $"rtmp://{this._configuration["stream.local.rtmp"]}/live/{ipCamera.Id}", + Flv1 = $"http://{this._configuration["stream.local.flv"]}/live/{ipCamera.Id}.flv", + Hls1 = $"http://{this._configuration["stream.local.hls"]}/live/{ipCamera.Id}.m3u8", + Rtmp2 = $"rtmp://{this._configuration["stream.remote.rtmp"]}/live/{ipCamera.Id}", + Flv2 = $"http://{this._configuration["stream.remote.flv"]}/live/{ipCamera.Id}.flv", + Hls2 = $"http://{this._configuration["stream.remote.hls"]}/live/{ipCamera.Id}.m3u8", Arguments = this._configuration["ffmpeg.args"], File = this._configuration["ffmpeg.file"] }; diff --git a/projects/IoT/IoTServices/ONVIFService/Program.cs b/projects/IoT/IoTServices/ONVIFService/Program.cs index d69eae84..d745c983 100644 --- a/projects/IoT/IoTServices/ONVIFService/Program.cs +++ b/projects/IoT/IoTServices/ONVIFService/Program.cs @@ -24,7 +24,7 @@ namespace ONVIFService new EFConfigurationValue { Id = "email:password", Value= "aA123456"}, new EFConfigurationValue { Id = "server.urls", Value= "http://*:8004" }, new EFConfigurationValue { Id = "node.url", Value= "127.0.0.1:8002"}, - new EFConfigurationValue { Id = "timer.seconds", Value="300"}, + new EFConfigurationValue { Id = "timer.seconds", Value="600"}, new EFConfigurationValue { Id = "onvif.timer", Value="1"}, new EFConfigurationValue { Id = "onvif.speed", Value="0.2"}, new EFConfigurationValue { Id = "camera.usr", Value="admin"}, diff --git a/projects/IoT/IoTServices/ONVIFService/Views/Home/Test.cshtml b/projects/IoT/IoTServices/ONVIFService/Views/Home/Test.cshtml index b8b04cc4..b0d35252 100644 --- a/projects/IoT/IoTServices/ONVIFService/Views/Home/Test.cshtml +++ b/projects/IoT/IoTServices/ONVIFService/Views/Home/Test.cshtml @@ -1,8 +1,4 @@ @model List -@{ - int i = 0; - var player = "ucload"; -} @if (Model.Count > 0) {
diff --git a/projects/IoT/IoTServices/ONVIFService/appsettings.json b/projects/IoT/IoTServices/ONVIFService/appsettings.json index 2af830af..4da849fa 100644 --- a/projects/IoT/IoTServices/ONVIFService/appsettings.json +++ b/projects/IoT/IoTServices/ONVIFService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.22", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Information" diff --git a/projects/IoT/IoTServices/SerialPortService/appsettings.json b/projects/IoT/IoTServices/SerialPortService/appsettings.json index 58b53bb6..4da849fa 100644 --- a/projects/IoT/IoTServices/SerialPortService/appsettings.json +++ b/projects/IoT/IoTServices/SerialPortService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.20", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Information" diff --git a/projects/IoT/IoTServices/WinService/appsettings.json b/projects/IoT/IoTServices/WinService/appsettings.json index 39ea51ab..bb4a50c0 100644 --- a/projects/IoT/IoTServices/WinService/appsettings.json +++ b/projects/IoT/IoTServices/WinService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.20", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/IoTCenter/appsettings.json b/projects/IoTCenter/appsettings.json index 809014e7..2e69ecf4 100644 --- a/projects/IoTCenter/appsettings.json +++ b/projects/IoTCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.21", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/StudyCenter/appsettings.json b/projects/StudyCenter/appsettings.json index d58dd8da..872b852e 100644 --- a/projects/StudyCenter/appsettings.json +++ b/projects/StudyCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.1", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/UserCenter/appsettings.json b/projects/UserCenter/appsettings.json index 589260ee..abe8420b 100644 --- a/projects/UserCenter/appsettings.json +++ b/projects/UserCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.20", + "version": "1.0.0-beta.100", "Logging": { "LogLevel": { "Default": "Warning" @@ -7,11 +7,29 @@ }, "UseMiniProfiler": false, "ConnectionStrings": { - "database.mysql.connection": "Server=127.0.0.1;Port=3306;Database=data;Uid=root;Pwd=root;", - "database.sqlite.connection": "Data Source=data.db" + "database.mysql.connection": "Server=127.0.0.1;Port=3306;Database=usercenter;Uid=root;Pwd=root;", + "database.sqlite.connection": "Data Source=usercenter.db" }, "AppSettings": { "database": "sqlite", "UseCookieSessionStore": false - } + }, + //Ocelot config + "GlobalConfiguration": { + "BaseUrl": "http://192.168.3.124:8000/" + }, + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "192.168.3.124", + "Port": 8001 + } + ], + "UpstreamPathTemplate": "/api/{version}/iot/{everything}", + "UpstreamHttpMethod": [ "Get" ] + } + ] } \ No newline at end of file diff --git a/publish/build.cmd b/publish/build.cmd index c6efc945..9fa55922 100644 --- a/publish/build.cmd +++ b/publish/build.cmd @@ -9,7 +9,7 @@ echo d|xcopy "./src/linux-arm64/publish" "./dist/linux-arm64/publish" /s /e /y / dotnet publish ../projects/UserCenter/UserCenter.csproj -c Release -r linux-x64 -o ../../publish/dist/linux-x64/publish/apps/UserCenter dotnet publish ../projects/IoTCenter/IoTCenter.csproj -c Release -r linux-x64 -o ../../publish/dist/linux-x64/publish/apps/IoTCenter -dotnet publish ../projects/UserCenter/UserCenter.csproj -c Release -r linux-arm64 -o .../../publish/dist/linux-arm64/publish/apps/UserCenter +dotnet publish ../projects/UserCenter/UserCenter.csproj -c Release -r linux-arm64 -o ../../publish/dist/linux-arm64/publish/apps/UserCenter dotnet publish ../projects/IoTCenter/IoTCenter.csproj -c Release -r linux-arm64 -o ../../publish/dist/linux-arm64/publish/apps/IoTCenter dotnet publish ../projects/IoT/IoTNode/IoTNode.csproj -c Release -r linux-arm64 -o ../../../publish/dist/linux-arm64/publish/apps/IoTNode dotnet publish ../projects/IoT/IoTServices/WinService/WinService.csproj -c Release -r win-x86 -o "../../../../publish/dist/win-x86/Program Files (x86)/WinService" @@ -17,6 +17,7 @@ dotnet publish ../projects/IoT/IoTServices/APService/APService.csproj -c Release dotnet publish ../projects/IoT/IoTServices/ONVIFService/ONVIFService.csproj -c Release -r linux-x64 -o ../../../../publish/dist/linux-x64/publish/apps/ONVIFService dotnet publish ../projects/IoT/IoTServices/ONVIFService/ONVIFService.csproj -c Release -r linux-arm64 -o ../../../../publish/dist/linux-arm64/publish/apps/ONVIFService dotnet publish ../projects/IoT/IoTServices/SerialPortService/SerialPortService.csproj -c Release -r linux-arm64 -o ../../../../publish/dist/linux-arm64/publish/apps/SerialPortService +dotnet publish ../projects/IoT/IoTServices/LiChuangService/LiChuangService.csproj -c Release -r linux-arm64 -o ../../../../publish/dist/linux-arm64/publish/apps/LiChuangService gradle build -p ../projects/IoT/IoTServices/NJWLService set endtime=%time% diff --git a/publish/src/linux-arm64/publish/install.sh b/publish/src/linux-arm64/publish/install.sh index 51f6bbc8..77ae1a33 100644 --- a/publish/src/linux-arm64/publish/install.sh +++ b/publish/src/linux-arm64/publish/install.sh @@ -11,5 +11,6 @@ chmod 777 /root/publish/apps/APService/APService chmod 777 /root/publish/apps/ONVIFService/ONVIFService chmod 777 /root/publish/apps/ONVIFService/wwwroot/ffmpeg-linux-arm64 chmod 777 /root/publish/apps/SerialPortService/SerialPortService +chmod 777 /root/publish/apps/LiChuangService/LiChuangService chmod 777 /root/publish/apps/srs/objs/srs service supervisor restart \ No newline at end of file diff --git a/publish/src/linux-arm64/publish/supervisor/lichuang.conf b/publish/src/linux-arm64/publish/supervisor/lichuang.conf new file mode 100644 index 00000000..7a13a52a --- /dev/null +++ b/publish/src/linux-arm64/publish/supervisor/lichuang.conf @@ -0,0 +1,8 @@ +[program:lichangservice] +command=/root/publish/apps/LiChuangService/LiChuangService +directory=/root/publish/apps/LiChuangService/ +autostart=true +autorestart=true +user=root +stdout_logfile=/root/publish/logs/lichangservice.log +stderr_logfile=/root/publish/logs/lichangservice.err \ No newline at end of file