Commit a3bef9f9 authored by 谢旭's avatar 谢旭

修改弹窗页面

parent e5edfd3e
No preview for this file type
...@@ -14,17 +14,24 @@ namespace CefDemo.Controllers ...@@ -14,17 +14,24 @@ namespace CefDemo.Controllers
public class ElecFenceController : ApiController public class ElecFenceController : ApiController
{ {
// GET api // GET api
public string Get(string id) public bool Get(string id)
{ {
return id; return true;
} }
// POST api // POST api
public string Post([FromBody] FenceModel model) public bool Post([FromBody] FenceModel model)
{ {
CalculateModel.SaveModel(model); CalculateModel.SaveModel(model);
CalculateModel.issetValue = true; CalculateModel.issetValue = true;
return "ok"; if (CalculateModel.Model == null)
{
return false;
}
else
{
return true;
}
} }
// PUT api // PUT api
public void Put(int id, string value) public void Put(int id, string value)
......
...@@ -18,6 +18,7 @@ namespace CefDemo.Extension ...@@ -18,6 +18,7 @@ namespace CefDemo.Extension
static public FenceModel Model; static public FenceModel Model;
static public bool issetValue =false; static public bool issetValue =false;
static public bool isOutArea = false;
public static bool IsSamePoint(Point p1,Point p2) public static bool IsSamePoint(Point p1,Point p2)
{ {
...@@ -110,6 +111,122 @@ namespace CefDemo.Extension ...@@ -110,6 +111,122 @@ namespace CefDemo.Extension
} }
public static string GetPointState(Point point)
{
if (Model == null)
return "--";
if (Model.FenceType == "polygon")
{
if (IsinPolyhedron(point, points, Convert.ToSingle(Model.Height)))
{
//在围栏内
var dis = PointToPlane(points, point, Convert.ToSingle(Model.Height), Convert.ToSingle(Model.Buffer_dis));
if (dis >= Convert.ToSingle(Model.Buffer_dis))
{
return "缓冲区内";
}
else if (dis < Convert.ToSingle(Model.Buffer_dis))
{
var showdis = dis.ToString().Substring(0, 5);
return "接近电子围栏";
}
//if (isOutArea == true)
//{
// //isOutArea = SocketModel.CancelCmd("#sic,,set,elecfence.alarm_enable,off" + Environment.NewLine);
//}
}
else
{
//在围栏外
var dis = PointToPlane(points, point, Convert.ToSingle(Model.Height), Convert.ToSingle(Model.Buffer_dis));
//var showdis = dis.ToShort();
////发出警报
//if (isOutArea == false)
//{
// /// isOutArea = SocketModel.SendCmd("#sic,,set,elecfence.alarm_enable,on" + Environment.NewLine);
//}
return $"闯出电子围栏";
}
}
else if (Model.FenceType == "sphere")
{
double _inner_Radius = Convert.ToSingle(Model.Radius) - Convert.ToSingle(Model.Buffer_dis) ; //内球体半径
double _distance = P2PDistance(point, Center); //
if (_distance < _inner_Radius)
{
// 内球体内
return "闯入";
}
else if (_distance >= _inner_Radius && _distance < Convert.ToSingle(Model.Radius))
{
//缓冲区内
return "闯入";
}
else if (_distance >= Convert.ToSingle(Model.Radius))
{
//在球外
return "闯出";
}
}
else if (Model.FenceType == "circle")
{
double low_hight = Center.Z;
double hei_height = Center.Z + Convert.ToSingle( Model.Height);
double buffer_low = Center.Z + Convert.ToSingle(Model.Buffer_dis);
double buffer_hei = hei_height- Convert.ToSingle(Model.Buffer_dis);
if ((point.Z >= buffer_low && point.Z <= buffer_hei)||(point.Z >= low_hight && point.Z <= hei_height && point.Z < buffer_low && point.Z > buffer_hei))
{
double _hor_inner_radius = 0.0;
_hor_inner_radius = Convert.ToSingle(Model.Radius) - Convert.ToSingle(Model.Buffer_dis);
//投影到平面计算, 点与圆心的距离
double _distance = P2PDistance(point, Center);
//如果投影再内,再判断高度是否超出
if (_distance > _hor_inner_radius)
{
//在内圆,安全
return "缓冲区内";
}
else if (_distance <= _hor_inner_radius && _distance < Convert.ToSingle(Model.Radius))
{
////出了内圆 在外圆内
return "接近电子围栏";
}
else if (_distance >= Convert.ToSingle(Model.Radius))
{
return "闯出电子围栏";
}
}
else
{
return "闯出电子围栏";
}
}
return "--";
}
/// <summary> /// <summary>
/// 多面体电子围栏 /// 多面体电子围栏
/// </summary> /// </summary>
...@@ -134,12 +251,24 @@ namespace CefDemo.Extension ...@@ -134,12 +251,24 @@ namespace CefDemo.Extension
var showdis = dis.ToString().Substring(0,5); var showdis = dis.ToString().Substring(0,5);
return $"距离电子围栏{showdis}米"; return $"距离电子围栏{showdis}米";
} }
if (isOutArea==true)
{
//isOutArea = SocketModel.CancelCmd("#sic,,set,elecfence.alarm_enable,off" + Environment.NewLine);
}
} }
else else
{ {
//在围栏外 //在围栏外
var dis = PointToPlane(points, point, Height, Buffer_dis); var dis = PointToPlane(points, point, Height, Buffer_dis);
var showdis = dis.ToShort(); var showdis = dis.ToShort();
//发出警报
if (isOutArea==false)
{
/// isOutArea = SocketModel.SendCmd("#sic,,set,elecfence.alarm_enable,on" + Environment.NewLine);
}
return $"超出电子围栏{showdis}米"; return $"超出电子围栏{showdis}米";
} }
...@@ -339,13 +468,13 @@ namespace CefDemo.Extension ...@@ -339,13 +468,13 @@ namespace CefDemo.Extension
public static string GetWarningInfo(Point point) public static string GetWarningInfo(Point point)
{ {
if (Model == null) if (Model == null)
return "0.0"; return "--";
if (Model.FenceType == "polygon") //多边体 if (Model.FenceType == "polygon") //多边体
{ {
if (points == null && issetValue ==true) if (points == null && issetValue ==true)
{ {
return "0.0"; return "--";
} }
else else
{ {
...@@ -357,7 +486,7 @@ namespace CefDemo.Extension ...@@ -357,7 +486,7 @@ namespace CefDemo.Extension
{ {
if (Center == null && issetValue == true) if (Center == null && issetValue == true)
{ {
return "0.0"; return "--";
} }
else else
{ return DistanceToCylinder(Center, Convert.ToSingle(Model.Radius), point, Convert.ToSingle(Model.Height), Convert.ToSingle(Model.Buffer_dis)); } { return DistanceToCylinder(Center, Convert.ToSingle(Model.Radius), point, Convert.ToSingle(Model.Height), Convert.ToSingle(Model.Buffer_dis)); }
...@@ -367,7 +496,7 @@ namespace CefDemo.Extension ...@@ -367,7 +496,7 @@ namespace CefDemo.Extension
{ {
if (Center == null && issetValue == true) if (Center == null && issetValue == true)
{ {
return "0.0"; return "--";
} }
else else
{ {
...@@ -381,7 +510,13 @@ namespace CefDemo.Extension ...@@ -381,7 +510,13 @@ namespace CefDemo.Extension
} }
public static bool isOutBufferArea()
{
if (Model == null) return false;
return true;
}
} }
} }
...@@ -185,6 +185,21 @@ namespace CefDemo.Extension ...@@ -185,6 +185,21 @@ namespace CefDemo.Extension
} }
public static bool SendCmd(string cmd)
{
byte[] arrServerRecMsg = new byte[1024 * 10];
client.Send(Encoding.UTF8.GetBytes(cmd));
return true;
}
public static bool CancelCmd(string cmd)
{
byte[] arrServerRecMsg = new byte[1024 * 10];
client.Send(Encoding.UTF8.GetBytes(cmd));
return false;
}
} }
} }
...@@ -134,11 +134,12 @@ namespace CefDemo ...@@ -134,11 +134,12 @@ namespace CefDemo
string longitude = location.ElementAt(Convert.ToInt32(i++ % 16)).Value.ToString(); string longitude = location.ElementAt(Convert.ToInt32(i++ % 16)).Value.ToString();
string latitude = location.ElementAt(Convert.ToInt32(i++ % 16)).Key.ToString(); string latitude = location.ElementAt(Convert.ToInt32(i++ % 16)).Key.ToString();
string alitude = "50.32"; string alitude = "50.32";
string distance = CalculateModel.GetWarningInfo(new Point(Convert.ToSingle(longitude), Point point = new Point(Convert.ToSingle(longitude),
Convert.ToSingle(latitude), Convert.ToSingle(latitude),
Convert.ToSingle(alitude) Convert.ToSingle(alitude)
)); );
string distance = CalculateModel.GetWarningInfo(point);
string pointstate = CalculateModel.GetPointState(point);
string sendMessage = "" + string sendMessage = "" +
"{\"deviceType\":\"RTK\"" + "{\"deviceType\":\"RTK\"" +
",\"SICVersion\":\"SIC_1.2\"" + ",\"SICVersion\":\"SIC_1.2\"" +
...@@ -155,9 +156,8 @@ namespace CefDemo ...@@ -155,9 +156,8 @@ namespace CefDemo
",\"deviceBrand\":\"SOUTH\"" + ",\"deviceBrand\":\"SOUTH\"" +
",\"receivetime\":\"20200630153620\"" + ",\"receivetime\":\"20200630153620\"" +
",\"longitude\":" + longitude + // ",\"longitude\":" + longitude + //
",\"WarningInfo\":" +"\""+ distance + "\"" + ",\"WarningInfo\":" +"\""+ distance + "\"" +
",\"Pointstate\":" + "\"" + pointstate + "\"" +
//",\"WarningInfo\":\"20200630153620\"" +
"}"; "}";
if (i==10000000) if (i==10000000)
{ {
......
This diff is collapsed.
...@@ -14,5 +14,5 @@ ...@@ -14,5 +14,5 @@
<app-root></app-root> <app-root></app-root>
<!-- <script src="./assets/cesium/Source/Cesium.js" type="module"></script> <!-- <script src="./assets/cesium/Source/Cesium.js" type="module"></script>
<script src="./assets/smart3d/smart3d.js" type="text/javascript"></script> --> <script src="./assets/smart3d/smart3d.js" type="text/javascript"></script> -->
<script type="text/javascript" src="runtime.63f49ff57885da8e180a.js"></script><script type="text/javascript" src="es2015-polyfills.bd2948f767ad791e8f4b.js" nomodule></script><script type="text/javascript" src="polyfills.83c00be449c76cfa39e1.js"></script><script type="text/javascript" src="scripts.c62c23642f7fbbbdafae.js"></script><script type="text/javascript" src="main.ab80c7291b04b69861ec.js"></script></body> <script type="text/javascript" src="runtime.63f49ff57885da8e180a.js"></script><script type="text/javascript" src="es2015-polyfills.bd2948f767ad791e8f4b.js" nomodule></script><script type="text/javascript" src="polyfills.83c00be449c76cfa39e1.js"></script><script type="text/javascript" src="scripts.c62c23642f7fbbbdafae.js"></script><script type="text/javascript" src="main.c503e1fd5f61b3e2c396.js"></script></body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment