Commit e405596c LN

增加压力值上传

1 个父辈 cb5f948c
......@@ -314,5 +314,8 @@ namespace OnlineStore.Common
/// 忽略料叉报警
/// </summary>
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
//状态
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 = "";
if (commandResultMsg.Count() > 0)
......
......@@ -315,13 +315,33 @@ namespace DeviceLibrary
double fanwei = ReadShort(Addr.手动置零范围);
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>
/// <returns></returns>
public double GetWeight()
{
return ReadInt32(Addr.毛重);
double v = ReadInt32(Addr.毛重);
lastWeight.UpdateV(v);
return v;
}
/// <summary>
/// 重置尖峰重量值
......@@ -337,7 +357,9 @@ namespace DeviceLibrary
/// <returns></returns>
public double PeakWeight()
{
return ReadInt32(Addr.峰值);
double v = ReadInt32(Addr.峰值);
lastPeakWeight.UpdateV(v);
return v;
}
/// <summary>
/// 归零
......@@ -394,4 +416,34 @@ namespace DeviceLibrary
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
this.lblSensor = new System.Windows.Forms.Label();
this.btnAxisRStop = new System.Windows.Forms.Button();
this.btnAxisRTest = new System.Windows.Forms.Button();
this.axisMoveControl1 = new AxisMoveControl();
this.configControl1 = new ConfigControl();
this.axisMoveControl1 = new TheMachine.AxisMoveControl();
this.configControl1 = new TheMachine.ConfigControl();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.panel1.SuspendLayout();
......@@ -140,7 +140,7 @@ namespace TheMachine
this.btnAxisRStop.Name = "btnAxisRStop";
this.btnAxisRStop.Size = new System.Drawing.Size(155, 31);
this.btnAxisRStop.TabIndex = 13;
this.btnAxisRStop.Text = "旋转轴停止";
this.btnAxisRStop.Text = "轴循环停止";
this.btnAxisRStop.UseVisualStyleBackColor = true;
this.btnAxisRStop.Click += new System.EventHandler(this.button3_Click);
//
......@@ -150,7 +150,7 @@ namespace TheMachine
this.btnAxisRTest.Name = "btnAxisRTest";
this.btnAxisRTest.Size = new System.Drawing.Size(155, 31);
this.btnAxisRTest.TabIndex = 12;
this.btnAxisRTest.Text = "旋转轴循环";
this.btnAxisRTest.Text = "轴循环开始";
this.btnAxisRTest.UseVisualStyleBackColor = true;
this.btnAxisRTest.Click += new System.EventHandler(this.button2_Click);
//
......
......@@ -91,10 +91,38 @@ namespace TheMachine
volatile bool roateloop = false;
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(() => {
// var p1 = RobotManage.mainMachine.Config.UpDown_P1;
// var p1_speed = RobotManage.mainMachine.Config.UpDown_P1_speed;
// var axis = RobotManage.mainMachine.UpDown_Axis;
// 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)
// {
......@@ -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)
......
......@@ -143,8 +143,8 @@ namespace TheMachineNView
}
else
{
lblYa.Text =Math.Round( RobotManage.oKLE_WeightSensor.GetWeight(),2).ToString();
lblMaxY.Text = Math.Round(RobotManage.oKLE_WeightSensor.PeakWeight(), 2).ToString();
lblYa.Text =Math.Round( RobotManage.oKLE_WeightSensor.GetSWeight(),2).ToString();
lblMaxY.Text = Math.Round(RobotManage.oKLE_WeightSensor.GetSPeakWeight(), 2).ToString();
lblMaxSet.Text = Setting_Init.Device_WeightSensor_MaxValue.ToString();
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!