Commit 32c61afd authored by 潘栩锋's avatar 潘栩锋 🚴

修复 浙江班奈特 真实环境调试。

parent e12c6823
......@@ -17,11 +17,19 @@ namespace FLY.Winder.BanNaiTe.UI.Server
{
public event PropertyChangedEventHandler PropertyChanged;
const string ADDR_CW = "DB107.0.0";//顺时针(正方向) ,程序会直接读取 DB7.0.0~DB7.0.4
const string ADDR_CCW = "DB107.0.1";//逆时针(反方向)
const string ADDR_Sign0 = "DB107.0.2";//转向信号0 (撞了它, 变为正方向运行)
const string ADDR_Sign1 = "DB107.0.3";//转向信号1 (撞了它, 变为反方向运行)
const string ADDR_OrgSign = "DB107.0.4";//复位原点信号 (撞了它后,证明在中间)
const string ADDR_SIGNBASE = "DB107.0.0";//信号地址
const int SIGN_CNT = 5;
const int SIGN_INDEX_FORW = 0;//正方向
const int SIGN_INDEX_BACKW = 1;//反方向
const int SIGN_INDEX_1 = 2;//转向信号1 (撞了它, 变为反方向运行)
const int SIGN_INDEX_0 = 3; //转向信号0(撞了它, 变为正方向运行)
const int SIGN_INDEX_ORG = 4;//复位原点信号 (撞了它后,证明在中间)
//const string ADDR_FORW = "DB107.0.0";//顺时针(正方向) ,程序会直接读取 DB7.0.0~DB7.0.4
//const string ADDR_BACKW = "DB107.0.1";//逆时针(反方向)
//const string ADDR_Sign1 = "DB107.0.2";//转向信号1 (撞了它, 变为反方向运行)
//const string ADDR_Sign0 = "DB107.0.3";//转向信号0 (撞了它, 变为正方向运行)
//const string ADDR_OrgSign = "DB107.0.4";//复位原点信号 (撞了它后,证明在中间)
const string ADDR_RotaryVelocity = "DB107.2";//旋转塔速度% 有正负
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
......@@ -219,14 +227,14 @@ namespace FLY.Winder.BanNaiTe.UI.Server
bool Read()
{
var resultBools = device.ReadBool(ADDR_CW, 5);
var resultBools = device.ReadBool(ADDR_SIGNBASE, SIGN_CNT);
if (!SetState(resultBools))
return false;
IsForw = resultBools.Content[0];
IsBackw = resultBools.Content[1];
IsTurnSign0 = resultBools.Content[2];
IsTurnSign1 = resultBools.Content[3];
IsOrgSign = resultBools.Content[4];
IsForw = resultBools.Content[SIGN_INDEX_FORW];
IsBackw = resultBools.Content[SIGN_INDEX_BACKW];
IsTurnSign0 = resultBools.Content[SIGN_INDEX_0];
IsTurnSign1 = resultBools.Content[SIGN_INDEX_1];
IsOrgSign = resultBools.Content[SIGN_INDEX_ORG];
var resultFloat = device.ReadFloat(ADDR_RotaryVelocity);
if (!SetState(resultFloat))
......
......@@ -133,7 +133,7 @@ namespace FLY.Winder.BanNaiTe.UI.Server
rposOfRInFile = LoadRPosOfR();
if (double.IsNaN(rposOfRInFile))
{
rposOfRInFile = 20000;
rposOfRInFile = 25 * 19.1 * 60;
SaveRPosOfR(rposOfRInFile);
}
......@@ -145,13 +145,13 @@ namespace FLY.Winder.BanNaiTe.UI.Server
RPosAtTurnSign1 = RPosOfR / 2;
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsPlcConnected), this, nameof(IsPlcConnected));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsForw), this, nameof(IsForw));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsBackw), this, nameof(IsBackw));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsTurnSign0), this, nameof(IsTurnSign0));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsTurnSign1), this, nameof(IsTurnSign1));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsForw), this, nameof(IsBackw));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsBackw), this, nameof(IsForw));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsTurnSign0), this, nameof(IsTurnSign1));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsTurnSign1), this, nameof(IsTurnSign0));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsOrgSign), this, nameof(IsOrgSign));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.RotaryVelocity),()=> {
RSpeed = plc.RotaryVelocity;
RSpeed = -plc.RotaryVelocity;
});
updateMinuteOfR();
......@@ -269,13 +269,13 @@ namespace FLY.Winder.BanNaiTe.UI.Server
RPosAtTurnSign0 = RPosGlobal;
isReal_RPosAtTurnSign0 = true;
if (isReal_RPosAtTurnSign1)
if (isReal_RPosAtTurnSign0 && isReal_RPosAtTurnSign1)
{
updateRPosOfR();
}
//-------------------------------------------------------------
//位置预测
//位置预测, SIGN1 还没触发
if (!isReal_RPosAtTurnSign1)
{
if (!isReal_RPosAtOrgSign)//原点信号 还没发生
......@@ -285,6 +285,7 @@ namespace FLY.Winder.BanNaiTe.UI.Server
else //原点信号 发生了
{
RPosOfR = (RPosAtOrgSign - RPosAtTurnSign0) * 2;
//通过原点计算的 RPosOfR,不会保存
}
RPosAtTurnSign1 = RPosAtTurnSign0 + RPosOfR;
}
......@@ -298,7 +299,7 @@ namespace FLY.Winder.BanNaiTe.UI.Server
RPosAtTurnSign1 = RPosGlobal;
isReal_RPosAtTurnSign1 = true;
if (isReal_RPosAtTurnSign0)
if (isReal_RPosAtTurnSign0 && isReal_RPosAtTurnSign1)
{
updateRPosOfR();
}
......@@ -314,6 +315,7 @@ namespace FLY.Winder.BanNaiTe.UI.Server
else //原点信号 发生了
{
RPosOfR = (RPosAtTurnSign1 - RPosAtOrgSign) * 2;
//通过原点计算的 RPosOfR,不会保存
}
RPosAtTurnSign0 = RPosAtTurnSign1 - RPosOfR;
}
......@@ -424,11 +426,13 @@ namespace FLY.Winder.BanNaiTe.UI.Server
else if (isReal_RPosAtTurnSign0 && !isReal_RPosAtTurnSign1) //信号0 发生了,信号1 还没发生
{
RPosOfR = (RPosAtOrgSign - RPosAtTurnSign0) * 2;
//通过原点计算的 RPosOfR,不会保存
RPosAtTurnSign1 = RPosAtTurnSign0 + RPosOfR;
}
else if (!isReal_RPosAtTurnSign0 && isReal_RPosAtTurnSign1) //信号0 还没发生,信号1 发生了
{
RPosOfR = (RPosAtOrgSign - RPosAtTurnSign0) * 2;
RPosOfR = (RPosAtTurnSign1 - RPosAtOrgSign) * 2;
//通过原点计算的 RPosOfR,不会保存
RPosAtTurnSign0 = RPosAtTurnSign1 - RPosOfR;
}
}
......
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