Commit 4eaa20d8 LN

新增:氛围灯,红外传感器,压力传感器。

1 个父辈 599eba92
...@@ -360,4 +360,5 @@ MigrationBackup/ ...@@ -360,4 +360,5 @@ MigrationBackup/
.ionide/ .ionide/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd
\ No newline at end of file \ No newline at end of file
FodyWeavers.xsd
/doc
...@@ -225,6 +225,23 @@ namespace OnlineStore.Common ...@@ -225,6 +225,23 @@ namespace OnlineStore.Common
public static MyConfig<int> UploadVideo_ImgHeight = 1080; public static MyConfig<int> UploadVideo_ImgHeight = 1080;
[MyConfigComment("监控上传功能_图像质量")] [MyConfigComment("监控上传功能_图像质量")]
public static MyConfig<int> UploadVideo_ImgQuality = 100; public static MyConfig<int> UploadVideo_ImgQuality = 100;
[MyConfigComment("LED氛围灯_端口号")]
public static MyConfig<string> Device_LedLight_PortName = "";
[MyConfigComment("红外传感器_端口号")]
public static MyConfig<string> Device_DauxiKS107_PortName = "";
[MyConfigComment("红外传感器_基准值")]
public static MyConfig<int> Device_DauxiKS107_BaseValue = 1000;
[MyConfigComment("红外传感器_最大误差值")]
public static MyConfig<int> Device_DauxiKS107_ErrorValue = 10000;
[MyConfigComment("重力传感器_端口号")]
public static MyConfig<string> Device_WeightSensor_PortName = "";
[MyConfigComment("重力传感器_上限值")]
public static MyConfig<int> Device_WeightSensor_MaxValue =10000;
} }
public enum InOut_Roller_Mode public enum InOut_Roller_Mode
{ {
......
...@@ -52,6 +52,7 @@ namespace OnlineStore.Common ...@@ -52,6 +52,7 @@ namespace OnlineStore.Common
out_store_wait_string_ready, out_store_wait_string_ready,
in_store_detect_material, in_store_detect_material,
wait_reel_transfer, wait_reel_transfer,
sensor_alarm,
reset_press, reset_press,
reset_press_with_sudden, reset_press_with_sudden,
runbtn_press, runbtn_press,
...@@ -144,5 +145,6 @@ namespace OnlineStore.Common ...@@ -144,5 +145,6 @@ namespace OnlineStore.Common
temp, temp,
outstore_abnormal_reel, outstore_abnormal_reel,
bacth_no_fix, bacth_no_fix,
comInitError,
} }
} }
...@@ -78,6 +78,8 @@ ...@@ -78,6 +78,8 @@
<Compile Include="DeviceLibrary\Camera.cs" /> <Compile Include="DeviceLibrary\Camera.cs" />
<Compile Include="DeviceLibrary\CameraTest.cs" /> <Compile Include="DeviceLibrary\CameraTest.cs" />
<Compile Include="DeviceLibrary\CylinderManger.cs" /> <Compile Include="DeviceLibrary\CylinderManger.cs" />
<Compile Include="DeviceLibrary\dauxiKS107\DauxiKS107Controller.cs" />
<Compile Include="DeviceLibrary\flyelectronicControl\Flyelectronic_485_RGB_Controller.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" /> <Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\IPCamera.cs" /> <Compile Include="DeviceLibrary\IPCamera.cs" />
<Compile Include="DeviceLibrary\I_SafetyDevice.cs" /> <Compile Include="DeviceLibrary\I_SafetyDevice.cs" />
...@@ -89,11 +91,13 @@ ...@@ -89,11 +91,13 @@
<Compile Include="DeviceLibrary\AxisBean.cs" /> <Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="DeviceLibrary\ServerCommunication_AgvProcess.cs" /> <Compile Include="DeviceLibrary\ServerCommunication_AgvProcess.cs" />
<Compile Include="DeviceLibrary\VisionHelper.cs" /> <Compile Include="DeviceLibrary\VisionHelper.cs" />
<Compile Include="DeviceLibrary\weightSensor\OKLE_WeightSensor.cs" />
<Compile Include="TestRoi.cs" /> <Compile Include="TestRoi.cs" />
<Compile Include="theMachine\BoxTransport.cs" /> <Compile Include="theMachine\BoxTransport.cs" />
<Compile Include="theMachine\Common.cs" /> <Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\JobList.cs" /> <Compile Include="theMachine\JobList.cs" />
<Compile Include="theMachine\LabelParam.cs" /> <Compile Include="theMachine\LabelParam.cs" />
<Compile Include="theMachine\MainMachine _LedRGBProcess.cs" />
<Compile Include="theMachine\MainMachine_AGV.cs" /> <Compile Include="theMachine\MainMachine_AGV.cs" />
<Compile Include="theMachine\MainMachine_ServerControl.cs" /> <Compile Include="theMachine\MainMachine_ServerControl.cs" />
<Compile Include="theMachine\MainMachine _BtnProcess.cs" /> <Compile Include="theMachine\MainMachine _BtnProcess.cs" />
...@@ -172,5 +176,6 @@ ...@@ -172,5 +176,6 @@
<ItemGroup> <ItemGroup>
<WCFMetadata Include="Connected Services\" /> <WCFMetadata Include="Connected Services\" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file \ No newline at end of file
...@@ -27,11 +27,13 @@ namespace DeviceLibrary ...@@ -27,11 +27,13 @@ namespace DeviceLibrary
public event Func<int, int, (bool, string)> interference; public event Func<int, int, (bool, string)> interference;
public string AxisName; public string AxisName;
public bool ForceSafeCheck = false; public bool ForceSafeCheck = false;
public AxisBean(ConfigMoveAxis axisConfig, string deviceName) public int maxSensorValue = 0;
public AxisBean(ConfigMoveAxis axisConfig, string deviceName, int maxSensorValue = 0)
{ {
this.Config = axisConfig; this.Config = axisConfig;
AxisName = deviceName + " " + Config.Explain + "[" + Config.DeviceName + "-" + Config.GetAxisValue() + "]"; AxisName = deviceName + " " + Config.Explain + "[" + Config.DeviceName + "-" + Config.GetAxisValue() + "]";
List.Add(this); List.Add(this);
this.maxSensorValue = maxSensorValue;
} }
public bool Open(bool isCheck, out string Msg) public bool Open(bool isCheck, out string Msg)
...@@ -203,7 +205,7 @@ namespace DeviceLibrary ...@@ -203,7 +205,7 @@ namespace DeviceLibrary
return true; return true;
} }
//判断是否需要重新运动 //判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0) if (MoveInfo.CanWhileCount > 0 && CanRMove(axis))
{ {
string clearMsg = ""; string clearMsg = "";
//判断轴是否报警 //判断轴是否报警
...@@ -256,7 +258,7 @@ namespace DeviceLibrary ...@@ -256,7 +258,7 @@ namespace DeviceLibrary
return true; return true;
} }
//判断是否需要重新运动 //判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0) if (MoveInfo.CanWhileCount > 0 && CanRMove(axis))
{ {
LogUtil.error(MoveInfo.Name + axis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次"); LogUtil.error(MoveInfo.Name + axis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点"); //LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
...@@ -371,33 +373,91 @@ namespace DeviceLibrary ...@@ -371,33 +373,91 @@ namespace DeviceLibrary
} }
public void MonitorAxisLoadRate(float maxloadrate) public void MonitorAxisLoadRate(float maxloadrate)
{ {
//Task.Run(() =>
//{
// Task.Delay(200).Wait();
// LogUtil.info($"{AxisName}-开始负载监控,最大负载阈值:{maxloadrate}");
// List<float> loadrate = new List<float>();
// while (IsBusy)
// {
// var loadval = ((HCAxisManager)AxisManager.instance).GetAxisLoadRate(Config.DeviceName, Config.GetAxisValue());
// loadrate.Add(loadval);
// if (loadval > maxloadrate)
// {
// LogUtil.info($"{AxisName}-{loadval}>{maxloadrate}超过负载,系统急停");
// SuddenStop();
// Msg.add(AxisName + "-超过负载,系统急停", MsgLevel.alarm, ErrInfo.SuddenStop);
// break;
// }
// Task.Delay(50).Wait();
// }
// if (loadrate.Count > 5)
// {
// loadrate.Sort();
// int middleIndex = loadrate.Count / 2;
// LogUtil.info($"{AxisName}-本次负载监控:最小值:{loadrate.Min()}, 平均值:{loadrate.Average()}, 最大值{loadrate.Max()},中位数:{loadrate[middleIndex]}, 最大阈值:{maxloadrate}");
// }
//});
}
private static bool CanRMove(ConfigMoveAxis axis)
{
string AxisName = axis.GetNameStr();
try
{
//判断是否进出轴
if (RobotManage.mainMachine.InOut_Axis.Config.IsSameAxis(axis.DeviceName,axis.GetAxisValue()))
{
int maxSensorValue = Setting_Init.Device_WeightSensor_MaxValue;
if (Setting_Init.Device_WeightSensor_PortName == "" || RobotManage.oKLE_WeightSensor == null || (!RobotManage.oKLE_WeightSensor.IsPortOpen))
{
return true;
}
double value = RobotManage.oKLE_WeightSensor.GetWeight();
double maxV = RobotManage.oKLE_WeightSensor.PeakWeight();
bool canRM = true;
if (value >= maxSensorValue || maxV >= maxSensorValue)
{
canRM = false;
}
LogUtil.info($"{AxisName}-压力传感器当前值:{value} ,峰值:{maxV},上限值:{maxSensorValue}, 是否能重复运动:{canRM}");
return canRM;
}
}
catch (Exception ex)
{
LogUtil.error($"{AxisName}CanRMove 出错:" + ex.ToString());
return false;
}
return true;
}
public void SensorDetection(float maxValue)
{
if(Setting_Init.Device_WeightSensor_PortName==""|| RobotManage.oKLE_WeightSensor==null|| (!RobotManage.oKLE_WeightSensor.IsPortOpen))
{
return;
}
Task.Run(() => Task.Run(() =>
{ {
Task.Delay(200).Wait(); Task.Delay(200).Wait();
LogUtil.info($"{AxisName}-开始负载监控,最大负载阈值:{maxloadrate}"); LogUtil.info($"{AxisName}-压力传感器开始检测,配置最大值:{maxValue}");
List<float> loadrate = new List<float>(); List<double> loadrate = new List<double>();
while (IsBusy) while (IsBusy)
{ {
var loadval = ((HCAxisManager)AxisManager.instance).GetAxisLoadRate(Config.DeviceName, Config.GetAxisValue()); double value = RobotManage.oKLE_WeightSensor.GetWeight();
loadrate.Add(loadval); double maxV = RobotManage.oKLE_WeightSensor.PeakWeight();
if (loadval > maxloadrate)
{ loadrate.Add(value);
LogUtil.info($"{AxisName}-{loadval}>{maxloadrate}超过负载,系统急停"); LogUtil.info($"{AxisName}-压力传感器当前值:{value},上限值:{maxValue}");
SuddenStop();
Msg.add(AxisName + "-超过负载,系统急停", MsgLevel.alarm, ErrInfo.SuddenStop);
break;
}
Task.Delay(50).Wait(); Task.Delay(50).Wait();
} }
if (loadrate.Count > 5) if (loadrate.Count > 5)
{ {
loadrate.Sort(); loadrate.Sort();
int middleIndex = loadrate.Count / 2; int middleIndex = loadrate.Count / 2;
LogUtil.info($"{AxisName}-本次负载监控:最小值:{loadrate.Min()}, 平均值:{loadrate.Average()}, 最大值{loadrate.Max()},中位数:{loadrate[middleIndex]}, 最大阈值:{maxloadrate}"); LogUtil.info($"{AxisName}-本次压力传感器监控:最小值:{loadrate.Min()}, 平均值:{loadrate.Average()}, 最大值{loadrate.Max()},中位数:{loadrate[middleIndex]}, 最大阈值:{maxValue}");
} }
}); });
} }
#region 匀速上升处理 #region 匀速上升处理
private System.Timers.Timer axisCheckTimer = null; private System.Timers.Timer axisCheckTimer = null;
internal string TargetIoType = ""; internal string TargetIoType = "";
......
using OnlineStore.Common;
using OnlineStore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class DauxiKS107Controller
{
private static int baudRate = 9600;//波特率
private static Parity parity = Parity.None;//校验位
private static int dataBits = 8;//数据位
private static StopBits stopBits = StopBits.One; //停止位
private SerialPort _serialPort = null;
string comPortName;
System.Timers.Timer timer;
public volatile int Distance;
public bool IsRunning { get => timer.Enabled; }
public DauxiKS107Controller(int Elapsms = 5000)
{
timer = new System.Timers.Timer(Elapsms);
timer.Elapsed += Timer_Elapsed;
timer.AutoReset = true;
timer.Enabled = false;
}
~DauxiKS107Controller()
{
LogUtil.info($"{comPortName}声波传感器退出");
timer.Enabled = false;
_serialPort?.Close();
}
List<int> distantlist = new List<int>() { 1000, 100, 100, 100, 10 };
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
bool readok = true;
for (int i = 0; i < 5; i++)
{
if (Quary(out int value, out string errmsg))
{
LogUtil.info($"{comPortName}读取到声波距离:{value}mm,err:{errmsg}");
readok = true;
if (value > 0 && value < 1000)
{
//Distance = value;
lock (distantlist)
{
distantlist.Add(value);
if (distantlist.Count > 8)
{
distantlist.RemoveAt(0);
}
Distance = TrimMean(distantlist, 0.8);
}
return;
}
else
readok = false;
}
else
{
readok = false;
}
}
if (!readok)
{
LogUtil.info($"{comPortName}声波传感器读取失败,重新打开");
if (!OpenPort(comPortName, out string errmsg))
{
LogUtil.info($"{comPortName}声波传感器打开失败:" + errmsg);
}
}
}
/// <summary>
/// 打开串口资源
/// <returns>返回bool类型</returns>
/// </summary>
public bool OpenPort(string _comport, out string errmsg)
{
comPortName = _comport;
//如果串口是打开的,先关闭
errmsg = "";
if (_serialPort == null)
{
try
{
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
_serialPort.RtsEnable = true; //自动请求
_serialPort.ReadTimeout = 100;//超时
LogUtil.info("声波传感器" + comPortName + "打开成功");
}
catch (Exception e)
{
errmsg += crc.GetString("comOpenFail", "串口{0}打开失败", _comport);
LogUtil.info("串口"+_comport+"打开失败:" + e.ToString());
return false;
}
}
//errmsg += crc.GetString("Res0095.e19bb66e", "初始化.");
if (_serialPort.IsOpen)
_serialPort.Close();
bool ok = false;
try
{
//打开串口
//errmsg += $"打开串口:{comPortName}.";
_serialPort.Open();
LogUtil.info(_comport + "声波传感器端口打开成功" );
Thread.Sleep(200);
for (int i = 1; i < 10; i++)
{
Thread.Sleep(100);
//errmsg += crc.GetString("Res0096.184519ba", "检测数据.");
Quary(out int value, out string err);
//errmsg += err;
LogUtil.info(_comport + "声波传感器检测数据结果:"+value+"/" + err);
if (value > 0)
{
timer.Enabled = true;
ok = true;
break;
}
}
}
catch (Exception Ex)
{
errmsg += Ex.ToString();
//throw Ex;
}
return ok;
}
public bool PortIsOpen()
{
return (_serialPort != null) && (_serialPort.IsOpen);
}
public bool ClosePort()
{
if(_serialPort!=null&&_serialPort.IsOpen)
{
_serialPort.Close();
}
return true;
}
static byte[] quarycommand = new byte[] { 0xe8, 0x02, 0xb0 };
public bool Quary(out int value, out string errmsg)
{
errmsg = "";
byte[] buf = new byte[8];
value = 0;
try
{
_serialPort.Write(quarycommand, 0, quarycommand.Length);
Thread.Sleep(80);
var readlen = _serialPort.Read(buf, 0, buf.Length);
if (readlen == 2)
{
var c = new byte[] { buf[1], buf[0] };
value = (int)BitConverter.ToUInt16(c, 0);
}
else
{
errmsg += crc.GetString("comDataError", "串口{0}数据错误{1}", _serialPort.PortName, BitConverter.ToString(buf));
LogUtil.error( $"{comPortName}返回数据不正确:" + BitConverter.ToString(buf));
return false;
}
}
catch (Exception ex)
{
errmsg = ex.ToString();
return false;
}
return true;
}
public static int TrimMean(List<int> array, double percent)
{
try
{
if (array.Count < 4)
{
return array[0];
}
List<int> templist = new List<int>(array);
templist.Sort();
templist.RemoveAt(0);
templist.RemoveAt(0);
templist.RemoveAt(templist.Count - 1);
templist.RemoveAt(templist.Count - 1);
return (int)templist.Average();
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
return 0;
}
}
}
}
...@@ -159,7 +159,8 @@ namespace DeviceLibrary ...@@ -159,7 +159,8 @@ namespace DeviceLibrary
case MoveStep.StoreTS06: case MoveStep.StoreTS06:
MoveInfo.NextMoveStep(MoveStep.StoreTS07); MoveInfo.NextMoveStep(MoveStep.StoreTS07);
InOut_Axis.AbsMove(MoveInfo, From.InOut_P2, Config.InOut_P2_speed); InOut_Axis.AbsMove(MoveInfo, From.InOut_P2, Config.InOut_P2_speed);
InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate); //InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate);
InOut_Axis.SensorDetection(Setting_Init.Device_WeightSensor_MaxValue);
MoveInfo.log($"{storeMoveType}:进出轴去取料点P2【{From.InOut_P2}】【{Config.InOut_P2_speed}】"); MoveInfo.log($"{storeMoveType}:进出轴去取料点P2【{From.InOut_P2}】【{Config.InOut_P2_speed}】");
break; break;
case MoveStep.StoreTS07: case MoveStep.StoreTS07:
...@@ -202,20 +203,30 @@ namespace DeviceLibrary ...@@ -202,20 +203,30 @@ namespace DeviceLibrary
MoveInfo.log($"{storeMoveType}:旋转轴去取料点P2【{Fix.Middle_P2}】【{Config.Middle_P2_speed}】"); MoveInfo.log($"{storeMoveType}:旋转轴去取料点P2【{Fix.Middle_P2}】【{Config.Middle_P2_speed}】");
UpDown_Axis.AbsMove(MoveInfo, Fix.UpDown_PH, Config.UpDown_P1_speed); UpDown_Axis.AbsMove(MoveInfo, Fix.UpDown_PH, Config.UpDown_P1_speed);
MoveInfo.log($"{storeMoveType}:升降轴去取料高点【{Fix.UpDown_PH}】【{Config.UpDown_P1_speed}】"); MoveInfo.log($"{storeMoveType}:升降轴去取料高点【{Fix.UpDown_PH}】【{Config.UpDown_P1_speed}】");
SensorProcess();
break; break;
case MoveStep.StoreFIX02: case MoveStep.StoreFIX02:
MoveInfo.NextMoveStep(MoveStep.StoreFIX03); MoveInfo.NextMoveStep(MoveStep.StoreFIX03);
InOut_Axis.AbsMove(MoveInfo, Fix.InOut_P2, Config.InOut_P2_speed); InOut_Axis.AbsMove(MoveInfo, Fix.InOut_P2, Config.InOut_P2_speed);
InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate); //InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate);
InOut_Axis.SensorDetection(Setting_Init.Device_WeightSensor_MaxValue);
MoveInfo.log($"{storeMoveType}:进出轴去取料点【{Fix.InOut_P2}】【{Config.InOut_P2_speed}】"); MoveInfo.log($"{storeMoveType}:进出轴去取料点【{Fix.InOut_P2}】【{Config.InOut_P2_speed}】");
break; break;
case MoveStep.StoreFIX03: case MoveStep.StoreFIX03:
RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.ToFix)); bool sCheck= SensorProcess();
MoveInfo.NextMoveStep(MoveStep.StoreFIX04); if (!sCheck)
Comp_Axis.AbsMove(MoveInfo, Fix.Comp_PH, Config.Comp_P2_speed); {
MoveInfo.log($"{storeMoveType}:压紧轴去压紧高点【{Fix.Comp_PH}】【{Config.Comp_P2_speed}】");
UpDown_Axis.AbsMove(MoveInfo, Fix.UpDown_PL, Config.UpDown_P3_speed / 2); }
MoveInfo.log($"{storeMoveType}:升降轴去取料低点【{Fix.UpDown_PL}】【{Config.UpDown_P3_speed / 2}】");
RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.ToFix));
MoveInfo.NextMoveStep(MoveStep.StoreFIX04);
Comp_Axis.AbsMove(MoveInfo, Fix.Comp_PH, Config.Comp_P2_speed);
MoveInfo.log($"{storeMoveType}:压紧轴去压紧高点【{Fix.Comp_PH}】【{Config.Comp_P2_speed}】");
UpDown_Axis.AbsMove(MoveInfo, Fix.UpDown_PL, Config.UpDown_P3_speed / 2);
MoveInfo.log($"{storeMoveType}:升降轴去取料低点【{Fix.UpDown_PL}】【{Config.UpDown_P3_speed / 2}】");
break; break;
case MoveStep.StoreFIX04: case MoveStep.StoreFIX04:
...@@ -278,7 +289,8 @@ namespace DeviceLibrary ...@@ -278,7 +289,8 @@ namespace DeviceLibrary
case MoveStep.StoreFIX04_05_DownToFixLow: case MoveStep.StoreFIX04_05_DownToFixLow:
MoveInfo.NextMoveStep(MoveStep.StoreFIX04_06_InoutToPos); MoveInfo.NextMoveStep(MoveStep.StoreFIX04_06_InoutToPos);
InOut_Axis.AbsMove(MoveInfo, Fix.InOut_P2, Config.InOut_P2_speed); InOut_Axis.AbsMove(MoveInfo, Fix.InOut_P2, Config.InOut_P2_speed);
InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate); //InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate);
InOut_Axis.SensorDetection(Setting_Init.Device_WeightSensor_MaxValue);
MoveInfo.log($"{storeMoveType}:进出轴去取料点P2【{Fix.InOut_P2}】【{Config.InOut_P2_speed}】"); MoveInfo.log($"{storeMoveType}:进出轴去取料点P2【{Fix.InOut_P2}】【{Config.InOut_P2_speed}】");
break; break;
case MoveStep.StoreFIX04_06_InoutToPos: case MoveStep.StoreFIX04_06_InoutToPos:
...@@ -352,7 +364,8 @@ namespace DeviceLibrary ...@@ -352,7 +364,8 @@ namespace DeviceLibrary
case MoveStep.StoreTS12: case MoveStep.StoreTS12:
MoveInfo.NextMoveStep(MoveStep.StoreTS13); MoveInfo.NextMoveStep(MoveStep.StoreTS13);
InOut_Axis.AbsMove(MoveInfo, To.InOut_P2, Config.InOut_P2_speed); InOut_Axis.AbsMove(MoveInfo, To.InOut_P2, Config.InOut_P2_speed);
InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate); //InOut_Axis.MonitorAxisLoadRate(Setting_Init.LoadRateLimit_InOutMaxLoadRate);
InOut_Axis.SensorDetection(Setting_Init.Device_WeightSensor_MaxValue);
MoveInfo.log($"{storeMoveType}:进出轴去取料点P2【{To.InOut_P2}】【{Config.InOut_P2_speed}】"); MoveInfo.log($"{storeMoveType}:进出轴去取料点P2【{To.InOut_P2}】【{Config.InOut_P2_speed}】");
break; break;
case MoveStep.StoreTS13: case MoveStep.StoreTS13:
...@@ -447,5 +460,47 @@ namespace DeviceLibrary ...@@ -447,5 +460,47 @@ namespace DeviceLibrary
// //return pos > 0 ? RobotManage.CameraA : RobotManage.CameraB; // //return pos > 0 ? RobotManage.CameraA : RobotManage.CameraB;
// return RobotManage.CameraA; // return RobotManage.CameraA;
//} //}
/// <summary>
/// 返回ture表示没问题,返回false需要报警
/// </summary>
/// <returns></returns>
private bool SensorProcess()
{
try
{
if (Setting_Init.Device_DauxiKS107_PortName == "" || RobotManage.dauxiKS107Controller == null || RobotManage.dauxiKS107Controller.PortIsOpen ()== false)
{
return true ;
}
if (RobotManage.dauxiKS107Controller.Quary(out int value, out string errMsg))
{
int cha = value - Setting_Init.Device_DauxiKS107_BaseValue;
if (cha > Setting_Init.Device_DauxiKS107_ErrorValue)
{
TimeSpan span = DateTime.Now - RobotManage.LastResetTime;
RobotManage.SensorNeedReset = true;
if (span.TotalHours > 1)
{
LogUtil.error($"传感器误差过大,需要复位:当前值:{value},基准值:{Setting_Init.Device_DauxiKS107_BaseValue},SensorErroCount={RobotManage.SensorNeedReset}, 最大误差:{Setting_Init.Device_DauxiKS107_ErrorValue}," +
$"上次复位时间{RobotManage.LastResetTime.ToShortDateString()},一小时内出现红外传感器检测错误,需要报警");
RobotManage.SensorNeedAlarm = true;
return false;
}
else
{
LogUtil.error($"传感器误差过大,需要复位:当前值:{value},基准值:{Setting_Init.Device_DauxiKS107_BaseValue},SensorErroCount={RobotManage.SensorNeedReset},最大误差:{Setting_Init.Device_DauxiKS107_ErrorValue}");
}
}
}
}
catch (Exception ex)
{
LogUtil.error("SensorProcess 出错:" + ex.ToString());
}
return true;
}
} }
} }
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using static System.Windows.Forms.AxHost;
namespace DeviceLibrary
{
partial class MainMachine
{
private Flyelectronic_485_RGB_Controller rGB_Controller = null;
private bool rgbLedInitOk = false;
public string lastColor = "";
System.Threading.Timer ledRgbTimer;
public bool CloseRgbLed()
{
if(rgbLedInitOk)
{
rGB_Controller.Dispose();
}
return true;
}
public bool InitRgbLed(out string msg)
{
msg = "";
string port = Setting_Init.Device_LedLight_PortName;
if (port == "")
{
LogUtil.info( "未配置LED灯端口号");
return false;
}
rGB_Controller = new Flyelectronic_485_RGB_Controller("LED");
bool result = rGB_Controller.OpenPort(port, out msg);
if (result)
{
LogUtil.error("LED灯初始化成功");
rgbLedInitOk = true;
ledRgbTimer = new System.Threading.Timer(new TimerCallback(RgbLedProcess), null, 0, 1000);
GC.KeepAlive(ledtimer);
msg = "";
return true;
}
else
{
LogUtil.error("LED灯初始化失败:" + msg);
}
return false;
}
private void ShowColor(Color color)
{
if (lastColor.Equals(color.ToArgb().ToString()))
{
return;
}
rGB_Controller.CloseLed();
rGB_Controller.ShowColor(color);
}
private void RgbLedProcess(object o)
{
if (rGB_Controller == null || (!rgbLedInitOk))
{
return;
}
// 红色: 急停,
//紫色: 异常,
//蓝绿: 待机
//流动绿: 入库
//流动黄: 出库,
//白色: 等待用户响应(等待取走盘等),
//蓝色: 扫码检测
if (runStatus == RunStatus.Stop)
{
//未启动 黑色
ShowColor(Color.Black);
}
else if (isInSuddenDown)
{
//红色: 急停,
ShowColor(Color.Red);
}
else if (hasAlarm)
{
//紫色: 异常,
ShowColor(Color.Purple);
} //温度超限
else if (IsTHoutRange())
{
//紫色: 异常,
ShowColor(Color.Purple);
}
//温度超限30分钟
else if (IsTHoutRangeOver30m())
{
//紫色: 异常,
ShowColor(Color.Purple);
}
else if (runStatus == RunStatus.Running)
{
var h = NGDoor_Tray_Test_Reel;
if (h != null && h.Value)
{
//等待料盘拿走
//白色: 等待用户响应(等待取走盘等),
//蓝色: 扫码检测
ShowColor(Color.White);
}
else if (ClampMoveInfo.IsStep(MoveStep.ReelClamp_10) && (!RobotManage.InoutDebugMode) && (!ClampMoveInfo.MoveParam.IsNg))
{
//蓝色: 扫码检测
ShowColor(Color.Blue);
}
//出入库 绿闪 黄闪
else if (StoreMoveInfo.MoveStep >= MoveStep.StoreOut10)
{
//流动黄: 出库,
if (lastColor.Equals("yellowRun"))
{
return;
}
rGB_Controller.CloseLed();
rGB_Controller.ShowYellowLight();
}
else if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn01)
{
//流动绿: 入库
if (lastColor.Equals("yellowRun"))
{
return;
}
rGB_Controller.CloseLed();
rGB_Controller.ShowYellowLight();
}
}
else
{
//待机 蓝绿
ShowColor(Color.FromArgb(0, 128, 128));
}
}
}
}
...@@ -355,6 +355,7 @@ namespace DeviceLibrary ...@@ -355,6 +355,7 @@ namespace DeviceLibrary
IOMove(IO_Type.LineRun, IO_VALUE.LOW); IOMove(IO_Type.LineRun, IO_VALUE.LOW);
IOMove(IO_Type.LineRev, IO_VALUE.LOW); IOMove(IO_Type.LineRev, IO_VALUE.LOW);
LedProcess(null); LedProcess(null);
RgbLedProcess("");
SoundsController.StopPlay(); SoundsController.StopPlay();
LogUtil.info("开始停止系统3."); LogUtil.info("开始停止系统3.");
} }
...@@ -370,7 +371,8 @@ namespace DeviceLibrary ...@@ -370,7 +371,8 @@ namespace DeviceLibrary
Alarm(AlarmType.None); Alarm(AlarmType.None);
runStatus = RunStatus.HomeReset; runStatus = RunStatus.HomeReset;
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset); ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
ResetMoveInfo.log("开始回原"); ResetMoveInfo.log("开始回原,记录最后一次回原时间");
RobotManage.LastResetTime = DateTime.Now;
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000)); ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
} }
......
...@@ -223,10 +223,30 @@ namespace DeviceLibrary ...@@ -223,10 +223,30 @@ namespace DeviceLibrary
ReelPutted(StoreMoveInfo.MoveParam.PlateH); ReelPutted(StoreMoveInfo.MoveParam.PlateH);
OutStoreJobList.ClearLastPosid(StoreMoveInfo.MoveParam.PosID); OutStoreJobList.ClearLastPosid(StoreMoveInfo.MoveParam.PosID);
} }
if (RobotManage.SensorNeedAlarm)
{
//需要报警
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut20);
StoreMoveInfo.log($"红外传感器偏差过大,需要检查后复位");
}
else if(RobotManage.SensorNeedReset)
{
//需要复位
StoreMoveInfo.log($"红外传感器偏差过大,开始复位系统");
RobotManage.SensorNeedReset = false;
BeginHomeReset();
}
else
{
StoreMoveInfo.EndMove(); StoreMoveInfo.EndMove();
}
} }
break; break;
case MoveStep.StoreOut20:
Msg.add(crc.GetString(L.sensor_alarm, "红外传感器偏差过大,需要检查后复位."), MsgLevel.info);
break;
default: default:
StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}"); StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
break; break;
......
...@@ -133,6 +133,7 @@ namespace DeviceLibrary ...@@ -133,6 +133,7 @@ namespace DeviceLibrary
StoreOut16, StoreOut16,
StoreOut17, StoreOut17,
StoreOut18, StoreOut18,
StoreOut20,//红外传感器报警
StoreTS01, StoreTS01,
StoreTS02, StoreTS02,
......
...@@ -59,6 +59,14 @@ namespace DeviceLibrary ...@@ -59,6 +59,14 @@ namespace DeviceLibrary
public static HIKCamera CameraA = new HIKCamera(); public static HIKCamera CameraA = new HIKCamera();
public static DauxiKS107Controller dauxiKS107Controller = null;
public static OKLE_WeightSensor oKLE_WeightSensor =null;
public static bool SensorNeedReset = false ;
public static bool SensorNeedAlarm = false;
public static DateTime LastResetTime = DateTime.Now;
public static void Init(params object[] param) public static void Init(params object[] param)
{ {
string msg = ""; string msg = "";
...@@ -116,6 +124,37 @@ namespace DeviceLibrary ...@@ -116,6 +124,37 @@ namespace DeviceLibrary
IsLoadOk = false; IsLoadOk = false;
msg += crc.GetString(L.tempnhum_sensor_init_fail, $"温湿度传感器初始化失败,端口:") + $"{Setting_Init.App_Humiture_Port}\n"; msg += crc.GetString(L.tempnhum_sensor_init_fail, $"温湿度传感器初始化失败,端口:") + $"{Setting_Init.App_Humiture_Port}\n";
} }
if (!mainMachine.InitRgbLed(out string LedMsg))
{
if (LedMsg != "")
{
msg += LedMsg + "\n";
}
}
if (Setting_Init.Device_DauxiKS107_PortName != "")
{
dauxiKS107Controller = new DauxiKS107Controller();
if(!dauxiKS107Controller.OpenPort(Setting_Init.Device_DauxiKS107_PortName,out string dauxiMsg))
{
if (dauxiMsg != "")
{
msg += dauxiMsg + "\n";
}
}
}
if (Setting_Init.Device_WeightSensor_PortName != "")
{
oKLE_WeightSensor = new OKLE_WeightSensor();
if (!oKLE_WeightSensor.Open(Setting_Init.Device_WeightSensor_PortName, out string sensorMsg))
{
if (sensorMsg != "")
{
msg += sensorMsg + "\n";
}
}
}
//Thread.Sleep(1000); //Thread.Sleep(1000);
//if (!IOManager.ConnectionIOList(new List<string>())) //if (!IOManager.ConnectionIOList(new List<string>()))
//{ //{
...@@ -181,6 +220,15 @@ namespace DeviceLibrary ...@@ -181,6 +220,15 @@ namespace DeviceLibrary
LogUtil.info("开始关闭系统."); LogUtil.info("开始关闭系统.");
IOManager.CloseAllConnection(); IOManager.CloseAllConnection();
CameraA.stopCamera(); CameraA.stopCamera();
mainMachine.CloseRgbLed();
if(oKLE_WeightSensor!= null)
{
oKLE_WeightSensor.Close();
}
if(dauxiKS107Controller!= null)
{
dauxiKS107Controller.ClosePort();
}
} }
public static bool IsUserPause public static bool IsUserPause
{ {
......
...@@ -29,9 +29,14 @@ namespace TheMachine ...@@ -29,9 +29,14 @@ namespace TheMachine
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.lblLed = new System.Windows.Forms.Label();
this.lblOkValue = new System.Windows.Forms.Label();
this.lblSensor = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.axisMoveControl1 = new DeviceLibrary.AxisMoveControl(); this.axisMoveControl1 = new DeviceLibrary.AxisMoveControl();
this.configControl1 = new TheMachine.ConfigControl(); this.configControl1 = new TheMachine.ConfigControl();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
...@@ -40,6 +45,9 @@ namespace TheMachine ...@@ -40,6 +45,9 @@ namespace TheMachine
// panel1 // panel1
// //
this.panel1.AutoScroll = true; this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.lblLed);
this.panel1.Controls.Add(this.lblOkValue);
this.panel1.Controls.Add(this.lblSensor);
this.panel1.Controls.Add(this.button3); this.panel1.Controls.Add(this.button3);
this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button2);
this.panel1.Controls.Add(this.axisMoveControl1); this.panel1.Controls.Add(this.axisMoveControl1);
...@@ -50,6 +58,30 @@ namespace TheMachine ...@@ -50,6 +58,30 @@ namespace TheMachine
this.panel1.Size = new System.Drawing.Size(1234, 924); this.panel1.Size = new System.Drawing.Size(1234, 924);
this.panel1.TabIndex = 2; this.panel1.TabIndex = 2;
// //
// lblLed
//
this.lblLed.AutoSize = true;
this.lblLed.Location = new System.Drawing.Point(38, 621);
this.lblLed.Name = "lblLed";
this.lblLed.Size = new System.Drawing.Size(0, 12);
this.lblLed.TabIndex = 16;
//
// lblOkValue
//
this.lblOkValue.AutoSize = true;
this.lblOkValue.Location = new System.Drawing.Point(38, 578);
this.lblOkValue.Name = "lblOkValue";
this.lblOkValue.Size = new System.Drawing.Size(0, 12);
this.lblOkValue.TabIndex = 15;
//
// lblSensor
//
this.lblSensor.AutoSize = true;
this.lblSensor.Location = new System.Drawing.Point(38, 539);
this.lblSensor.Name = "lblSensor";
this.lblSensor.Size = new System.Drawing.Size(0, 12);
this.lblSensor.TabIndex = 14;
//
// button3 // button3
// //
this.button3.Location = new System.Drawing.Point(38, 481); this.button3.Location = new System.Drawing.Point(38, 481);
...@@ -70,6 +102,11 @@ namespace TheMachine ...@@ -70,6 +102,11 @@ namespace TheMachine
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click); this.button2.Click += new System.EventHandler(this.button2_Click);
// //
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// axisMoveControl1 // axisMoveControl1
// //
this.axisMoveControl1.Location = new System.Drawing.Point(3, 3); this.axisMoveControl1.Location = new System.Drawing.Point(3, 3);
...@@ -97,6 +134,7 @@ namespace TheMachine ...@@ -97,6 +134,7 @@ namespace TheMachine
this.Size = new System.Drawing.Size(1234, 924); this.Size = new System.Drawing.Size(1234, 924);
this.Load += new System.EventHandler(this.AxisControl_Load); this.Load += new System.EventHandler(this.AxisControl_Load);
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
...@@ -108,5 +146,9 @@ namespace TheMachine ...@@ -108,5 +146,9 @@ namespace TheMachine
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label lblSensor;
private System.Windows.Forms.Label lblLed;
private System.Windows.Forms.Label lblOkValue;
private System.Windows.Forms.Timer timer1;
} }
} }
...@@ -47,6 +47,7 @@ namespace TheMachine ...@@ -47,6 +47,7 @@ namespace TheMachine
axisMoveControl1.LoadData(AxisBean.List); axisMoveControl1.LoadData(AxisBean.List);
configControl1.Config = RobotManage.Config; configControl1.Config = RobotManage.Config;
LogUtil.info("伺服面板加载完成."); LogUtil.info("伺服面板加载完成.");
timer1.Start();
} }
...@@ -120,5 +121,47 @@ namespace TheMachine ...@@ -120,5 +121,47 @@ namespace TheMachine
{ {
roateloop = false; roateloop = false;
} }
private void timer1_Tick(object sender, EventArgs e)
{
if (!this.Visible)
{
return;
}
try
{
if (Setting_Init.Device_LedLight_PortName != "")
{
lblLed.Text ="LED"+ Setting_Init.Device_LedLight_PortName+":"+ RobotManage.mainMachine.lastColor.ToString();
}
else
{
lblLed.Text = "";
}
if (Setting_Init.Device_DauxiKS107_PortName != "")
{
RobotManage.dauxiKS107Controller.Quary(out int currValue, out string msg);
lblSensor.Text = $"红外传感器{Setting_Init.Device_DauxiKS107_PortName}:" + currValue + ", /" + Setting_Init.Device_DauxiKS107_BaseValue + "/" + Setting_Init.Device_DauxiKS107_ErrorValue;
}
else
{
lblSensor.Text = "";
}
if (Setting_Init.Device_WeightSensor_PortName != "")
{
lblOkValue.Text = $"压力传感器{Setting_Init.Device_WeightSensor_PortName}: {Setting_Init.Device_WeightSensor_MaxValue}";
}
else
{
lblOkValue.Text = "";
}
}
catch(Exception ex)
{
LogUtil.error("出错:" + ex.ToString());
}
}
} }
} }
...@@ -117,4 +117,7 @@ ...@@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -278,6 +278,12 @@ ...@@ -278,6 +278,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="icon.ico" /> <Content Include="icon.ico" />
<EmbeddedResource Include="ledColor\green.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="ledColor\yellow.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<Content Include="更新记录.txt" /> <Content Include="更新记录.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -424,4 +424,8 @@ Res0225 关 Switch to Low ...@@ -424,4 +424,8 @@ Res0225 关 Switch to Low
Res0226 开 Switch to High Res0226 开 Switch to High
flashing 闪烁 Flashing flashing 闪烁 Flashing
save_success 保存成功 Save success save_success 保存成功 Save success
save_failed 保存失败 Save failed
\ No newline at end of file \ No newline at end of file
save_failed 保存失败 Save failed
sensor_alarm 红外传感器偏差过大,需要检查后复位 Infrared sensor deviation is too large, need to check and then reset
comInitError {0}初始化失败 {0}Initialization failure
comDataError 串口{0}数据错误{1} Serial port {0} data error {1}
comOpenFail 串口{0}打开失败 Serial port {0} open failed
...@@ -426,4 +426,8 @@ Res0225 关 閉める ...@@ -426,4 +426,8 @@ Res0225 关 閉める
Res0226 开 開ける Res0226 开 開ける
flashing 闪烁 ヴラド flashing 闪烁 ヴラド
save_success 保存成功 保存は成功しました save_success 保存成功 保存は成功しました
save_failed 保存失败 保存に失敗しました
\ No newline at end of file \ No newline at end of file
save_failed 保存失败 保存に失敗しました
sensor_alarm 红外传感器偏差过大,需要检查后复位 赤外線センサーのずれが大きすぎる
comInitError {0}初始化失败 {0}初期化に失敗しました
comDataError 串口{0}数据错误{1} シリアルポート {0} データエラー {1}
comOpenFail 串口{0}打开失败 シリアルポート {0} のオープンに失敗
...@@ -411,4 +411,8 @@ Res0225 关 关 ...@@ -411,4 +411,8 @@ Res0225 关 关
Res0226 开 开 Res0226 开 开
flashing 闪烁 闪烁 flashing 闪烁 闪烁
save_success 保存成功 保存成功 save_success 保存成功 保存成功
save_failed 保存失败 保存失败
\ No newline at end of file \ No newline at end of file
save_failed 保存失败 保存失败
sensor_alarm 红外传感器偏差过大,需要报警 红外传感器偏差过大,需要报警
comInitError {0}初始化失败 {0}初始化失败
comDataError 串口{0}数据错误{1} 串口{0}数据错误{1}
comOpenFail 串口{0}打开失败 串口{0}打开失败
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!