Commit f32b61a4 by liulongfei

上行数据接入

parent a18c53cf
......@@ -11,6 +11,7 @@ using VIZ.Framework.Connection;
using VIZ.Framework.Module;
using VIZ.GimbalAI.Controller.Connection;
using VIZ.GimbalAI.Controller.Domain;
using VIZ.GimbalAI.Controller.Storage;
namespace VIZ.GimbalAI.Controller.Module
{
......@@ -30,6 +31,16 @@ namespace VIZ.GimbalAI.Controller.Module
public override string Detail { get; } = "应用程序启动 -- 串口";
/// <summary>
/// 下行数据串口号(摇杆 -> 云台)
/// </summary>
private readonly string GIMBAL_SERIAL_PORT_DOWN = ApplicationDomainEx.IniStorage.GetValue<GimbalConfig, string>(p => p.GIMBAL_SERIAL_PORT_DOWN);
/// <summary>
/// 上行护具串口号(云台 -> 摇杆)
/// </summary>
private readonly string GIMBAL_SERIAL_PORT_UP = ApplicationDomainEx.IniStorage.GetValue<GimbalConfig, string>(p => p.GIMBAL_SERIAL_PORT_UP);
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
......@@ -39,12 +50,19 @@ namespace VIZ.GimbalAI.Controller.Module
ConnectionManager.SerialPortConnection = new SerialPortConnection();
// 下行
SerialPortEndpointManager down_endpoint_manager = new SerialPortEndpointManager(SerialPortKeys.DOWN, "COM4", 115200, Parity.None, 8, StopBits.One);
SerialPortEndpointManager down_endpoint_manager = new SerialPortEndpointManager(SerialPortKeys.DOWN, GIMBAL_SERIAL_PORT_DOWN, 115200, Parity.None, 8, StopBits.One);
down_endpoint_manager.PackageProvider = new GimbalPackageDownProvider(53, new byte[] { 0xA5, 0xE7 }, SerialPortKeys.DOWN);
ConnectionManager.SerialPortConnection.AddEndpointManager(down_endpoint_manager);
down_endpoint_manager.Open();
// 上行
SerialPortEndpointManager up_endpoint_manager = new SerialPortEndpointManager(SerialPortKeys.UP, GIMBAL_SERIAL_PORT_UP, 115200, Parity.None, 8, StopBits.One);
up_endpoint_manager.PackageProvider = new GimbalPackageUpProvider(53, new byte[] { 0x58, 0xA0 }, SerialPortKeys.UP);
ConnectionManager.SerialPortConnection.AddEndpointManager(up_endpoint_manager);
up_endpoint_manager.Open();
return true;
}
......@@ -54,7 +72,7 @@ namespace VIZ.GimbalAI.Controller.Module
/// <param name="context">应用程序启动上下文</param>
public override void Shutdown(AppSetupContext context)
{
ConnectionManager.SerialPortConnection.Dispose();
}
}
}
......@@ -18,5 +18,17 @@ namespace VIZ.GimbalAI.Controller.Storage
/// </summary>
[Ini(Section = "Gimbal", DefaultValue = "True", Type = typeof(bool))]
public string GIMBAL_IS_WRITE_DATA { get; set; }
/// <summary>
/// 下行数据串口号(摇杆 -> 云台)
/// </summary>
[Ini(Section = "Gimbal", DefaultValue = "True", Type = typeof(bool))]
public string GIMBAL_SERIAL_PORT_DOWN { get; set; }
/// <summary>
/// 上行护具串口号(云台 -> 摇杆)
/// </summary>
[Ini(Section = "Gimbal", DefaultValue = "True", Type = typeof(bool))]
public string GIMBAL_SERIAL_PORT_UP { get; set; }
}
}
......@@ -10,4 +10,8 @@ APPLICATION_IS_DEBUG=true
; ============================================================
[Gimbal]
; 是否输出数据
GIMBAL_IS_WRITE_DATA=true
\ No newline at end of file
GIMBAL_IS_WRITE_DATA=true
; 下行数据串口号(摇杆 -> 云台)
GIMBAL_SERIAL_PORT_DOWN=COM3
; 上行护具串口号(云台 -> 摇杆)
GIMBAL_SERIAL_PORT_UP=COM4
\ No newline at end of file
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