Commit 8c7b3fe3 刘韬

1

1 个父辈 a1958cc1
{
"HIKIPCamera": [
{
"Name": "monitorA",
"IP": "192.168.106.21",
"User": "admin",
"Password": "Acc123456",
"Port": 8000
}
]
}
\ No newline at end of file
{
"HIKIPCamera": [
{
"Name": "monitorB",
"IP": "192.168.105.21",
"User": "admin",
"Password": "Acc123456",
"Port": 8000
}
]
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ PRO,50,气压检测超时,AirCheckSeconds,5,,,,,,,,,,,,
PRO,50,扫码相机,CameraName,asdasdasd,,,,,,,,,,,,
PRO,40,入料线体顶升电机速度,InLift_Moto_Speed,10,,,,,,,,,,,,
PRO,40,出料线体顶升电机速度,OutLift_Moto_Speed,10,,,,,,,,,,,,
PRO,40,称重传感器端口,WeightSensorPort,COM1,,,,,,,,,,,,
PRO,40,称重传感器端口,WeightSensorPort,COM5,,,,,,,,,,,,
PRO,40,称重传感器皮重,WeightSensorBase,22,,,,,,,,,,,,
PRO,40,库位最大承重,StoreWeightLimited,30,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
......
......@@ -32,6 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.Camera.VisionLib">
<HintPath>..\..\Camera\CameraVisionLib\bin\Debug\Asa.Camera.VisionLib.dll</HintPath>
</Reference>
<Reference Include="Asa.PrintLabel">
<HintPath>..\..\PrintLabel\PrintLabel\bin\Debug\Asa.PrintLabel.dll</HintPath>
</Reference>
......@@ -73,6 +76,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DeviceLibrary\AcSerialBean.cs" />
<Compile Include="DeviceLibrary\Camera.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\LiftMonitor.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
......@@ -147,6 +151,12 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="Config\CameraB.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Config\CameraA.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="StoreConfig\linePositions.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
using Asa.Camera;
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
public class HIKCamera
{
Thread camerathread;
//static HIKCamera _camera;
Asa.Camera.VisionLib camera;
//public static HIKCamera Current
//{
// get
// {
// if (_camera == null)
// _camera = new HIKCamera();
// return _camera;
// }
//}
public string Name = "";
public event EventHandler<Bitmap> camera_event;
public string DeviceName = "monitor1";
public bool LoadCameraConfig(string CameraID, out string msg)
{
Name = CameraID;
msg = "";
string path = $".\\Config\\{CameraID}.json";
if (!File.Exists(path))
{
msg = Name + "找不到监控相机配置文件";
LogUtil.error(Name + "找不到监控相机配置文件" + path);
return false;
}
try
{
var configtxt = File.ReadAllText(path);
if (configtxt.IndexOf("Pwd") > 0)
{
configtxt = configtxt.Replace("Pwd", "Password");
configtxt = configtxt.Replace("\"8000\"", "8000");
File.WriteAllText(path, configtxt);
}
var m = Regex.Match(configtxt, "name\".*?\"(.+)\"", RegexOptions.IgnoreCase);
DeviceName = m.Groups[1].Value;
camera = new VisionLib(path, true, "HIK.IPCamera");
}
catch (Exception e)
{
msg = Name + "加载监控相机配置文件失败:" + e.ToString();
LogUtil.error(Name + "加载监控相机配置文件失败:" + e.ToString());
return false;
}
camera.Open(DeviceName);
Bitmap bmp = camera.GetImage(DeviceName);
if (bmp == null)
{
msg = Name + $"监控相机打开失败";
LogUtil.error(Name + $"监控相机打开失败");
return false;
}
camerathread = new Thread(new ThreadStart(startCamera));
camerathread.Start();
GC.KeepAlive(camerathread);
return true;
}
int errortimes = 0;
void startCamera()
{
while (true)
{
try
{
Bitmap bmp = camera.GetImage(DeviceName);
if (bmp != null)
{
errortimes = 0;
camera_event?.Invoke(this, bmp);
}
else if (bmp == null && errortimes < 5)
{
errortimes++;
LogUtil.error(Name + $"相机获取图像出错,{errortimes}");
}
else if (errortimes == 5)
{
camera.Open();
errortimes++;
LogUtil.error(Name + $"相机错误次数过多,重新打开,{errortimes}");
}
else if (errortimes == 6)
{
LogUtil.error(Name + $"相机连接失败, 相机线程退出,{errortimes}");
break;
}
Thread.Sleep(1000 / 5);
}
catch
{
errortimes++;
}
}
camera.Close();
camera.Dispose();
}
public void CameraGrabOne(string filename)
{
try
{
LogUtil.info(Name + "库位文件名:" + filename);
Bitmap bmp = camera.GetImage(DeviceName);
if (bmp != null)
{
if (File.Exists(filename))
File.Delete(filename);
bmp.Save(filename, ImageFormat.Jpeg);
bmp.Dispose();
}
}
catch (Exception e)
{
LogUtil.error(Name + e.ToString());
}
}
public string GetFixtureStateFilename(string PositionNum, string WareNumber, StoreMoveType storeMoveType, FixtureState fixtureState)
{
string dir = $"\\image\\Fixture\\{storeMoveType}\\{PositionNum}\\";
Directory.CreateDirectory(dir);
string filename = $"{WareNumber}@@{fixtureState}.jpg";
foreach (var x in Path.GetInvalidFileNameChars())
{
filename = filename.Replace(x.ToString(), "");
}
return dir + filename;
}
}
public enum FixtureState
{
In,
Up,
Down,
Out,
DoorIn,
DoorOut,
}
......@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace DeviceLibrary
{
class LiftMonitor
public class LiftMonitor
{
string up;
string down;
......@@ -36,6 +36,8 @@ namespace DeviceLibrary
}
public void LiftUp(MoveInfo moveInfo) {
if (moveInfo == null)
moveInfo = new MoveInfo("界面");
if (IOManager.IOValue(up.ToString()).Equals(IO_VALUE.HIGH)) {
moveInfo.log($"{axisBean.AxisName},已在位置,无需上升");
return;
......@@ -71,6 +73,8 @@ namespace DeviceLibrary
}
public void LiftDown(MoveInfo moveInfo)
{
if (moveInfo == null)
moveInfo = new MoveInfo("界面");
if (IOManager.IOValue(down.ToString()).Equals(IO_VALUE.HIGH))
{
moveInfo.log($"{axisBean.AxisName},已在位置,无需下降");
......
......@@ -56,10 +56,13 @@ namespace DeviceLibrary
DateTime pauseTime= DateTime.MinValue;
public void Pause() {
lineTimer.Enabled = false;
pauseTime = DateTime.Now;
DOMove(LineIO, IO_VALUE.LOW);
LogUtil.info(Name + $" 线体管理器 暂停线体.");
if (lineTimer.Enabled)
{
lineTimer.Enabled = false;
pauseTime = DateTime.Now;
DOMove(LineIO, IO_VALUE.LOW);
LogUtil.info(Name + $" 线体管理器 暂停线体.");
}
}
public void Resume() {
......@@ -69,17 +72,19 @@ namespace DeviceLibrary
{
if (linrunlist.Count > 0)
{
foreach (var k in linrunlist.Keys)
foreach (var k in linrunlist.Keys.ToArray())
{
linrunlist[k] += DateTime.Now - pauseTime;
if (linrunlist.ContainsKey(k))
linrunlist[k] += DateTime.Now - pauseTime;
}
DOMove(LineIO, IO_VALUE.HIGH);
}
}
pauseTime = DateTime.MinValue;
lineTimer.Enabled = true;
LogUtil.info(Name + $" 线体管理器 恢复运行线体.");
}
pauseTime = DateTime.MinValue;
lineTimer.Enabled = true;
LogUtil.info(Name + $" 线体管理器 恢复运行线体.");
}
/// <summary>
......
......@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
......@@ -14,6 +15,7 @@ public class OKLEController
private static int dataBits = 8;//数据位
private static StopBits stopBits = StopBits.One; //停止位
private static Dictionary<string, AcSerialBean> SerialMap = new Dictionary<string, AcSerialBean>();
private static Dictionary<string, double> ValueBuffer = new Dictionary<string, double>();
private static string LogName = "";
......@@ -40,6 +42,8 @@ public class OKLEController
}
LogName = "[OKLE_" + port + "]";
if (!ValueBuffer.ContainsKey(port))
ValueBuffer.Add(port, 0);
AcSerialBean sb = new AcSerialBean(port, bautRate, parity, dataBits, stopBits);
try
......@@ -102,86 +106,68 @@ public class OKLEController
}
}
public static bool Reset(string port)
{
AcSerialBean sb = GetSerialBean(port);
if (sb == null)
{
return false;
}
LogName = "[OKLE_" + port + "]";
//12.1.4执行手动置零
//指令格式:01 10 00 5E 00 01 02 00 01 6A EE
byte[] sendData = new byte[11];
sendData[0] = 0x01;
sendData[1] = 0x10;
sendData[2] = 0x00;
sendData[3] = 0x5E;
sendData[4] = 0x00;
sendData[5] = 0x01;
sendData[6] = 0x02;
sendData[7] = 0x00;
sendData[8] = 0x01;
sendData[9] = 0x00;
sendData[10] = 0x00;
sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData);
LogUtil.debug(LogName + "发送数据:" + str);
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
return isOk;
}
public static double queryData(string port)
{
{
double weight = 0d;
AcSerialBean sb = GetSerialBean(port);
if (sb == null)
{
return weight;
}
LogName = "[OKLE_" + port + "]";
//12..1.2读取力值(毛重)指令,指令格式:01 03 00 50 00 02 C4 1A
//01 03 00 00 00 02 C4 0B
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x03;
sendData[2] = 0x00;
sendData[3] = 0x00;
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0xC4;
sendData[7] = 0x0B;
//sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData, " ");
byte[] reviceData = new byte[9];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
LogUtil.debug(LogName + "发送数据:" + str + ",收到数据 :" + AcSerialBean.byteToHexStr(reviceData, " "));
return getReviceData(reviceData);
}
public static double CalWeight(double value, double dValue = 0, double xishu = 1)
{
double v = (double)(value - dValue) / xishu;
LogUtil.debug("重量计算 (" + value + "-" + dValue + ")/" + xishu + "=" + v);
return v;
if (!Monitor.TryEnter(sb))
return ValueBuffer[port];
try
{
LogName = "[OKLE_" + port + "]";
//12..1.2读取力值(毛重)指令,指令格式:01 03 00 50 00 02 C4 1A
//01 03 00 00 00 02 C4 0B
byte[] sendData = new byte[8];
sendData[0] = 0x01;
sendData[1] = 0x03;
sendData[2] = 0x00;
sendData[3] = 0x00;
sendData[4] = 0x00;
sendData[5] = 0x02;
sendData[6] = 0xC4;
sendData[7] = 0x0B;
//sendData = buildCheckData(sendData, sendData.Length - 2);
string str = AcSerialBean.byteToHexStr(sendData, " ");
byte[] reviceData = new byte[15];
bool isOk = false;
sb.SendCommand(sendData, ref reviceData, 100, out isOk);
LogUtil.debug(LogName + "发送数据:" + str + ",收到数据 :" + AcSerialBean.byteToHexStr(reviceData, " "));
ValueBuffer[port] = getReviceData(reviceData);
return ValueBuffer[port];
}
catch(Exception e) {
LogUtil.debug(LogName + e.ToString());
return ValueBuffer[port];
}
finally {
Monitor.Exit(sb);
}
}
private static double getReviceData(byte[] dataArray)
{
double value = 0d;
try
{
if (dataArray.Length >= 9)
//3D 53 47 2B 30 30 32 30 2E 30 31 6B BE 0D 0A
//=SG+0020.01k�
var tempstr = Encoding.ASCII.GetString(dataArray);
if (tempstr.StartsWith("="))
{
var numstr = tempstr.Substring(3, 8);
if (!double.TryParse(numstr, out value))
LogUtil.info(LogName + "转换出错:" + numstr.ToString());
}
else
{
//返回格式:01 03 04 FF FF C1 F0 AB C3(数据根据实际情况变化)
//地址 功能码 字节数 第一组寄存器数据 第二组寄存器数据 CRC16校验
//01 03 04 FF FF C1 F0 AB C3
string highV = String.Format("{0:X2}", dataArray[3]) + String.Format("{0:X2}", dataArray[4]);
string lowV = String.Format("{0:X2}", dataArray[5]) + String.Format("{0:X2}", dataArray[6]);
value = (double)Convert.ToInt32(highV + lowV, 16);
LogUtil.info(LogName + "转换出错:" + tempstr.ToString());
}
}
catch (Exception ex)
......
......@@ -28,7 +28,7 @@ namespace DeviceLibrary
{
Config = _Config;
mainMachine = _mainMachine;
MoveInfo = new MoveInfo("行走机构");
#region 初始化伺服轴
XAxis = _mainMachine.XAxis;
YAxis = _mainMachine.YAxis;
......@@ -37,11 +37,14 @@ namespace DeviceLibrary
}
StoreMoveType storeMoveType = StoreMoveType.None;
public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType)
string WareCode="";
public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType, string warecode)
{
if (MoveInfo.MoveStep != MoveStep.Wait)
return false;
WareCode = warecode;
storeMoveType = _storeMoveType;
if (from == null)
{
......@@ -83,15 +86,15 @@ namespace DeviceLibrary
case MoveStep.Wait:
break;
case MoveStep.StoreTS01:
if (IOManager.IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.LOW) &&
IOManager.IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.LOW))
if (IOManager.IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.HIGH) ||
IOManager.IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.HIGH))
{
Msg.add("伸缩叉2侧检测到有物料无法继续,请检查", MsgLevel.warning);
Msg.add("伸缩叉2侧检测到有物料无法继续,请检查", MsgLevel.alarm);
RobotManage.UserPause("伸缩2侧叉检测到有物料无法继续,请检查");
}
else if (IOManager.IOValue(IO_Type.ForkMaterial_Check).Equals(IO_VALUE.HIGH))
{
Msg.add("出库时伸缩叉检测到有物料无法继续,请检查", MsgLevel.warning);
Msg.add("出库时伸缩叉检测到有物料无法继续,请检查", MsgLevel.alarm);
RobotManage.UserPause("出库时伸缩叉检测到有物料无法继续,请检查");
}
else
......@@ -130,6 +133,7 @@ namespace DeviceLibrary
MoveInfo.log($"{storeMoveType}:进出轴到达取料点");
break;
case MoveStep.StoreTS07:
GetCamera(From.Zaxis_P2).CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(From.posid, WareCode, storeMoveType, FixtureState.In));
MoveInfo.NextMoveStep(MoveStep.StoreTS08);
YAxis.AbsMove(MoveInfo, From.Yaxis_PH, Config.Yaxis_P4_speed);
MoveInfo.log($"{storeMoveType}:上下轴到达取料低点");
......@@ -140,15 +144,16 @@ namespace DeviceLibrary
MoveInfo.log($"{storeMoveType}:进出轴到达待机点");
break;
case MoveStep.StoreTS09:
if (IOManager.IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.LOW) &&
IOManager.IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.LOW))
GetCamera(From.Zaxis_P2).CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(From.posid, WareCode, storeMoveType, FixtureState.Out));
if (IOManager.IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.HIGH) ||
IOManager.IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.HIGH))
{
Msg.add("伸缩叉2侧检测到有物料无法继续,请检查", MsgLevel.warning);
Msg.add("伸缩叉2侧检测到有物料无法继续,请检查", MsgLevel.alarm);
RobotManage.UserPause("伸缩叉2侧检测到有物料无法继续,请检查");
}
else if (IOManager.IOValue(IO_Type.ForkMaterial_Check).Equals(IO_VALUE.LOW))
{
Msg.add("出库时伸缩叉没有取到物料,请检查", MsgLevel.warning);
Msg.add("出库时伸缩叉没有取到物料,请检查", MsgLevel.alarm);
RobotManage.UserPause("出库时伸缩叉没有取到物料,请检查");
}
else
......@@ -179,6 +184,7 @@ namespace DeviceLibrary
MoveInfo.log($"{storeMoveType}:进出轴到达目的地");
break;
case MoveStep.StoreTS13:
GetCamera(To.Zaxis_P2).CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.In));
MoveInfo.NextMoveStep(MoveStep.StoreTS14);
YAxis.AbsMove(MoveInfo, To.Yaxis_PL, Config.Yaxis_P4_speed);
MoveInfo.log($"{storeMoveType}:上下轴到达目的地低点");
......@@ -189,15 +195,16 @@ namespace DeviceLibrary
MoveInfo.log($"{storeMoveType}:进出轴到达待机点");
break;
case MoveStep.StoreTS15:
if (IOManager.IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.LOW) &&
IOManager.IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.LOW))
GetCamera(To.Zaxis_P2).CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.Out));
if (IOManager.IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.HIGH) ||
IOManager.IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.HIGH))
{
Msg.add("伸缩叉检测到有物料无法继续,请检查", MsgLevel.warning);
Msg.add("伸缩叉2侧检测到有物料无法继续,请检查", MsgLevel.alarm);
RobotManage.UserPause("伸缩叉检测到有物料无法继续,请检查");
}
else if (IOManager.IOValue(IO_Type.ForkMaterial_Check).Equals(IO_VALUE.HIGH))
{
Msg.add("入库后伸缩叉上任然检测到物料,请检查", MsgLevel.warning);
Msg.add("入库后伸缩叉上任然检测到物料,请检查", MsgLevel.alarm);
RobotManage.UserPause("入库后伸缩叉上任然检测到物料,请检查");
}
else
......@@ -232,5 +239,9 @@ namespace DeviceLibrary
{
InOutEndProcessEvent?.Invoke(posid, storeMoveType, true);
}
HIKCamera GetCamera(int pos) {
return pos > 0 ? RobotManage.CameraA : RobotManage.CameraB;
}
}
}
......@@ -345,7 +345,8 @@ namespace DeviceLibrary
public enum MsgLevel {
warning,
info
info,
alarm
}
public class IdWorker
{
......
......@@ -105,6 +105,7 @@ namespace DeviceLibrary
}
}
[Serializable]
class BoxStorePosition {
//行走机构取料点
public int Xaxis_P2;
......
......@@ -43,7 +43,10 @@ namespace DeviceLibrary
}
List<ACStorePosition> poslist;
int CurrentPosIndex = 0;
public bool AutoInOutTest = false;
/// <summary>
/// 自动出入库状态
/// </summary>
public bool AutoInOutTest { get; set; } = false;
bool StopAutoInOut = false;
void AutoInOutTestProcess()
{
......@@ -62,7 +65,7 @@ namespace DeviceLibrary
case MoveStep.StoreIn01:
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn02);
var ac = poslist[CurrentPosIndex];
if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.A), new BoxStorePosition(ac), StoreMoveType.InStore)) {
if (!boxTransport.Start(new BoxStorePosition(Config, StoreSide.A), new BoxStorePosition(ac), StoreMoveType.InStore,"auto")) {
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
......@@ -95,7 +98,7 @@ namespace DeviceLibrary
return;
}
var bc = poslist[CurrentPosIndex];
if (!boxTransport.Start(new BoxStorePosition(ac), new BoxStorePosition(bc), StoreMoveType.InStore))
if (!boxTransport.Start(new BoxStorePosition(ac), new BoxStorePosition(bc), StoreMoveType.InStore, "auto"))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
......@@ -112,7 +115,7 @@ namespace DeviceLibrary
}
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut11);
ac = poslist[CurrentPosIndex];
if (!boxTransport.Start(new BoxStorePosition(ac), new BoxStorePosition(Config, StoreSide.B), StoreMoveType.OutStore))
if (!boxTransport.Start(new BoxStorePosition(ac), new BoxStorePosition(Config, StoreSide.B), StoreMoveType.OutStore, "auto"))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
......
......@@ -36,9 +36,13 @@ namespace DeviceLibrary
double CurrentWeight
{
get
{
var weight = OKLEController.queryData(Config.WeightSensorPort);
return weight - Config.WeightSensorBase;
{ if (RobotManage.StoreType == StoreType.TypeA)
{
var weight = OKLEController.queryData(Config.WeightSensorPort);
return weight - Config.WeightSensorBase;
}
else
return 0;
}
}
void InProcess()
......@@ -49,6 +53,7 @@ namespace DeviceLibrary
switch (InMoveInfo.MoveStep)
{
case MoveStep.Wait:
if (CurrentWeight > Config.StoreWeightLimited)
{
Msg.add($"周转箱超重,当前重量:{CurrentWeight}kg,最大限重{Config.StoreWeightLimited}kg", MsgLevel.warning);
......@@ -92,7 +97,11 @@ namespace DeviceLibrary
if (CurrentWeight <= Config.StoreWeightLimited)
{
InMoveInfo.log($"开始拍照扫码");
ScanCode();
if (RobotManage.InoutDebugMode)
{
InMoveInfo.NextMoveStep(MoveStep.InWaitServerCallback);
}
else ScanCode();
}
else
{
......@@ -128,7 +137,12 @@ namespace DeviceLibrary
}
break;
case MoveStep.InWaitServerCallback:
if (InMoveInfo.IsTimeOut(5))
if (RobotManage.InoutDebugMode)
{
Msg.add("等待手动选择入库库位", MsgLevel.info);
}
else if (InMoveInfo.IsTimeOut(5))
Msg.add("等待服务器返回库位", MsgLevel.info);
else if (InMoveInfo.IsTimeOut(15))
{
......@@ -139,14 +153,17 @@ namespace DeviceLibrary
case MoveStep.StartInStore:
InMoveInfo.NextMoveStep(MoveStep.In06);
CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up,IO_VALUE.LOW);
InSideLift.LiftUp(InMoveInfo);
InSideLift.LiftDown(InMoveInfo);
InMoveInfo.log($"放下入料阻挡");
break;
case MoveStep.In06:
InMoveInfo.NextMoveStep(MoveStep.In07);
LineIn.LineRun("work", 999);
CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.HIGH);
InMoveInfo.log($"料箱定位前进");
if (RobotManage.StoreType == StoreType.TypeA)
{
CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.HIGH);
InMoveInfo.log($"料箱定位前进");
}
break;
case MoveStep.In07:
if (IOValue(IO_Type.InOverHead_Check).Equals(IO_VALUE.HIGH)) {
......@@ -172,8 +189,11 @@ namespace DeviceLibrary
break;
case MoveStep.In08:
InMoveInfo.NextMoveStep(MoveStep.In09);
CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.LOW);
InMoveInfo.log("料箱定位后退");
if (RobotManage.StoreType == StoreType.TypeA)
{
CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.LOW);
InMoveInfo.log("料箱定位后退");
}
break;
case MoveStep.In09:
InMoveInfo.NextMoveStep(MoveStep.InWaitBoxLeave);
......@@ -198,6 +218,14 @@ namespace DeviceLibrary
InMoveInfo.NextMoveStep(MoveStep.Wait);
}
break;
case MoveStep.InReset:
InMoveInfo.NextMoveStep(MoveStep.Wait);
InMoveInfo.log("入库线体状态重置");
CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up, IO_VALUE.HIGH);
CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.LOW);
InSideLift.LiftDown(InMoveInfo);
LineIn.LineStop("work");
break;
default:
InMoveInfo.log($"未找到对应步骤:{InMoveInfo.MoveStep}");
break;
......
......@@ -14,18 +14,71 @@ namespace DeviceLibrary
partial class MainMachine
{
void ioMonitor()
{
{
//右侧料串已空
//if (RightMoveInfo.IsStep(MoveStep.Wait) && IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.HIGH) && RightShelfNoTray)
}
bool InSafeCheck() {
bool ok = true;
if (IOValue(IO_Type.InEntry_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.InFrontCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
LineIn.Pause();
}
Msg.add("入料正面安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
if (RobotManage.StoreType == StoreType.TypeA)
{
if (IOValue(IO_Type.InSide_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal)
{
ok = false;
LineIn.Pause();
}
Msg.add("入料侧面光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
}
if (ok)
LineIn.Resume();
return ok;
}
bool OutSafeCheck() {
bool ok = true;
if (IOValue(IO_Type.OutExit_SafetyGrating).Equals(IO_VALUE.LOW))
{
Msg.add("右侧料串已空,等待取走料串", MsgLevel.warning);
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.InFrontCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
LineOut.Pause();
}
Msg.add("出料正面安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
//左侧料串已满
//if (LeftMoveInfo.IsStep(MoveStep.Wait) && IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH) && LeftShelfNoTray)
if (RobotManage.StoreType == StoreType.TypeA)
{
Msg.add("作侧料串已满,等待取走料串", MsgLevel.warning);
if (IOValue(IO_Type.OutSide_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.OutExitCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
LineOut.Pause();
}
Msg.add("入料侧面安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
}
if (ok)
LineOut.Resume();
return ok;
}
}
}
......@@ -20,8 +20,10 @@ namespace DeviceLibrary
}
void OutProcess()
{
if (CheckWait(OutMoveInfo))
return;
//常规上料扫码流程
switch (OutMoveInfo.MoveStep)
......@@ -72,7 +74,7 @@ namespace DeviceLibrary
break;
case MoveStep.Out02:
OutMoveInfo.NextMoveStep(MoveStep.Out03);
LineIn.LineRun("work", 3);
LineOut.LineRun("work", 3);
OutMoveInfo.log($"料箱抵达出口");
OutMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
break;
......
......@@ -26,7 +26,7 @@ namespace DeviceLibrary
{
case MoveStep.Wait:
//判断入库线体有没有等待入库
if (InMoveInfo.MoveStep == MoveStep.InWaitBoxLeave)
if (InMoveInfo.MoveStep == MoveStep.InWaitBoxLeave && !string.IsNullOrEmpty(InMoveInfo.MoveParam.PosID))
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
StoreMoveInfo.MoveParam = InMoveInfo.MoveParam.clone();
......@@ -46,7 +46,7 @@ namespace DeviceLibrary
case MoveStep.StoreIn01:
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
var ac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
boxTransport.Start(new BoxStorePosition(Config,StoreSide.A), new BoxStorePosition(ac),StoreMoveType.InStore);
boxTransport.Start(new BoxStorePosition(Config,StoreSide.A), new BoxStorePosition(ac),StoreMoveType.InStore, StoreMoveInfo.MoveParam.WareCode);
StoreMoveInfo.log($"开始转运周转箱");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreExecute);
break;
......@@ -76,7 +76,7 @@ namespace DeviceLibrary
case MoveStep.StoreOut10:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
var outac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
boxTransport.Start(new BoxStorePosition(outac),new BoxStorePosition(Config, StoreSide.B),StoreMoveType.OutStore);
boxTransport.Start(new BoxStorePosition(outac),new BoxStorePosition(Config, StoreSide.B),StoreMoveType.OutStore, StoreMoveInfo.MoveParam.WareCode);
StoreMoveInfo.log($"开始转运周转箱");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreExecute);
break;
......
......@@ -32,14 +32,14 @@ namespace DeviceLibrary
public bool UserPause { get; set; } = false;
MoveInfo ResetMoveInfo;
public MoveInfo ResetMoveInfo;
/// <summary>
/// 右侧移动信息
/// </summary>
public MoveInfo InMoveInfo;
public MoveInfo OutMoveInfo;
MoveInfo StoreMoveInfo;
MoveInfo AIOTMoveInfo;
public MoveInfo StoreMoveInfo;
public MoveInfo AIOTMoveInfo;
public delegate void ProcessMsg(List<Msg> msg);
public event ProcessMsg ProcessMsgEvent;
......@@ -53,11 +53,11 @@ namespace DeviceLibrary
AxisBean InLift_Moto;
AxisBean OutLift_Moto;
LineRunMonitor LineIn;
LineRunMonitor LineOut;
public LineRunMonitor LineIn;
public LineRunMonitor LineOut;
LiftMonitor InSideLift;
LiftMonitor OutSideLift;
public LiftMonitor InSideLift;
public LiftMonitor OutSideLift;
BoxTransport boxTransport;
public bool boxTransportIsFree { get => boxTransport.IsComplateOrFree; }
......@@ -79,15 +79,14 @@ namespace DeviceLibrary
public MainMachine(Robot_Config _config) {
Config = _config;
InMoveInfo = new MoveInfo("A侧取料");
InMoveInfo.SetStateDelegate(InState);
StoreMoveInfo = new MoveInfo("出入库");
InMoveInfo = new MoveInfo("入料A侧");
InMoveInfo.SetStateDelegate(InState);
StoreMoveInfo = new MoveInfo("行走机构");
StoreMoveInfo.SetStateDelegate(StoreState);
OutMoveInfo = new MoveInfo("B侧出料");
OutMoveInfo = new MoveInfo("出料B侧");
OutMoveInfo.SetStateDelegate(OutState);
ResetMoveInfo = new MoveInfo("重置");
AIOTMoveInfo = new MoveInfo("出入库测试");
//MoveInfo.List.Remove(AIOTMoveInfo);
#region 初始化led
AlarmLed = new Led(Config.DOList[IO_Type.Alarm_Led].GetIOAddr());
......@@ -201,13 +200,15 @@ namespace DeviceLibrary
if (runStatus == RunStatus.Running)
{
ioMonitor();
InProcess();
if (InSafeCheck())
InProcess();
boxTransport.Process();
if (RobotManage.mainMachine.AutoInOutTest)
AutoInOutTestProcess();
else
StoreProcess();
OutProcess();
if (OutSafeCheck())
OutProcess();
}
else if (runStatus == RunStatus.HomeReset)
{
......@@ -223,6 +224,13 @@ namespace DeviceLibrary
var m = Msg.get();
ProcessMsgEvent?.Invoke(m);
ServerCM.ProcessMsg(m);
if (m.Find((aa) => aa.msgLevel == MsgLevel.alarm) == null)
{
AlarmBuzzer.OFF();
}
else {
AlarmBuzzer.ON();
}
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if (!UserPause)
Msg.clear();
......@@ -252,7 +260,7 @@ namespace DeviceLibrary
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
//强制回原
bool forceHome=true;
bool forceHome=false;
void HomeReset()
{
if (CheckWait(ResetMoveInfo))
......@@ -296,12 +304,15 @@ namespace DeviceLibrary
YAxis.AbsMove(ResetMoveInfo, Config.Yaxis_P1,Config.Yaxis_P1_speed);
XAxis.AbsMove(ResetMoveInfo, Config.Xaxis_P1,Config.Xaxis_P1_speed);
OutSideLift.LiftUp(ResetMoveInfo);
InSideLift.LiftUp(ResetMoveInfo);
InSideLift.LiftDown(ResetMoveInfo);
CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up, IO_VALUE.HIGH);
CylinderMove(InMoveInfo, IO_Type.OutStop_Down, IO_Type.OutStop_Up, IO_VALUE.HIGH);
CylinderMove(InMoveInfo, IO_Type.OutExitStop_Down, IO_Type.OutExitStop_Up, IO_VALUE.HIGH);
break;
case MoveStep.H06_HomeReset:
if (IOValue(IO_Type.ForkMaterial_Check).Equals(IO_VALUE.HIGH) &&
IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.LOW))
if (IOValue(IO_Type.ForkMaterial_Check).Equals(IO_VALUE.HIGH) ||
IOValue(IO_Type.SideA_ForkMaterial_Check).Equals(IO_VALUE.HIGH) ||
IOValue(IO_Type.SideB_ForkMaterial_Check).Equals(IO_VALUE.HIGH))
{
ResetMoveInfo.NextMoveStep(MoveStep.H07_HomeReset);
ResetMoveInfo.log("进出轴上有周转箱");
......@@ -322,7 +333,7 @@ namespace DeviceLibrary
case MoveStep.H07_HomeReset:
if (OutMoveInfo.MoveStep == MoveStep.Wait && IsOutLiftEmpty) {
ResetMoveInfo.NextMoveStep(MoveStep.H08_HomeReset);
boxTransport.Start(null, new BoxStorePosition(Config, StoreSide.B), StoreMoveType.ReturnHome);
boxTransport.Start(null, new BoxStorePosition(Config, StoreSide.B), StoreMoveType.ReturnHome, "ReturnHome");
ResetMoveInfo.log("进出轴上有周转箱,开始送到出口");
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
}
......@@ -342,52 +353,22 @@ namespace DeviceLibrary
break;
}
}
public bool IgnoreSafecheck=false;
bool _IgnoreSafecheck = false;
public bool IgnoreSafecheck { get => _IgnoreSafecheck; set {
if (value)
{
IOMove(IO_Type.DoorSafe_Disable, IO_VALUE.HIGH);
}
else {
IOMove(IO_Type.DoorSafe_Disable, IO_VALUE.LOW);
}
_IgnoreSafecheck = value;
} }
public bool IgnoreGratingSignal = false;
bool lastSafeCheckStatus = true;
bool SafeCheck() {
bool ok = true;
if (IOValue(IO_Type.InEntry_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.InFrontCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
DeviceSuddenStop();
}
Msg.add("安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}else if (IOValue(IO_Type.OutExit_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.InFrontCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
DeviceSuddenStop();
}
Msg.add("安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
if (IOValue(IO_Type.InSide_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.InFrontCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
DeviceSuddenStop();
}
Msg.add("安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
else if (IOValue(IO_Type.OutSide_SafetyGrating).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.OutExitCar_Check).Equals(IO_VALUE.LOW))
{
ok = false;
DeviceSuddenStop();
}
Msg.add("安全光栅被遮挡" + (ok ? "[已忽略]" : ""), MsgLevel.warning);
}
if (IOValue(IO_Type.FrontDoor_Check).Equals(IO_VALUE.LOW))
{
......@@ -418,8 +399,7 @@ namespace DeviceLibrary
//AxisBean.StopMultiAxis(new List<AxisBean>() { Take_Middle_Axis, Take_UpDown_Axis, Label_X_Axis,Label_Y_Axis, Label_Z_Axis, Label_R_Axis });
AxisBean.StopMultiAxis(AxisBean.List);
MoveInfo.List.ForEach((m) => { m.CanWhileCount = 5; });
LineIn.Pause();
LineOut.Pause();
if (runStatus == RunStatus.HomeReset)
{
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
......@@ -449,7 +429,7 @@ namespace DeviceLibrary
else if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
Alarm(AlarmType.SuddenStop);
Msg.add("急停中", MsgLevel.warning);
Msg.add("急停中", MsgLevel.alarm);
ok = false;
}
else if (alarmType == AlarmType.SuddenStop) {
......@@ -465,8 +445,8 @@ namespace DeviceLibrary
}
if (RobotManage.InoutDebugMode)
{
Msg.add("进出库调试模式", MsgLevel.warning);
ok = false;
Msg.add("进出库调试模式", MsgLevel.info);
//ok = false;
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
{
......
......@@ -39,6 +39,7 @@ namespace DeviceLibrary
InWaitBoxLeave, //等待料箱入库
InBoxLeaved, //料箱已取走
InOverHead,
InReset,
OutBoxPutOn,
Out01,
......@@ -52,6 +53,7 @@ namespace DeviceLibrary
Out09,
Out10,
Out11,
OutReset,
......
......@@ -15,6 +15,7 @@ namespace DeviceLibrary
{
public static MainMachine mainMachine;
public static Robot_Config Config;
public static StoreType StoreType = ConfigHelper.Config.Get<StoreType>("StoreType",StoreType.TypeA);
public static bool IsLoadOk = true;
public static bool IsConfigMode = false;
public static bool InoutDebugMode = false;
......@@ -27,6 +28,10 @@ namespace DeviceLibrary
public static List<string> PositionNumList { get => CSVPositionReader<ACStorePosition>.allPositionMap.Keys.ToList(); }
static string baseDir = Application.StartupPath;
static Thread mainThread;
public static HIKCamera CameraA=new HIKCamera();
public static HIKCamera CameraB= new HIKCamera();
public static void Init() {
string msg = "";
try
......@@ -56,12 +61,24 @@ namespace DeviceLibrary
IsLoadOk = false;
msg += "IO板卡初始化失败\n";
}
if (!OKLEController.Init(Config.WeightSensorPort)) {
if (StoreType == StoreType.TypeA)
{
if (!OKLEController.Init(Config.WeightSensorPort))
{
IsLoadOk = false;
msg += $"称重传感器初始化失败 Port:{Config.WeightSensorPort}\n";
}
}
if (!CameraA.LoadCameraConfig("CameraA", out string errmsg))
{
IsLoadOk = false;
msg += $"称重传感器初始化失败 Port:{Config.WeightSensorPort}\n";
msg += errmsg + "\r\n";
}
if (!CameraB.LoadCameraConfig("CameraB", out errmsg))
{
IsLoadOk = false;
msg += errmsg+"\r\n";
}
IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
......@@ -147,4 +164,8 @@ namespace DeviceLibrary
LogUtil.info("用户取消忽略安全光栅");
}
}
public enum StoreType {
TypeA,TypeB
}
}
......@@ -257,7 +257,7 @@ namespace DeviceLibrary
{
//LogUtil.info(boxBean.Name + "点击【原点返回】,【" + PortName + "_" + SlvAddr + "】 速度【" + a.HomeHighSpeed + "】");
LogUtil.info(boxBean.Name + "【" + PortName + "_" + SlvAddr + "】点动: 速度:" + speed + $",AddSpeed:{a.AddSpeed}, DelSpeed:{a.DelSpeed}");
AxisManager.SpeedMove(PortName, SlvAddr, speed, a.AddSpeed, a.DelSpeed);
AxisManager.SpeedMove(PortName, SlvAddr, speed, 0, 0);
}
}
}
......
......@@ -24,14 +24,23 @@
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="HCBOARD" type="log4net.Appender.RollingFileAppender">
<file value="logs/HCBOARD.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="HCBOARD">
<logger name="HCBOARD" additivity="false">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="HCBOARD" />
</logger>
<!--<root>
<level value="Info" />
......
......@@ -39,6 +39,8 @@ namespace TheMachine
this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.btn_PauseBuzzer = new System.Windows.Forms.Button();
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.cb_IgnoreGratingSignal = new System.Windows.Forms.CheckBox();
......@@ -48,9 +50,13 @@ namespace TheMachine
this.listView1 = new System.Windows.Forms.ListView();
this.btn_stop = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button();
this.btn_outreset = new System.Windows.Forms.Button();
this.btn_inreset = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
......@@ -129,11 +135,15 @@ namespace TheMachine
this.tabControl1.Location = new System.Drawing.Point(0, 90);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1008, 599);
this.tabControl1.Size = new System.Drawing.Size(1008, 639);
this.tabControl1.TabIndex = 1;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btn_inreset);
this.tabPage1.Controls.Add(this.btn_outreset);
this.tabPage1.Controls.Add(this.pictureBox2);
this.tabPage1.Controls.Add(this.pictureBox1);
this.tabPage1.Controls.Add(this.btn_PauseBuzzer);
this.tabPage1.Controls.Add(this.cb_EnableBuzzer);
this.tabPage1.Controls.Add(this.cb_IgnoreGratingSignal);
......@@ -141,15 +151,41 @@ namespace TheMachine
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Location = new System.Drawing.Point(4, 30);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(1000, 565);
this.tabPage1.Size = new System.Drawing.Size(1000, 605);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "信息";
this.tabPage1.UseVisualStyleBackColor = true;
//
// pictureBox2
//
this.pictureBox2.BackColor = System.Drawing.Color.Gainsboro;
this.pictureBox2.Location = new System.Drawing.Point(479, 314);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(463, 283);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox2.TabIndex = 270;
this.pictureBox2.TabStop = false;
this.pictureBox2.Visible = false;
this.pictureBox2.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick);
this.pictureBox2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Gainsboro;
this.pictureBox1.Location = new System.Drawing.Point(10, 314);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(463, 283);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 271;
this.pictureBox1.TabStop = false;
this.pictureBox1.Visible = false;
this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick);
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
//
// btn_PauseBuzzer
//
this.btn_PauseBuzzer.BackColor = System.Drawing.Color.OrangeRed;
this.btn_PauseBuzzer.Location = new System.Drawing.Point(653, 135);
this.btn_PauseBuzzer.Location = new System.Drawing.Point(657, 109);
this.btn_PauseBuzzer.Name = "btn_PauseBuzzer";
this.btn_PauseBuzzer.Size = new System.Drawing.Size(201, 40);
this.btn_PauseBuzzer.TabIndex = 6;
......@@ -161,7 +197,7 @@ namespace TheMachine
// cb_EnableBuzzer
//
this.cb_EnableBuzzer.AutoSize = true;
this.cb_EnableBuzzer.Location = new System.Drawing.Point(653, 42);
this.cb_EnableBuzzer.Location = new System.Drawing.Point(657, 16);
this.cb_EnableBuzzer.Name = "cb_EnableBuzzer";
this.cb_EnableBuzzer.Size = new System.Drawing.Size(109, 25);
this.cb_EnableBuzzer.TabIndex = 5;
......@@ -172,7 +208,7 @@ namespace TheMachine
// cb_IgnoreGratingSignal
//
this.cb_IgnoreGratingSignal.AutoSize = true;
this.cb_IgnoreGratingSignal.Location = new System.Drawing.Point(653, 104);
this.cb_IgnoreGratingSignal.Location = new System.Drawing.Point(657, 78);
this.cb_IgnoreGratingSignal.Name = "cb_IgnoreGratingSignal";
this.cb_IgnoreGratingSignal.Size = new System.Drawing.Size(125, 25);
this.cb_IgnoreGratingSignal.TabIndex = 2;
......@@ -183,7 +219,7 @@ namespace TheMachine
// cb_IgnoreSafecheck
//
this.cb_IgnoreSafecheck.AutoSize = true;
this.cb_IgnoreSafecheck.Location = new System.Drawing.Point(653, 73);
this.cb_IgnoreSafecheck.Location = new System.Drawing.Point(657, 47);
this.cb_IgnoreSafecheck.Name = "cb_IgnoreSafecheck";
this.cb_IgnoreSafecheck.Size = new System.Drawing.Size(215, 25);
this.cb_IgnoreSafecheck.TabIndex = 2;
......@@ -194,9 +230,9 @@ namespace TheMachine
// groupBox1
//
this.groupBox1.Controls.Add(this.stateView);
this.groupBox1.Location = new System.Drawing.Point(21, 32);
this.groupBox1.Location = new System.Drawing.Point(10, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(611, 225);
this.groupBox1.Size = new System.Drawing.Size(611, 292);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "运行状态";
......@@ -210,7 +246,7 @@ namespace TheMachine
this.stateView.Location = new System.Drawing.Point(3, 25);
this.stateView.MultiSelect = false;
this.stateView.Name = "stateView";
this.stateView.Size = new System.Drawing.Size(605, 197);
this.stateView.Size = new System.Drawing.Size(605, 264);
this.stateView.TabIndex = 0;
this.stateView.UseCompatibleStateImageBehavior = false;
//
......@@ -252,15 +288,35 @@ namespace TheMachine
this.btn_run.UseVisualStyleBackColor = true;
this.btn_run.Click += new System.EventHandler(this.btn_run_Click);
//
// btn_outreset
//
this.btn_outreset.Location = new System.Drawing.Point(657, 265);
this.btn_outreset.Name = "btn_outreset";
this.btn_outreset.Size = new System.Drawing.Size(191, 40);
this.btn_outreset.TabIndex = 272;
this.btn_outreset.Text = "出料线状态重置";
this.btn_outreset.UseVisualStyleBackColor = true;
this.btn_outreset.Click += new System.EventHandler(this.btn_outreset_Click);
//
// btn_inreset
//
this.btn_inreset.Location = new System.Drawing.Point(657, 208);
this.btn_inreset.Name = "btn_inreset";
this.btn_inreset.Size = new System.Drawing.Size(191, 40);
this.btn_inreset.TabIndex = 272;
this.btn_inreset.Text = "入料线状态重置";
this.btn_inreset.UseVisualStyleBackColor = true;
this.btn_inreset.Click += new System.EventHandler(this.btn_inreset_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1008, 689);
this.ClientSize = new System.Drawing.Size(1008, 729);
this.Controls.Add(this.listView1);
this.Controls.Add(this.btn_stop);
this.Controls.Add(this.btn_run);
this.Controls.Add(this.listView1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
......@@ -274,6 +330,8 @@ namespace TheMachine
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
......@@ -301,6 +359,10 @@ namespace TheMachine
private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem;
private System.Windows.Forms.CheckBox cb_EnableBuzzer;
private System.Windows.Forms.Button btn_PauseBuzzer;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button btn_inreset;
private System.Windows.Forms.Button btn_outreset;
}
}
......@@ -101,9 +101,29 @@ namespace TheMachine
AddForm("日志", lc);
RobotManage.Init();
RobotManage.UserPauseSet += RobotManage_UserPauseSet;
}
RobotManage.CameraA.camera_event += CameraA_camera_event;
RobotManage.CameraB.camera_event += CameraA_camera_event;
}
private void CameraA_camera_event(object sender, Bitmap e)
{
if ((HIKCamera)sender == RobotManage.CameraA)
{
this.Invoke((EventHandler<Bitmap>)delegate
{
pictureBox1.Visible = true;
pictureBox1.Image = e;
}, sender, e);
}
else {
this.Invoke((EventHandler<Bitmap>)delegate
{
pictureBox2.Visible = true;
pictureBox2.Image = e;
}, sender, e);
}
}
private void AlarmBuzzer_BuzzerStateChange(object sender, bool e)
{
......@@ -135,7 +155,11 @@ namespace TheMachine
stateView.Items.Clear();
foreach (MoveInfo moveInfo in moveInfoList)
{
if (moveInfo.Name=="重置" && RobotManage.mainMachine.runStatus != RunStatus.HomeReset)
if (moveInfo.Equals(RobotManage.mainMachine.ResetMoveInfo) && RobotManage.mainMachine.runStatus != RunStatus.HomeReset)
{
continue;
}
else if (moveInfo.Equals(RobotManage.mainMachine.AIOTMoveInfo) && !RobotManage.mainMachine.AutoInOutTest)
{
continue;
}
......@@ -244,7 +268,8 @@ namespace TheMachine
if (RobotManage.isRunning)
{
btn_stop.Enabled = true;
(sender as Button).Text = "暂停运行";
RobotManage_UserPauseSet(this, false);
//(sender as Button).Text = "暂停运行";
}
}
else if (!userpause)
......@@ -271,13 +296,15 @@ namespace TheMachine
if (e)
{
userpause = true;
userpause = true;
(btn_run as Button).Text = "恢复运行";
(btn_run as Button).BackColor = Color.LightGreen;
}
else if (e)
else
{
userpause = false;
(btn_run as Button).Text = "暂停运行";
(btn_run as Button).BackColor = Color.Yellow;
}
}
private void btn_stop_Click(object sender, EventArgs e)
......@@ -350,5 +377,55 @@ namespace TheMachine
AlarmBuzzer.MuteOnce();
}
private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
var obj = sender as PictureBox;
if (obj.Dock == DockStyle.Fill)
obj.Dock = DockStyle.None;
else
{
obj.BringToFront();
obj.Dock = DockStyle.Fill;
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
var obj = sender as PictureBox;
if (obj.Dock == DockStyle.Fill)
obj.Dock = DockStyle.None;
}
private void btn_inreset_Click(object sender, EventArgs e)
{
if (RobotManage.mainMachine.IOValue(IO_Type.InStopMaterial_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.InOverHead_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.InEndMaterialBottom_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.InEndMaterialTop_Check).Equals(IO_VALUE.HIGH)
) {
MessageBox.Show(this, "检测到有信号被遮挡,重置前,请确认已将周转箱移除!", "警告");
return;
}
if (MessageBox.Show(this, "重置前,请确认已将周转箱移除!", "警告", MessageBoxButtons.OKCancel).Equals(DialogResult.Cancel))
return;
RobotManage.mainMachine.InMoveInfo.NewMove(MoveStep.InReset);
}
private void btn_outreset_Click(object sender, EventArgs e)
{
if (RobotManage.mainMachine.IOValue(IO_Type.OutStopMaterial_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.OutEntryMaterialBottom_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.OutEntryMaterialTop_Check).Equals(IO_VALUE.HIGH)
)
{
MessageBox.Show(this, "检测到有信号被遮挡,重置前,请确认已将周转箱移除!", "警告");
return;
}
if (MessageBox.Show(this, "重置前,请确认已将周转箱移除!", "警告", MessageBoxButtons.OKCancel).Equals(DialogResult.Cancel))
return;
RobotManage.mainMachine.OutMoveInfo.NewMove(MoveStep.OutReset);
}
}
}
using OnlineStore.LoadCSVLibrary;
using DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -13,19 +14,76 @@ namespace TheMachine
{
public partial class IOControls : UserControl
{
DeviceConfig _Config;
public DeviceConfig Config
Robot_Config _Config;
public Robot_Config Config
{
get { return _Config; }
set
{
_Config = value;
ioControl1.Config = value;
timer1.Enabled = true;
}
}
public IOControls()
{
InitializeComponent();
}
private void btn_leftLiftUp_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.InSideLift.LiftUp(null);
}
private void btn_leftLiftDown_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.InSideLift.LiftDown(null);
}
private void btn_rightLiftUp_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.OutSideLift.LiftUp(null);
}
private void btn_rightLiftDown_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.OutSideLift.LiftDown(null);
}
private void btn_leftLinerun_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.LineIn.LineRun("n",999);
}
private void btn_leftLinestop_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.LineIn.LineStop("n");
}
private void btn_rightLinerun_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.LineOut.LineRun("n", 999);
}
private void btn_rightLinestop_Click(object sender, EventArgs e)
{
RobotManage.mainMachine.LineOut.LineStop("n");
}
private void timer1_Tick(object sender, EventArgs e)
{
if (RobotManage.StoreType == StoreType.TypeA)
{
if (!this.Visible) return;
var w = OKLEController.queryData(Config.WeightSensorPort);
label_weight.Text = $"称重读数: {w:0.00}kg";
}
else {
timer1.Enabled = false;
label_weight.Text = "";
}
}
}
}
......@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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>
\ No newline at end of file
......@@ -37,6 +37,9 @@
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.PrintLabel, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
......@@ -178,6 +181,7 @@
<EmbeddedResource Include="UC\uc_boxdebug.resx">
<DependentUpon>uc_boxdebug.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!