1.调整和修复力创设备接入服务项目

2.消除编译警告,更新版本号到beta.100
TangShanKaiPing
wanggang 6 years ago
parent 305419ba7f
commit ce2600d7e6

@ -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<IPAddress> GetLocalIPList(this Helper helper)

@ -1,4 +1,4 @@
@model Device
@model Device
@{
Layout = null;
HtmlTitle = Model.Name;

@ -1,4 +1,4 @@
@model Node
@model Node
@{
Layout = null;
HtmlTitle = Model?.Name;
@ -170,7 +170,7 @@
</div>
</div>
</div>
<div class="card" v-if="getCount('一路照明开关')+getCount('三路照明开关')+getCount('计量开关')+getCount('二路灯开关')>0">
<div class="card" v-if="getCount('一路照明开关')+getCount('三路照明开关')+getCount('计量开关')+getCount('二路灯开关')+getCount('一路插座')+getCount('二路插座')>0">
<div class="card-header">
<div class="left">
开关
@ -212,9 +212,9 @@
<a href="javascript: ;" v-on:click="send(d.Id,'22off')"><img class="btn" src="~/iot/off.png" /></a>
</div>
<div v-if="isAdmin">
<a v-if="getDeviceDataValue(d,'状态4')==='关'" v-on:click="send(d.Id,'23l1on')"><img class="btn" src="~/iot/off.png" /></a>
<a v-else v-on:click="send(d.Id,'24l2off')"><img class="btn" src="~/iot/on.png" /></a>
<a v-if="getDeviceDataValue(d,'状态5')==='关'" v-on:click="send(d.Id,'25l2on')"><img class="btn" src="~/iot/off.png" /></a>
<a v-if="getDeviceDataValue(d,'L1状态')==='关'" v-on:click="send(d.Id,'23l1on')"><img class="btn" src="~/iot/off.png" /></a>
<a v-else v-on:click="send(d.Id,'24l1off')"><img class="btn" src="~/iot/on.png" /></a>
<a v-if="getDeviceDataValue(d,'L2状态')==='关'" v-on:click="send(d.Id,'25l2on')"><img class="btn" src="~/iot/off.png" /></a>
<a v-else v-on:click="send(d.Id,'26l2off')"><img class="btn" src="~/iot/on.png" /></a>
</div>
</div>
@ -261,6 +261,50 @@
</div>
</div>
</div>
<div class="card" v-if="getCount('一路插座')">
<div class="card-header">
<div class="left">
插座
</div>
<div class="right" v-if="isAdmin">
<a href="javascript: ;" v-on:click="sendAll('一路插座','21on')"><img class="btn" src="~/iot/on.png" /></a>
<a href="javascript: ;" v-on:click="sendAll('一路插座','22off')"><img class="btn" src="~/iot/off.png" /></a>
</div>
</div>
<div class="row">
<div class="col" v-for="d in getDevices('一路插座')">
<div><img class="icon" :src="'/iot/'+d.Icon+'.png'" /></div>
<div><i :class="d.IsOnline?'fa fa-toggle-on':'fa fa-toggle-off'" :style="d.IsOnline?'color:green;':'color:red;'"></i></div>
<div>{{d.DisplayName}} {{getDeviceDataValue(d,"状态")}}</div>
<div v-if="isAdmin">
<a href="javascript: ;" v-if="getDeviceDataValue(d,'状态')==='关'" v-on:click="send(d.Id,'21on')"><img class="btn" src="~/iot/off.png" /></a>
<a href="javascript: ;" v-else v-on:click="send(d.Id,'22off')"><img class="btn" src="~/iot/on.png" /></a>
</div>
</div>
</div>
</div>
<div class="card" v-if="getCount('二路插座')">
<div class="card-header">
<div class="left">
插座
</div>
<div class="right" v-if="isAdmin">
<a href="javascript: ;" v-on:click="sendAll('二路插座','21on')"><img class="btn" src="~/iot/on.png" /></a>
<a href="javascript: ;" v-on:click="sendAll('二路插座','22off')"><img class="btn" src="~/iot/off.png" /></a>
</div>
</div>
<div class="row">
<div class="col" v-for="d in getDevices('二路插座')">
<div><img class="icon" :src="'/iot/'+d.Icon+'.png'" /></div>
<div><i :class="d.IsOnline?'fa fa-toggle-on':'fa fa-toggle-off'" :style="d.IsOnline?'color:green;':'color:red;'"></i></div>
<div>{{d.DisplayName}} {{getDeviceDataValue(d,"状态")}}</div>
<div v-if="isAdmin">
<a href="javascript: ;" v-if="getDeviceDataValue(d,'状态')==='关'" v-on:click="send(d.Id,'21on')"><img class="btn" src="~/iot/off.png" /></a>
<a href="javascript: ;" v-else v-on:click="send(d.Id,'22off')"><img class="btn" src="~/iot/on.png" /></a>
</div>
</div>
</div>
</div>
<div class="card" v-if="getCount('密码门锁')">
<div class="card-header">
<div class="left">

@ -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('<video id="player" class="video" muted controls autoplay></video>');
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('<div id="player" class="rtmp video"></div>');
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('<video id="player" class="video" muted controls autoplay></video>');
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('<video id="player" class="video" muted controls autoplay></video>');
@ -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('<video id="player" class="video" muted controls autoplay></video>');
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('<video id="player" class="video" muted controls autoplay></video>');
@ -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()
}

@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.21",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.20",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -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

@ -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

@ -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<int>("timer.seconds") * 1000);
}
});
}
public void Exec(string code)
{
using (var scope = _applicationServices.CreateScope())
{
var repo = scope.ServiceProvider.GetService<IRepository<Button>>();
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<int>("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<byte> { 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<byte> { 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<byte>() { 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<byte>() { 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<byte>() { 0x16 };
list.AddRange(address);
list.Add(0x00);
var modbusdata = new List<byte> {
(byte)i,0x03,0x00,0x0f,0x00,0x01
}.ToArray();
var modbus = new List<byte>();
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<byte>() { 0x16 };
list.AddRange(address);
list.Add(0x00);
var modbusdata = new List<byte> {
(byte)i, 0x01,0x00,0x00,0x00,0x04
}.ToArray();
var modbus = new List<byte>();
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();
}
}
}

@ -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"},
//

@ -1,3 +0,0 @@
@model SPService.Applicaiton.Models.EditButtonModel
<p>@ViewBag.Result</p>
@Html.EditorForModel()

@ -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": {

@ -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

@ -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"]
};

@ -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"},

@ -1,8 +1,4 @@
@model List<Camera>
@{
int i = 0;
var player = "ucload";
}
@if (Model.Count > 0)
{
<div class="row">

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.22",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Information"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.20",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Information"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.20",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.21",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -1,5 +1,5 @@
{
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.100",
"Logging": {
"LogLevel": {
"Default": "Warning"

@ -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" ]
}
]
}

@ -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%

@ -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

@ -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
Loading…
Cancel
Save