Commit e405596c LN

增加压力值上传

1 个父辈 cb5f948c
...@@ -314,5 +314,8 @@ namespace OnlineStore.Common ...@@ -314,5 +314,8 @@ namespace OnlineStore.Common
/// 忽略料叉报警 /// 忽略料叉报警
/// </summary> /// </summary>
public static string ignoreFixtureAlarm = "ignoreFixtureAlarm"; public static string ignoreFixtureAlarm = "ignoreFixtureAlarm";
public const string yaliValue = "yaliValue";
public const string yaliMaxValue = "yaliMaxValue";
public const string yaliAlarmValue = "yaliAlarmValue";
} }
} }
...@@ -243,7 +243,15 @@ namespace DeviceLibrary ...@@ -243,7 +243,15 @@ namespace DeviceLibrary
//状态 //状态
boxStatus.status = (int)storeStatus; boxStatus.status = (int)storeStatus;
if (Setting_Init.Device_WeightSensor_PortName == "" || RobotManage.oKLE_WeightSensor == null || (!RobotManage.oKLE_WeightSensor.IsPortOpen))
{ }
else
{
lineOperation.data.Add(ParamDefine.yaliValue, RobotManage.oKLE_WeightSensor.GetSWeight().ToString());
lineOperation.data.Add(ParamDefine.yaliMaxValue, RobotManage.oKLE_WeightSensor.GetSPeakWeight().ToString());
lineOperation.data.Add(ParamDefine.yaliAlarmValue, Setting_Init.Device_WeightSensor_MaxValue.ToString());
}
string sendmsg = ""; string sendmsg = "";
if (commandResultMsg.Count() > 0) if (commandResultMsg.Count() > 0)
......
...@@ -315,13 +315,33 @@ namespace DeviceLibrary ...@@ -315,13 +315,33 @@ namespace DeviceLibrary
double fanwei = ReadShort(Addr.手动置零范围); double fanwei = ReadShort(Addr.手动置零范围);
loge.Info($"读取到手动置零范围:{fanwei}"); loge.Info($"读取到手动置零范围:{fanwei}");
} }
private ShowDataInfo lastWeight = new ShowDataInfo();
private ShowDataInfo lastPeakWeight = new ShowDataInfo();
public double GetSWeight()
{
if (!lastWeight.IsTimeout())
{
return lastWeight.lastValue;
}
return ReadInt32(Addr.毛重);
}
public double GetSPeakWeight()
{
if (!lastPeakWeight.IsTimeout())
{
return lastPeakWeight.lastValue;
}
return PeakWeight();
}
/// <summary> /// <summary>
/// 获取重量值 /// 获取重量值
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public double GetWeight() public double GetWeight()
{ {
return ReadInt32(Addr.毛重); double v = ReadInt32(Addr.毛重);
lastWeight.UpdateV(v);
return v;
} }
/// <summary> /// <summary>
/// 重置尖峰重量值 /// 重置尖峰重量值
...@@ -337,7 +357,9 @@ namespace DeviceLibrary ...@@ -337,7 +357,9 @@ namespace DeviceLibrary
/// <returns></returns> /// <returns></returns>
public double PeakWeight() public double PeakWeight()
{ {
return ReadInt32(Addr.峰值); double v = ReadInt32(Addr.峰值);
lastPeakWeight.UpdateV(v);
return v;
} }
/// <summary> /// <summary>
/// 归零 /// 归零
...@@ -394,4 +416,34 @@ namespace DeviceLibrary ...@@ -394,4 +416,34 @@ namespace DeviceLibrary
Console.WriteLine(msg); Console.WriteLine(msg);
} }
} }
public class ShowDataInfo
{
private int type = 0;
public double lastValue = 0;
private DateTime lastTime = DateTime.Now;
public void UpdateV(double lastV)
{
this.lastValue = lastV;
lastTime = DateTime.Now;
}
public bool IsTimeout()
{
if (lastValue <= 0)
{
return true;
}
else
{
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 2)
{
return true;
}
}
return false;
}
}
} }
...@@ -40,8 +40,8 @@ namespace TheMachine ...@@ -40,8 +40,8 @@ namespace TheMachine
this.lblSensor = new System.Windows.Forms.Label(); this.lblSensor = new System.Windows.Forms.Label();
this.btnAxisRStop = new System.Windows.Forms.Button(); this.btnAxisRStop = new System.Windows.Forms.Button();
this.btnAxisRTest = new System.Windows.Forms.Button(); this.btnAxisRTest = new System.Windows.Forms.Button();
this.axisMoveControl1 = new AxisMoveControl(); this.axisMoveControl1 = new TheMachine.AxisMoveControl();
this.configControl1 = new ConfigControl(); this.configControl1 = new TheMachine.ConfigControl();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
...@@ -140,7 +140,7 @@ namespace TheMachine ...@@ -140,7 +140,7 @@ namespace TheMachine
this.btnAxisRStop.Name = "btnAxisRStop"; this.btnAxisRStop.Name = "btnAxisRStop";
this.btnAxisRStop.Size = new System.Drawing.Size(155, 31); this.btnAxisRStop.Size = new System.Drawing.Size(155, 31);
this.btnAxisRStop.TabIndex = 13; this.btnAxisRStop.TabIndex = 13;
this.btnAxisRStop.Text = "旋转轴停止"; this.btnAxisRStop.Text = "轴循环停止";
this.btnAxisRStop.UseVisualStyleBackColor = true; this.btnAxisRStop.UseVisualStyleBackColor = true;
this.btnAxisRStop.Click += new System.EventHandler(this.button3_Click); this.btnAxisRStop.Click += new System.EventHandler(this.button3_Click);
// //
...@@ -150,7 +150,7 @@ namespace TheMachine ...@@ -150,7 +150,7 @@ namespace TheMachine
this.btnAxisRTest.Name = "btnAxisRTest"; this.btnAxisRTest.Name = "btnAxisRTest";
this.btnAxisRTest.Size = new System.Drawing.Size(155, 31); this.btnAxisRTest.Size = new System.Drawing.Size(155, 31);
this.btnAxisRTest.TabIndex = 12; this.btnAxisRTest.TabIndex = 12;
this.btnAxisRTest.Text = "旋转轴循环"; this.btnAxisRTest.Text = "轴循环开始";
this.btnAxisRTest.UseVisualStyleBackColor = true; this.btnAxisRTest.UseVisualStyleBackColor = true;
this.btnAxisRTest.Click += new System.EventHandler(this.button2_Click); this.btnAxisRTest.Click += new System.EventHandler(this.button2_Click);
// //
......
...@@ -91,10 +91,38 @@ namespace TheMachine ...@@ -91,10 +91,38 @@ namespace TheMachine
volatile bool roateloop = false; volatile bool roateloop = false;
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
Task.Run(() =>
{
var p1 = RobotManage.mainMachine.Config.UpDown_P1;
var p1_speed = RobotManage.mainMachine.Config.UpDown_P1_speed;
var axis = RobotManage.mainMachine.UpDown_Axis;
roateloop = true;
while (roateloop)
{
axis.AbsMove(null, p1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
if (!roateloop)
break;
Task.Delay(500).Wait();
axis.AbsMove(null, 1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
Task.Delay(500).Wait();
}
});
//Task.Run(() => { //Task.Run(() => {
// var p1 = RobotManage.mainMachine.Config.UpDown_P1; // var p1 = RobotManage.mainMachine.Config.Middle_P1;
// var p1_speed = RobotManage.mainMachine.Config.UpDown_P1_speed; // var p1_speed = RobotManage.mainMachine.Config.Middle_P1_speed;
// var axis = RobotManage.mainMachine.UpDown_Axis; // var axis = RobotManage.mainMachine.Middle_Axis;
// roateloop = true; // roateloop = true;
// while (roateloop) // while (roateloop)
// { // {
...@@ -117,33 +145,6 @@ namespace TheMachine ...@@ -117,33 +145,6 @@ namespace TheMachine
// } // }
//}); //});
Task.Run(() => {
var p1 = RobotManage.mainMachine.Config.Middle_P1;
var p1_speed = RobotManage.mainMachine.Config.Middle_P1_speed;
var axis = RobotManage.mainMachine.Middle_Axis;
roateloop = true;
while (roateloop)
{
axis.AbsMove(null, p1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
if (!roateloop)
break;
Task.Delay(500).Wait();
axis.AbsMove(null, 1, p1_speed);
Task.Delay(200).Wait();
while (axis.IsBusy)
{
Task.Delay(100).Wait();
}
Task.Delay(500).Wait();
}
});
} }
private void button3_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)
......
...@@ -143,8 +143,8 @@ namespace TheMachineNView ...@@ -143,8 +143,8 @@ namespace TheMachineNView
} }
else else
{ {
lblYa.Text =Math.Round( RobotManage.oKLE_WeightSensor.GetWeight(),2).ToString(); lblYa.Text =Math.Round( RobotManage.oKLE_WeightSensor.GetSWeight(),2).ToString();
lblMaxY.Text = Math.Round(RobotManage.oKLE_WeightSensor.PeakWeight(), 2).ToString(); lblMaxY.Text = Math.Round(RobotManage.oKLE_WeightSensor.GetSPeakWeight(), 2).ToString();
lblMaxSet.Text = Setting_Init.Device_WeightSensor_MaxValue.ToString(); lblMaxSet.Text = Setting_Init.Device_WeightSensor_MaxValue.ToString();
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!