|
@@ -6,6 +6,7 @@ using Aitex.Core.RT.Log;
|
|
|
using Aitex.Core.RT.OperationCenter;
|
|
|
using Aitex.Core.RT.SCCore;
|
|
|
using Aitex.Core.Util;
|
|
|
+using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
using FurnaceRT.Equipments.Boats;
|
|
|
using FurnaceRT.Equipments.Systems;
|
|
|
using MECF.Framework.Common.Equipment;
|
|
@@ -249,6 +250,7 @@ namespace FurnaceRT.Devices
|
|
|
return _diServoOn.Value;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
public IoFurnaceMotor(string module, XmlElement node, string ioModule = "")
|
|
@@ -436,28 +438,37 @@ namespace FurnaceRT.Devices
|
|
|
{
|
|
|
if (_diMoving.Value || _diHoming.Value)
|
|
|
{
|
|
|
- List<bool> chunks = new List<bool> { _diM0.Value, _diM1.Value, _diM2.Value, _diM3.Value, _diM4.Value, _diM5.Value };
|
|
|
- chunks.Reverse();
|
|
|
+ return GetRAxisSpeed();
|
|
|
+ }
|
|
|
+ return 0f;
|
|
|
+ }
|
|
|
+ private float GetRAxisSpeed()
|
|
|
+ {
|
|
|
|
|
|
- string binaryString = "";
|
|
|
- foreach (bool chunk in chunks)
|
|
|
- {
|
|
|
- binaryString += chunk ? "1" : "0";
|
|
|
- }
|
|
|
+ List<bool> chunks = new List<bool> { _diM0.Value, _diM1.Value, _diM2.Value, _diM3.Value, _diM4.Value, _diM5.Value };
|
|
|
+ chunks.Reverse();
|
|
|
|
|
|
- int intValue = Convert.ToInt32(binaryString, 2);
|
|
|
+ string binaryString = "";
|
|
|
+ foreach (bool chunk in chunks)
|
|
|
+ {
|
|
|
+ binaryString += chunk ? "1" : "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ int intValue = Convert.ToInt32(binaryString, 2);
|
|
|
|
|
|
- if (intValue >= 8 && intValue <= 47)
|
|
|
+ if (intValue >= 8 && intValue <= 47)
|
|
|
+ {
|
|
|
+ decimal standardSpeed = 0.1M;
|
|
|
+ for (int i = 8; i < intValue; i++)
|
|
|
{
|
|
|
- decimal standardSpeed = 0.1M;
|
|
|
- for (int i = 8; i < intValue; i++)
|
|
|
- {
|
|
|
- standardSpeed += 0.1M;
|
|
|
- }
|
|
|
- return (float)standardSpeed;
|
|
|
+ standardSpeed += 0.1M;
|
|
|
}
|
|
|
+ return (float)standardSpeed;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 0f;
|
|
|
}
|
|
|
- return 0f;
|
|
|
}
|
|
|
private float GetAxisSpeed()
|
|
|
{
|
|
@@ -664,6 +675,27 @@ namespace FurnaceRT.Devices
|
|
|
break;
|
|
|
|
|
|
case State.Rotating:
|
|
|
+ //if (_timer.GetElapseTime() >= 100)
|
|
|
+ //{
|
|
|
+ // var currSpeed = GetRAxisSpeed();
|
|
|
+ // if (!_doMove.Value && _setSpeed == (float)(currSpeed))
|
|
|
+ // {
|
|
|
+ // _doCCW.SetValue(!_isCW, out _);
|
|
|
+ // _doCW.SetValue(_isCW, out _);
|
|
|
+ // _doMove.SetValue(true, out _);
|
|
|
+ // SC.SetItemValue(_scServoMoveSpeed.PathName, _setSpeed);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // if (_timer.GetElapseTime() >= resetTime && !_doMove.Value && _setSpeed != (float)(currSpeed))
|
|
|
+ // {
|
|
|
+ // EV.PostAlarmLog($"{Module}", $"{Name} Motor Rotating timeout");
|
|
|
+ // _doMove.SetValue(false, out _);
|
|
|
+ // _state = State.Idle;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
default:
|
|
@@ -754,27 +786,19 @@ namespace FurnaceRT.Devices
|
|
|
break;
|
|
|
case "CW":
|
|
|
_state = State.Rotating;
|
|
|
- _doMove.SetPulseValue(true, resetTime);
|
|
|
- //ServoMoveSpeedSet = speed > 0 ? speed : (float)_scServoMoveSpeed.DoubleValue;
|
|
|
SetRotateSpeed(speed);
|
|
|
_doCCW.SetValue(false, out _);
|
|
|
_doCW.SetValue(true, out _);
|
|
|
SC.SetItemValue(_scServoMoveSpeed.PathName, speed);
|
|
|
+ _doMove.SetPulseValue(true, resetTime);
|
|
|
break;
|
|
|
case "CCW":
|
|
|
_state = State.Rotating;
|
|
|
- _doMove.SetPulseValue(true, resetTime);
|
|
|
- //ServoMoveSpeedSet = speed > 0 ? speed : (float)_scServoMoveSpeed.DoubleValue;
|
|
|
SetRotateSpeed(speed);
|
|
|
- _doCW.SetValue(false, out _);
|
|
|
_doCCW.SetValue(true, out _);
|
|
|
+ _doCW.SetValue(false, out _);
|
|
|
SC.SetItemValue(_scServoMoveSpeed.PathName, speed);
|
|
|
- break;
|
|
|
- case "Rotate":
|
|
|
- _state = State.Rotating;
|
|
|
- ServoMovePositionSet = 0;
|
|
|
_doMove.SetPulseValue(true, resetTime);
|
|
|
- _timer.Start(0);
|
|
|
break;
|
|
|
|
|
|
}
|
|
@@ -784,11 +808,12 @@ namespace FurnaceRT.Devices
|
|
|
|
|
|
private void SetRotateSpeed(float speed)
|
|
|
{
|
|
|
+ var value = Math.Round(speed, 3, MidpointRounding.AwayFromZero);
|
|
|
decimal standardSpeed = 0.1M;
|
|
|
bool enterSplit = false;
|
|
|
for (int i = 8; i <= 47; i++)
|
|
|
{
|
|
|
- decimal compareSpeed = Convert.ToDecimal(speed);
|
|
|
+ decimal compareSpeed = Convert.ToDecimal(value);
|
|
|
if (Decimal.Compare(compareSpeed, standardSpeed) > 0)
|
|
|
{
|
|
|
standardSpeed = standardSpeed + 0.1M;
|
|
@@ -808,17 +833,20 @@ namespace FurnaceRT.Devices
|
|
|
_doM1.SetValue(chunks[1], out _);
|
|
|
_doM2.SetValue(chunks[2], out _);
|
|
|
_doM3.SetValue(chunks[3], out _);
|
|
|
- _doM4.SetValue(false, out _);
|
|
|
- _doM5.SetValue(false, out _);
|
|
|
- if (chunks.Count == 5)
|
|
|
- {
|
|
|
- _doM4.SetValue(chunks[4], out _);
|
|
|
- _doM5.SetValue(false, out _);
|
|
|
- }
|
|
|
- if (chunks.Count == 6)
|
|
|
+ switch (chunks.Count)
|
|
|
{
|
|
|
- _doM4.SetValue(chunks[4], out _);
|
|
|
- _doM5.SetValue(chunks[5], out _);
|
|
|
+ case 5:
|
|
|
+ _doM4.SetValue(chunks[4], out _);
|
|
|
+ _doM5.SetValue(false, out _);
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ _doM4.SetValue(chunks[4], out _);
|
|
|
+ _doM5.SetValue(chunks[5], out _);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ _doM4.SetValue(false, out _);
|
|
|
+ _doM5.SetValue(false, out _);
|
|
|
+ break;
|
|
|
}
|
|
|
return;
|
|
|
}
|