|
|
@@ -6,8 +6,10 @@ using NetMQ.Monitoring;
|
|
|
using NetMQ.Sockets;
|
|
|
using OHV.Common.Model;
|
|
|
using OHV.Common.Shareds;
|
|
|
+using StackExchange.Redis.Extensions.Core.Extensions;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
@@ -246,7 +248,81 @@ namespace VehicleControlSystem.ControlLayer.MQ
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- #region Request Mothed
|
|
|
+ bool SetRequest(string index, string value )
|
|
|
+ {
|
|
|
+ List<string> repll = new List<string>();
|
|
|
+
|
|
|
+ if ( !this.IsReqConnected )
|
|
|
+ return false;
|
|
|
+
|
|
|
+ if ( !this.req.HasIn )
|
|
|
+ this.req.SendMoreFrame( "setm" ).SendFrame( index + "/" + value );
|
|
|
+
|
|
|
+ if ( !this.req.TryReceiveMultipartStrings( TimeSpan.FromSeconds( 5 ), ref repll ) )
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool GetRequst( string index, out List<string> vll)
|
|
|
+ {
|
|
|
+ vll = new List<string>();
|
|
|
+
|
|
|
+ if ( !this.IsReqConnected )
|
|
|
+ return false;
|
|
|
+
|
|
|
+ if ( !this.req.HasIn )
|
|
|
+ this.req.SendMoreFrame( "getm" ).SendFrame( index );
|
|
|
+
|
|
|
+ List<string> repll = new List<string>();
|
|
|
+
|
|
|
+ if ( this.req.TryReceiveMultipartStrings( TimeSpan.FromSeconds( 5 ), ref repll ) )
|
|
|
+ {
|
|
|
+ repll.RemoveAt( 0 );
|
|
|
+
|
|
|
+ var ret = repll[0].Split( '/' );
|
|
|
+ repll.Clear();
|
|
|
+
|
|
|
+ ret.ForEach( s =>
|
|
|
+ {
|
|
|
+ if ( s.Equals( "ok" ) || s.Equals( "nok" ) || s.Equals( index ) )
|
|
|
+ repll.Add( s );
|
|
|
+ } );
|
|
|
+
|
|
|
+ vll = repll;
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region Get Request Method
|
|
|
+ public eOperatationMode GetOperationMode()
|
|
|
+ {
|
|
|
+ List<string> rll;
|
|
|
+ this.GetRequst( "111", out rll );
|
|
|
+
|
|
|
+ if ( rll[0].Equals( "1" ) )
|
|
|
+ return eOperatationMode.AutoMode;
|
|
|
+ else
|
|
|
+ return eOperatationMode.ManualMode;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int CurrentPointNo()
|
|
|
+ {
|
|
|
+ List<string> rll;
|
|
|
+ this.GetRequst( "111", out rll );
|
|
|
+
|
|
|
+ int ret = 0;
|
|
|
+ int.TryParse( rll[1], out ret );
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Set Request Method
|
|
|
+
|
|
|
internal void SetObstruction( eObstacleState state )
|
|
|
{
|
|
|
string outStr = string.Empty;
|
|
|
@@ -254,16 +330,16 @@ namespace VehicleControlSystem.ControlLayer.MQ
|
|
|
switch ( state )
|
|
|
{
|
|
|
case eObstacleState.Normal:
|
|
|
- this.Request( "set", "5001/0", out outStr );
|
|
|
+ this.Request( "setm", "5001/0", out outStr );
|
|
|
break;
|
|
|
case eObstacleState.Abnormal:
|
|
|
- this.Request( "set", "5001/3", out outStr );
|
|
|
+ this.Request( "setm", "5001/3", out outStr );
|
|
|
break;
|
|
|
case eObstacleState.Blocked:
|
|
|
- this.Request( "set", "5001/2", out outStr );
|
|
|
+ this.Request( "setm", "5001/2", out outStr );
|
|
|
break;
|
|
|
case eObstacleState.Decelerate:
|
|
|
- this.Request( "set", "5001/1", out outStr );
|
|
|
+ this.Request( "setm", "5001/1", out outStr );
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -280,16 +356,15 @@ namespace VehicleControlSystem.ControlLayer.MQ
|
|
|
this.Request( "set", "112/0", out outStr );
|
|
|
else
|
|
|
{ }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
internal void SetMCState(bool isOn )
|
|
|
{
|
|
|
string outStr = string.Empty;
|
|
|
if ( isOn )
|
|
|
- this.Request( "set", "5000/1", out outStr );
|
|
|
+ this.Request( "setm", "5000/1", out outStr );
|
|
|
else
|
|
|
- this.Request( "set", "5000/0", out outStr );
|
|
|
+ this.Request( "setm", "5000/0", out outStr );
|
|
|
}
|
|
|
|
|
|
internal void SetCurrentSteeringState( eSteeringState state )
|