Browse Source

2023年6月18日15:30:49

master
fajiao 1 year ago
parent
commit
4e35f91c67
  1. 2
      ECMonitor/ECMonitor.csproj
  2. 29
      ECMonitor/Manager/WebSocketManager.cs
  3. 27
      ECMonitor/Manager/ZMQManager.cs
  4. 30
      ECMonitor/appsettings.json

2
ECMonitor/ECMonitor.csproj

@ -152,7 +152,7 @@
</Target>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="Copy $(ProjectDir)appsettings.json $(OutDir)appsettings.json" />

29
ECMonitor/Manager/WebSocketManager.cs

@ -1,36 +1,28 @@

using EC.Utils;
using EC.Utils.ZMQ;
using Fleck;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EC.Utils;
using Fleck;
namespace ECMonitor.Manager
{
public class WebSocketManager
{
WebSocketServer _webSocketServer = null;
List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>();
private WebSocketServer _webSocketServer = null;
private List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>();
public event EventHandler<PubSubModel> OnDataReceived; //定义一个委托类型的事件
public WebSocketManager()
{
FleckLog.Level = LogLevel.Debug;
_webSocketServer = new WebSocketServer("ws://0.0.0.0:" + ConfigHelper.WebSocketSvrPort());
}
public void Start()
{
_webSocketServer.Start(socket =>
{
socket.OnOpen = () =>
@ -50,13 +42,14 @@ namespace ECMonitor.Manager
WebSocketDataReceived(socket, message);
};
});
}
public void Stop()
{
allSockets.ToList().ForEach(s => s.Close());
_webSocketServer.Dispose();
}
private void WebSocketDataReceived(object sender, string message)
{
try
@ -70,12 +63,10 @@ namespace ECMonitor.Manager
}
}
}
catch(Exception ex) {
catch (Exception ex)
{
LogFactory.GetLogger().Error(ex);
}
}
}
}

27
ECMonitor/Manager/ZMQManager.cs

@ -1,14 +1,8 @@
using EC.Utils.ZMQ;
using EC.UsingEventAggregator;
using EC.Utils.Config;
using Prism.Events;
using EC.UsingEventAggregator;
using EC.Utils;
using EC.Utils.ZMQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EC.Utils;
namespace ECMonitor.Code
{
@ -17,8 +11,7 @@ namespace ECMonitor.Code
/// <summary>
/// 通用zmq
/// </summary>
static ZMQHelper _zmqHelper;
private static ZMQHelper _zmqHelper;
public event EventHandler<PubSubModel> OnDataReceived; //定义一个委托类型的事件
@ -33,14 +26,11 @@ namespace ECMonitor.Code
_zmqHelper = new ZMQHelper(pubserver, subserver, topics);
_zmqHelper.OnSubData += SubDataReceived;
_zmqHelper.Start();
}catch(Exception ex)
}
catch (Exception ex)
{
FLogger.Error(ex);
}
}
internal static List<string> SUBTopicList()
@ -52,7 +42,6 @@ namespace ECMonitor.Code
topicList.Add(ZMQTopic.MainFrom_Show_Video);
topicList.Add(ZMQTopic.AI_Detect_Warning_Data);
return topicList;
}
@ -61,6 +50,7 @@ namespace ECMonitor.Code
{
_zmqHelper?.Stop();
}
private void SubDataReceived(object sender, PubSubModel msgModel)
{
try
@ -71,12 +61,11 @@ namespace ECMonitor.Code
{
LogFactory.GetLogger().Error(ex);
}
}
public void Send(string topic, string msg)
{
_zmqHelper.Send(topic, msg);
}
}
}

30
ECMonitor/appsettings.json

@ -1,29 +1,29 @@
{
"EC_App": {
//================== ====================================== -->
//
//================== ϵͳҪ ====================================== -->
//ͻ˱ Ψһݱʶ
"AppId": "Video001",
//
//
"SoftName": "YDFK",
//
"SoftFullName": "要地防控系统-视频监控",
//
//ȫ
"SoftFullName": "Ҫ�ط���ϵͳ-��Ƶ���",
//
"SoftVersion": "V1.0.0",
//
"AutoWarningClose": 1,//
"VideoAIDetection": 0, //AI
//ԶرԤ
"AutoWarningClose": 1,//ԤԶر
"VideoAIDetection": 0, //ƵAI
"WebSocketSvrPort": 5003,
"APIServer": "http://192.168.1.200:8080/military/videoRecorder/qryCameraList",
"MainBarButtonSelectedIndex": 1, // 01,14, 29
"MainBarButtonSelectedIndex": 1, // ѡʼͼ 01,14, 29
"AIInputPath": "F:/TestImage/imgs/",
"AIOutPath": "F:/TestImage/outs/"
},
"ZMQ": {
"SUBServer": "tcp://192.168.1.182:5000", //ZMQ SUB
"PUBServer": "tcp://192.168.1.182:5001", //ZMQ PUB
"AISvrServer": "tcp://127.0.0.1:5002", // AI byte[] ZMQ REQ-> REP
"SUBImageServer": "tcp://192.168.1.182:5000", //SUB byte[]
"DBSvrServer": "tcp://127.0.0.1:5010", // ZMQ REQ-> REP
"SUBServer": "tcp://192.168.1.182:5000", //ͨZMQ SUBϢĵַ
"PUBServer": "tcp://192.168.1.182:5001", //ͨZMQ PUB Ϣַ
"AISvrServer": "tcp://127.0.0.1:5002", // ҪAI ͼƬbyte[] ZMQ REQ-> REP ַ
"SUBImageServer": "tcp://192.168.1.182:5000", //SUB ͼƬ byte[] ĵַ ֿԭ ͼƬ
"DBSvrServer": "tcp://127.0.0.1:5010", // ݿӿ ZMQ REQ-> REP ַ
"SUBTopic": "Topic,A",
"Top": "Topic,A"
},

Loading…
Cancel
Save