Commit 27e78cae 几米阳光

修改扫码方式。修改硕科通信代码。

1 个父辈 b6fa137c
此文件类型无法预览
此文件类型无法预览
......@@ -73,12 +73,6 @@
<Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon>
</Compile>
<Compile Include="FrmCamera.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmCamera.Designer.cs">
<DependentUpon>FrmCamera.cs</DependentUpon>
</Compile>
<Compile Include="FrmIOStatus.cs">
<SubType>Form</SubType>
</Compile>
......@@ -106,9 +100,6 @@
<EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmCamera.resx">
<DependentUpon>FrmCamera.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmIOStatus.resx">
<DependentUpon>FrmIOStatus.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -78,6 +78,7 @@
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(215, 33);
this.txtPwd.TabIndex = 276;
this.txtPwd.Text = "123456";
this.txtPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown);
//
// FrmPwd
......
......@@ -999,13 +999,12 @@ namespace OnlineStore.ACSingleStore
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string message = "";
string outMsg = "";
List<string> codeList = HDevelopExport.CameraScan(out outMsg);
List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList)
{
string code = HDevelopExport.SubStrCode(str);
message = message + code + "##";
message = message + str + "##";
}
LogUtil.info("扫码测试收到二维码【"+outMsg+"】:" + message);
LogUtil.info("扫码测试收到二维码【" + outMsg + "】:" + message);
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
}
......@@ -1307,20 +1306,13 @@ namespace OnlineStore.ACSingleStore
}
}
private void 摄像机调试ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmCamera frm = new FrmCamera(store);
frm.ShowDialog();
}
private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e)
{
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
FrmCodeLearn learn = new FrmCodeLearn();
learn.ShowDialog();
CodeLibrary.FrmCodeDecode frm = new FrmCodeDecode();
frm.ShowDialog();
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
}
......@@ -1349,7 +1341,8 @@ namespace OnlineStore.ACSingleStore
}
private void btnGetPosition_Click(object sender, EventArgs e)
{
ShuoKeControls.GetABSPosition(store.Config.CompressAxis_Slv);
int value = ShuoKeControls.GetABSPosition(store.Config.CompressAxis_Slv);
lblShuoKeMsg.Text = DateTime.Now.ToLongTimeString() + "实时位置:" + value;
}
private void btnStop_Click(object sender, EventArgs e)
{
......@@ -1373,10 +1366,11 @@ namespace OnlineStore.ACSingleStore
{
int posi = FormUtil.GetIntValue(txtLinePosition);
ShuoKeControls.RelativeMove(this.store.Config.CompressAxis_Slv, posi);
}
}
private void btnStatusSearch_Click(object sender, EventArgs e)
{
ShuoKeControls.GetStatus(store.Config.CompressAxis_Slv);
ShuoKeInfo info = ShuoKeControls.GetStatus(store.Config.CompressAxis_Slv);
lblShuoKeMsg.Text = info.ToShowStr();
}
private void FormComStatus(bool isOpen)
{
......
......@@ -3,13 +3,9 @@
1.使用硕科步进电机作为压紧轴
2.温湿度修改为com通信
3.增加安全光栅信号,当叉子出料过程中,遮挡光栅会暂停进出轴移动,光栅正常时再恢复移动
4.增加模拟量IO
4.增加模拟量IO
20181107
1.出库时等待10秒钟,或等待拿走料盘(高度=0)才算出库结束
1.出库时等待10秒钟,或等待拿走料盘(高度=0)才算出库结束
20181108
// 机器状态 顶灯显示
// 绿 黄 红
......@@ -36,10 +32,11 @@
在原来认为高度是8的基础上,再判断三个测高如果有一个高度>=9,则认定为12的料盘。
20181213
20181213
在RC26联电项目基础上拉取分支,作为RC33珠海料仓项目。
需要修改内容:扫码改为通用扫码类型。
硕科改为实时返回数据的通讯方式。
硕科压紧轴需要增加机构检测信号的处理。
......
......@@ -59,7 +59,7 @@
<Compile Include="acSingleStore\AC_SA_BoxBean.cs" />
<Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" />
<Compile Include="acSingleStore\ACStoreManager.cs" />
<Compile Include="halcon\HDevelopExport.cs" />
<Compile Include="halcon\CodeManager.cs" />
<Compile Include="KangNaiDe\AITcpClient.cs" />
<Compile Include="KangNaiDe\KNDAIManager.cs" />
<Compile Include="KangNaiDe\KNDManager.cs" />
......@@ -67,6 +67,7 @@
<Compile Include="PanasonicServo\ACCMDManager.cs" />
<Compile Include="PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="ShuoKe\ShuoKeController.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType>
......@@ -75,7 +76,6 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShuoKe\ShuoKeControls.cs" />
<Compile Include="store\model\AxisAlarmInfo.cs" />
<Compile Include="store\model\FixtureCodeInfo.cs" />
<Compile Include="store\KTK_DeviceBase.cs" />
......
......@@ -315,8 +315,11 @@ namespace OnlineStore.DeviceLibrary
}
else if (dataByte.Length == 2)
{
sendData[4] = dataByte[1];
sendData[5] = dataByte[0];
sendData[4] = dataByte[0];
sendData[5] = dataByte[1];
//sendData[4] = dataByte[1];
//sendData[5] = dataByte[0];
}
sendData = buildCheckData(sendData, sendData.Length - 2);
......
......@@ -89,7 +89,7 @@ namespace OnlineStore.DeviceLibrary
//初始化摄像机配置
string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
HDevelopExport.LoadConfig(nameStr,codeStr);
CodeManager.LoadConfig(nameStr,codeStr);
//初始化 //连接设备
KNDManager.ConnectionKND(Config.DIODeviceNameList);
......@@ -190,10 +190,7 @@ namespace OnlineStore.DeviceLibrary
//启动温湿度服务器
//HumitureServer.StartTemperateServer(Config.TemperateServer_Port);
HumitureController.Init(Config.Humiture_Port);
Task.Factory.StartNew(delegate ()
{
HDevelopExport.OpenAllCamera();
});
ReturnHome();
StartTime = DateTime.Now;
mainTimer.Enabled = true;
......@@ -283,10 +280,7 @@ namespace OnlineStore.DeviceLibrary
autoNext = false;
}
Task.Factory.StartNew(delegate ()
{
HDevelopExport.OpenAllCamera();
});
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
......@@ -690,8 +684,7 @@ namespace OnlineStore.DeviceLibrary
if (IsHasCompress_Axis)
{
ShuoKeControls.ClosePort();
}
HDevelopExport.CloseAllCamera();
}
HumitureServer.StopTemperateServer();
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
......@@ -1339,7 +1332,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "StopMove");
KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW);
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
HDevelopExport.CloseAllCamera();
isInPro = false;
}
......@@ -1499,12 +1492,16 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string outMsg = "";
string message = "";
List<string> codeList = HDevelopExport.CameraScan(out outMsg);
List<string> codeList = CodeManager.CameraScan();
if (codeList.Count <= 0)
{
codeList = CodeManager.CameraScan();
}
//= 1 + 123.4x100.5 - 7x12 = CODE
foreach (string str in codeList)
{
string code = HDevelopExport.SubStrCode(str);
string code = str;
code = "=1+0x0-7x" + height + " =" + code;
message = message + code + spiltStr;
}
......
......@@ -180,7 +180,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime, out info);
wait.IsEnd = ShuoKeControls.IsMoveEnd(wait.SlvAddr,wait.TargetPosition, StoreMove.LastSetpTime, out info);
}
if (!wait.IsEnd)
{
......@@ -192,7 +192,7 @@ namespace OnlineStore.DeviceLibrary
NotOkMsg += "" +info.ToShowStr();
}
ShuoKeControls.GetStatus(wait.SlvAddr);
//ShuoKeControls.GetStatus(wait.SlvAddr);
}
}
if (wait.IsEnd)
......
using CodeLibrary;
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class CodeManager
{
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
public static List<string> balserNameList = new List<string>();
public static List<string> hikNameList = new List<string>();
private static char spiltChar = '#';
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
/// <param name="nameStr">摄像机名称,多个用#分割</param>
/// <param name="codeStr">二维码类型,多个用#分割</param>
public static void LoadConfig(string nameStr, string codeStr)
{
cameraNameList = new List<string>();
codeTypeList = new List<string>();
try
{
string[] nameArray = nameStr.Split(spiltChar);
foreach (string str in nameArray)
{
LogUtil.info("加载到配置摄像机名称:" + str.Trim());
cameraNameList.Add(str.Trim());
}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
LogUtil.info("加载到配置二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
foreach(string str in names)
{
LogUtil.info("加载到HIK相机:" + str.Trim());
}
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string str in names)
{
LogUtil.info("加载到Balser相机:" + str.Trim());
}
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
if (balserNameList.Contains(cameraName))
{
BaslerCamera.Instance.Open(cameraName);
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
}
else if(hikNameList.Contains(cameraName))
{
HIKCamera.Instance.Open(cameraName);
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close();
}
else
{
LogUtil.info("未找到摄像机【"+cameraName+"】无法获取图片");
}
return bitm;
}
public static List<string> CameraScan( )
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
try
{
foreach (string cameraName in cameraNameList)
{
Bitmap bitmap = GetCamerImage(cameraName);
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
}
else
{
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
allCodeList.AddRange(cc);
}
}
}
catch (Exception ex)
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach(CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
return codeList;
}
public static string GetCodeParamFilePath(string codePath)
{
string appPath = Application.StartupPath;
string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
string filePath = path + codePath + ".dcm";
if (File.Exists(filePath))
{
return filePath;
}
else
{
return "";
}
}
}
}
using HalconDotNet;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace OnlineStore.DeviceLibrary
{
public class HDevelopCodeLearn
{
public static HWindow hv_ExpDefaultWinHandle;
public static HTuple hv_AcqHandle = null;
public static void HDevelopStop()
{
//MessageBox.Show("Press button to continue", "Program stop");
}
public static void InitHalcon()
{
// Default settings used in HDevelop
HOperatorSet.SetSystem("width", 512);
HOperatorSet.SetSystem("height", 512);
}
public static void RunHalcon(HWindow Window, string camerName, string codeType, string paramPath, int codeCount)
{
InitHalcon();
hv_ExpDefaultWinHandle = Window;
action(camerName, codeType, paramPath, codeCount);
}
private static bool OpenCamera(string cameraName)
{
try
{ //[1] HD USB Camera
HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1,
"default", -1, "false", "default", cameraName, 0, -1, out hv_AcqHandle);
//HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb",
// -1, "false", "default", "[1] HD USB Camera", 0, -1, out hv_AcqHandle);
return true;
}
catch (Exception ex)
{
LogUtil.error("打开摄像机失败:" + ex.ToString() + ",调用关闭摄像头");
CloseCamera(cameraName);
return false;
}
}
private static void CloseCamera(string cameraName)
{
try
{
HOperatorSet.CloseFramegrabber(hv_AcqHandle);
hv_AcqHandle = null;
}
catch (Exception ex)
{
LogUtil.error("关闭摄像机失败:" + ex.ToString());
}
}
public static bool IsRun = false;
// Main procedure
private static bool action(string cameraName, string codeType, string paramPath, int codeCount)
{
IsRun = true;
IsLearnEnd = false;
IsTestEnd = false;
try
{
HTuple hv_code_type = codeType;
HTuple hv_model_path = paramPath;
HObject ho_Image = null, ho_SymbolXLDs = null;
HTuple hv_train_first = null, /*hv_AcqHandle = null,*/ hv_DataCodeHandle = null;
HTuple hv_ResultHandles = new HTuple(), hv_DecodedDataStrings = new HTuple();
HTuple hv_GenParamNames = new HTuple(), hv_ModelBeforeTraining = new HTuple();
// Initialize local and output iconic variables
HOperatorSet.GenEmptyObj(out ho_Image);
HOperatorSet.GenEmptyObj(out ho_SymbolXLDs);
//Image Acquisition 04: Code generated by Image Acquisition 04
//Image Acquisition 01: Code generated by Image Acquisition 01
//hv_code_type = "Data Matrix ECC 200";
//hv_model_path = ("E:/BaiduNetdiskDownload/" + hv_code_type) + ".dcm";
hv_train_first = 1;
if (!OpenCamera(cameraName))
{
return false ;
}
//HOperatorSet.GrabImageStart(hv_AcqHandle, -1);
HOperatorSet.CreateDataCode2dModel(hv_code_type, new HTuple(), new HTuple(),
out hv_DataCodeHandle);
//set_data_code_2d_param (DataCodeHandle, 'strict_model', 'yes')
//set_data_code_2d_param (DataCodeHandle, 'persistence', 0)
//set_data_code_2d_param (DataCodeHandle, 'polarity', 'light_on_dark')
List<string> findCode = new List<string>();
if ((int)(hv_train_first) != 0)
{
while (findCode.Count < codeCount&&IsLearnEnd.Equals(false ))
{
ho_Image.Dispose();
HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
//Image Acquisition 04: Do something
//write_image (Image, 'jpeg', 0, 'E:/BaiduNetdiskDownload/fuba2.jpg')
if (ho_Image != null)
{
ho_SymbolXLDs.Dispose();
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
"train", "all", out hv_ResultHandles, out hv_DecodedDataStrings);
if ((int)(new HTuple((new HTuple(hv_DecodedDataStrings.TupleLength())).TupleNotEqual(
0))) != 0)
{
HOperatorSet.QueryDataCode2dParams(hv_DataCodeHandle, "get_model_params",
out hv_GenParamNames);
HOperatorSet.GetDataCode2dParam(hv_DataCodeHandle, hv_GenParamNames, out hv_ModelBeforeTraining);
HDevelopStop();
string[] resultList = hv_DecodedDataStrings.SArr;
foreach (string str in resultList)
{
if (!findCode.Contains(str))
{
LogUtil.info("["+cameraName + "][" + codeType + "]学习【" + str+"】");
findCode.Add(str);
}
}
}
ShowImage(ho_Image,ho_SymbolXLDs);
}
Thread.Sleep(500);
}
//*参数写入文件
LogUtil.info("["+cameraName + "][" + codeType + "]保存参数到文件【" + paramPath+"】");
HOperatorSet.WriteDataCode2dModel(hv_DataCodeHandle, hv_model_path);
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
}
//Read the previously saved data code model
findCode = new List<string>();
HOperatorSet.ReadDataCode2dModel(hv_model_path, out hv_DataCodeHandle);
while (findCode.Count < codeCount&&IsTestEnd.Equals(false ))
{
ho_Image.Dispose();
HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
//Image Acquisition 04: Do something
//write_image (Image, 'jpeg', 0, 'E:/BaiduNetdiskDownload/fuba2.jpg')
if (ho_Image != null)
{
ho_SymbolXLDs.Dispose();
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
"stop_after_result_num", 5, out hv_ResultHandles, out hv_DecodedDataStrings);
ShowImage(ho_Image,ho_SymbolXLDs);
if ((int)(new HTuple((new HTuple(hv_DecodedDataStrings.TupleLength())).TupleNotEqual(
0))) != 0)
{
string[] resultList = hv_DecodedDataStrings.SArr;
foreach (string str in resultList)
{
if (!findCode.Contains(str))
{
findCode.Add(str);
LogUtil.info("[" + cameraName + "][" + codeType + "]检测到【" + str + "】");
}
}
}
}
Thread.Sleep(500);
}
HOperatorSet.ClearDataCode2dModel(hv_DataCodeHandle);
CloseCamera(cameraName);
ho_Image.Dispose();
ho_SymbolXLDs.Dispose();
IsRun = false;
return true;
}catch(Exception ex)
{
LogUtil.error("出错了:" + ex.ToString());
CloseCamera(cameraName);
IsRun = false;
return false;
}
}
public static bool IsTestEnd = false;
public static bool IsLearnEnd = false;
public static void StopLearn()
{
IsTestEnd = true;
IsLearnEnd = true;
}
private static int dWidth = 0;
private static int dHeight = 0;
private static void ShowImage(HObject ho_Image,HObject ho_SymbolXLDs)
{
if (dWidth <= 0)
{
HTuple width, height;
//int dWidth = 0; int dHeight = 0;
HOperatorSet.GetImageSize(ho_Image, out width, out height);
dWidth = (int)width.D;
dHeight = (int)height.D;
hv_ExpDefaultWinHandle.SetPart(0, 0, dHeight, dWidth);
}
HOperatorSet.DispObj(ho_Image, hv_ExpDefaultWinHandle);
HOperatorSet.DispObj(ho_SymbolXLDs, hv_ExpDefaultWinHandle);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!