1
This commit is contained in:
parent
c66b551d3b
commit
a4e259738c
@ -63,6 +63,7 @@ namespace DAL
|
||||
camere.SaveImangeOK = Convert.ToBoolean(row["SaveImangeOK"]);
|
||||
camere.SaveImangeNG = Convert.ToBoolean(row["SaveImangeNG"]);
|
||||
camere.SaveImageOri = Convert.ToBoolean(row["SaveImageOri"]);
|
||||
camere.RotateAngle = Convert.ToDouble(row["RotateAngle"]);
|
||||
list.Add(camere);
|
||||
|
||||
}
|
||||
@ -110,6 +111,7 @@ namespace DAL
|
||||
cam.SaveImangeOK = Convert.ToBoolean(row["SaveImangeOK"]);
|
||||
cam.SaveImangeNG = Convert.ToBoolean(row["SaveImangeNG"]);
|
||||
cam.SaveImageOri = Convert.ToBoolean(row["SaveImageOri"]);
|
||||
cam.RotateAngle = Convert.ToDouble(row["RotateAngle"]);
|
||||
}
|
||||
return cam;
|
||||
}
|
||||
@ -153,7 +155,7 @@ namespace DAL
|
||||
{
|
||||
try
|
||||
{
|
||||
string sqlstr = "update Camera set [MachineID]=@MachineID,[CamType]=@CamType,CamName=@CamName,FPS=@FPS,ExposureTime=@ExposureTime,Gain=@Gain,Img_Width=@Img_Width,Img_Height=@Img_Height,SaveImangeOK=@SaveImangeOK,SaveImangeNG=@SaveImangeNG,SaveImageOri=@SaveImageOri where ID=@ID";
|
||||
string sqlstr = "update Camera set [MachineID]=@MachineID,[CamType]=@CamType,CamName=@CamName,FPS=@FPS,ExposureTime=@ExposureTime,Gain=@Gain,Img_Width=@Img_Width,Img_Height=@Img_Height,SaveImangeOK=@SaveImangeOK,SaveImangeNG=@SaveImangeNG,SaveImageOri=@SaveImageOri,RotateAngle=@RotateAngle where ID=@ID";
|
||||
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@MachineID", cam.MachineID),
|
||||
new OleDbParameter("@CamType", cam.CamType),
|
||||
new OleDbParameter("@CamName", cam.CamName),
|
||||
@ -165,6 +167,7 @@ namespace DAL
|
||||
new OleDbParameter("@SaveImangeOK", cam.SaveImangeOK),
|
||||
new OleDbParameter("@SaveImangeNG", cam.SaveImangeNG),
|
||||
new OleDbParameter("@SaveImageOri", cam.SaveImageOri),
|
||||
new OleDbParameter("@RotateAngle", cam.RotateAngle),
|
||||
new OleDbParameter("@ID", cam.ID));
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@ -202,7 +202,7 @@ namespace Model
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
ReceiveCallback(ReceiveInfo);
|
||||
ReceiveCallback?.Invoke(ReceiveInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@ -342,6 +342,118 @@ namespace Model.Vision
|
||||
}
|
||||
#endregion
|
||||
|
||||
//#region 相机取像回调函数
|
||||
//private PixelDataConverter converter = new PixelDataConverter();
|
||||
//HObject ho_image;
|
||||
///// <summary>
|
||||
///// 相机取像回调函数
|
||||
///// </summary>
|
||||
///// <param name="sender"></param>
|
||||
///// <param name="e"></param>
|
||||
//private void OnImageGrabbed(Object sender, ImageGrabbedEventArgs e)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// IGrabResult grabResult = e.GrabResult;
|
||||
|
||||
// using (grabResult)
|
||||
// {
|
||||
// // 图像抓取成功
|
||||
// // if (grabResult.GrabSucceeded)
|
||||
// if (grabResult.IsValid)
|
||||
// {
|
||||
|
||||
// // 判断是否是黑白图片格式
|
||||
// if (grabResult.PixelTypeValue == PixelType.Mono8 || grabResult.PixelTypeValue == PixelType.YUV422_YUYV_Packed)
|
||||
// {
|
||||
// if (latestFrameAddress == IntPtr.Zero)
|
||||
// {
|
||||
|
||||
// latestFrameAddress = Marshal.AllocHGlobal((Int32)(grabResult.PayloadSize));
|
||||
// }
|
||||
|
||||
// converter.OutputPixelFormat = PixelType.Mono8; // 需与halcon转换的彩色图像格式一致
|
||||
// converter.Convert(latestFrameAddress, grabResult.PayloadSize, grabResult);
|
||||
|
||||
// // 转换为Halcon黑白图像显示
|
||||
// HOperatorSet.GenImage1(out ho_image, "byte", (HTuple)grabResult.Width, (HTuple)grabResult.Height, (HTuple)latestFrameAddress);
|
||||
|
||||
// }
|
||||
// else if (grabResult.PixelTypeValue == PixelType.BayerRG8 || grabResult.PixelTypeValue == PixelType.YUV422packed)
|
||||
// {
|
||||
|
||||
// if (latestFrameAddress == IntPtr.Zero)
|
||||
// {
|
||||
// latestFrameAddress = Marshal.AllocHGlobal((Int32)(3 * grabResult.PayloadSize));
|
||||
// }
|
||||
|
||||
|
||||
// converter.OutputPixelFormat = PixelType.BGR8packed; // 需与halcon转换的彩色图像格式一致
|
||||
|
||||
// converter.Convert(latestFrameAddress, 3 * grabResult.PayloadSize, grabResult);
|
||||
|
||||
|
||||
// // 转换为Halcon彩色图像显示
|
||||
// HOperatorSet.GenImageInterleaved(out ho_image, latestFrameAddress, "bgr", (HTuple)grabResult.Width, (HTuple)grabResult.Height, -1, "byte", (HTuple)grabResult.Width, (HTuple)grabResult.Height, 0, 0, -1, 0);
|
||||
|
||||
// }
|
||||
|
||||
// //是否进行图像旋转
|
||||
// if (RotateAngle > 0)
|
||||
// {
|
||||
// HObject temp = null;
|
||||
|
||||
// HOperatorSet.RotateImage(ho_image, out temp, RotateAngle, "constant");
|
||||
// ho_image = temp;
|
||||
// HTuple width = 0;
|
||||
// HTuple height = 0;
|
||||
// HOperatorSet.GetImageSize(ho_image, out width, out height);
|
||||
// Img_Width = width.I;
|
||||
// Img_Height = height.I;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// // 抛出图像处理事件
|
||||
// if (ContinuousAcquisition)
|
||||
// {
|
||||
// eventProcessImage(ho_image);
|
||||
// }
|
||||
|
||||
// if (SaveImageOri)
|
||||
// {
|
||||
// //创建文件夹
|
||||
// if (!Directory.Exists(@"D:/OriginalGraph/" + this.CamName + "/"))
|
||||
// {
|
||||
// Directory.CreateDirectory(@"D:/OriginalGraph/" + this.CamName + "/");
|
||||
// }
|
||||
|
||||
// string filePath = @"D:/OriginalGraph/" + this.CamName + "/" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".bmp"; //模板图片路径 //保存模板图片
|
||||
// HOperatorSet.WriteImage(ho_image, "bmp", 0, filePath);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ErrorMessage = grabResult.ErrorCode + "," + grabResult.ErrorDescription;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// ShowException(exception);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// // Dispose the grab result if needed for returning it to the grab loop.
|
||||
// e.DisposeGrabResultIfClone();
|
||||
|
||||
// }
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
|
||||
#region 相机取像回调函数
|
||||
private PixelDataConverter converter = new PixelDataConverter();
|
||||
HObject ho_image;
|
||||
@ -358,11 +470,12 @@ namespace Model.Vision
|
||||
|
||||
using (grabResult)
|
||||
{
|
||||
HObject myho_image = new HObject();
|
||||
// 图像抓取成功
|
||||
// if (grabResult.GrabSucceeded)
|
||||
if (grabResult.IsValid)
|
||||
{
|
||||
|
||||
|
||||
// 判断是否是黑白图片格式
|
||||
if (grabResult.PixelTypeValue == PixelType.Mono8 || grabResult.PixelTypeValue == PixelType.YUV422_YUYV_Packed)
|
||||
{
|
||||
@ -376,12 +489,12 @@ namespace Model.Vision
|
||||
converter.Convert(latestFrameAddress, grabResult.PayloadSize, grabResult);
|
||||
|
||||
// 转换为Halcon黑白图像显示
|
||||
HOperatorSet.GenImage1(out ho_image, "byte", (HTuple)grabResult.Width, (HTuple)grabResult.Height, (HTuple)latestFrameAddress);
|
||||
HOperatorSet.GenImage1(out myho_image, "byte", (HTuple)grabResult.Width, (HTuple)grabResult.Height, (HTuple)latestFrameAddress);
|
||||
|
||||
}
|
||||
else if (grabResult.PixelTypeValue == PixelType.BayerRG8 || grabResult.PixelTypeValue == PixelType.YUV422packed)
|
||||
{
|
||||
|
||||
|
||||
if (latestFrameAddress == IntPtr.Zero)
|
||||
{
|
||||
latestFrameAddress = Marshal.AllocHGlobal((Int32)(3 * grabResult.PayloadSize));
|
||||
@ -389,19 +502,38 @@ namespace Model.Vision
|
||||
|
||||
|
||||
converter.OutputPixelFormat = PixelType.BGR8packed; // 需与halcon转换的彩色图像格式一致
|
||||
|
||||
|
||||
converter.Convert(latestFrameAddress, 3 * grabResult.PayloadSize, grabResult);
|
||||
|
||||
|
||||
|
||||
// 转换为Halcon彩色图像显示
|
||||
HOperatorSet.GenImageInterleaved(out ho_image, latestFrameAddress, "bgr", (HTuple)grabResult.Width, (HTuple)grabResult.Height, -1, "byte", (HTuple)grabResult.Width, (HTuple)grabResult.Height, 0, 0, -1, 0);
|
||||
|
||||
HOperatorSet.GenImageInterleaved(out myho_image, latestFrameAddress, "bgr", (HTuple)grabResult.Width, (HTuple)grabResult.Height, -1, "byte", (HTuple)grabResult.Width, (HTuple)grabResult.Height, 0, 0, -1, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//是否进行图像旋转
|
||||
if (RotateAngle > 0)
|
||||
{
|
||||
HObject temp = null;
|
||||
|
||||
HOperatorSet.RotateImage(myho_image, out temp, RotateAngle, "constant");
|
||||
myho_image = temp;
|
||||
HTuple width = 0;
|
||||
HTuple height = 0;
|
||||
HOperatorSet.GetImageSize(myho_image, out width, out height);
|
||||
Img_Width = width.I;
|
||||
Img_Height = height.I;
|
||||
}
|
||||
ho_image = myho_image;
|
||||
|
||||
|
||||
|
||||
// 抛出图像处理事件
|
||||
if (ContinuousAcquisition)
|
||||
{
|
||||
eventProcessImage(ho_image);
|
||||
eventProcessImage(this.ho_image);
|
||||
}
|
||||
|
||||
if (SaveImageOri)
|
||||
@ -413,8 +545,9 @@ namespace Model.Vision
|
||||
}
|
||||
|
||||
string filePath = @"D:/OriginalGraph/" + this.CamName + "/" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".bmp"; //模板图片路径 //保存模板图片
|
||||
HOperatorSet.WriteImage(ho_image, "bmp", 0, filePath);
|
||||
HOperatorSet.WriteImage(this.ho_image, "bmp", 0, filePath);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -436,6 +569,7 @@ namespace Model.Vision
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 设置Gige相机心跳时间
|
||||
/// <summary>
|
||||
/// 设置Gige相机心跳时间
|
||||
|
||||
@ -278,7 +278,23 @@ namespace Model.Vision
|
||||
camBrand = value;
|
||||
this.RaisePropertyChanged("CamBrand");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 图像旋转角度
|
||||
private double rotateAngle;
|
||||
/// <summary>
|
||||
/// 图像旋转角度
|
||||
/// </summary>
|
||||
public double RotateAngle
|
||||
{
|
||||
get { return rotateAngle; }
|
||||
set
|
||||
{
|
||||
rotateAngle = value;
|
||||
this.RaisePropertyChanged("RotateAngle");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@ -258,6 +258,13 @@ namespace Model.Vision
|
||||
m_MyCamera.MV_CC_GetIntValueEx_NET("Height", ref a);
|
||||
Img_Height = (int)a.nCurValue;
|
||||
|
||||
//下相机Y翻转
|
||||
if (CamName.Contains("Down"))
|
||||
{
|
||||
m_MyCamera.MV_CC_SetBoolValue_NET("ReverseX", true);
|
||||
}
|
||||
|
||||
|
||||
GetMinMaxExposureTime();
|
||||
GetMinMaxGain();
|
||||
SetFPS(FPS);
|
||||
@ -984,6 +991,8 @@ namespace Model.Vision
|
||||
/// 获取图像
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
///
|
||||
|
||||
public void ReceiveImageWorkThread(object obj)
|
||||
{
|
||||
int nRet = MyCamera.MV_OK;
|
||||
@ -993,7 +1002,7 @@ namespace Model.Vision
|
||||
IntPtr pImageBuf = IntPtr.Zero;
|
||||
int nImageBufSize = 0;
|
||||
|
||||
ho_image = new HObject();
|
||||
HObject myho_image = new HObject();
|
||||
IntPtr pTemp = IntPtr.Zero;
|
||||
|
||||
while (m_bGrabbing)
|
||||
@ -1046,7 +1055,7 @@ namespace Model.Vision
|
||||
|
||||
try
|
||||
{
|
||||
HOperatorSet.GenImageInterleaved(out ho_image, (HTuple)pTemp, (HTuple)"rgb", (HTuple)stFrameOut.stFrameInfo.nWidth, (HTuple)stFrameOut.stFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
HOperatorSet.GenImageInterleaved(out myho_image, (HTuple)pTemp, (HTuple)"rgb", (HTuple)stFrameOut.stFrameInfo.nWidth, (HTuple)stFrameOut.stFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
@ -1098,7 +1107,7 @@ namespace Model.Vision
|
||||
}
|
||||
try
|
||||
{
|
||||
HOperatorSet.GenImage1Extern(out ho_image, "byte", stFrameOut.stFrameInfo.nWidth, stFrameOut.stFrameInfo.nHeight, pTemp, IntPtr.Zero);
|
||||
HOperatorSet.GenImage1Extern(out myho_image, "byte", stFrameOut.stFrameInfo.nWidth, stFrameOut.stFrameInfo.nHeight, pTemp, IntPtr.Zero);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
@ -1112,6 +1121,20 @@ namespace Model.Vision
|
||||
continue;
|
||||
}
|
||||
|
||||
//是否进行图像旋转
|
||||
if (RotateAngle != 0)
|
||||
{
|
||||
HObject temp = null;
|
||||
|
||||
HOperatorSet.RotateImage(myho_image, out temp, RotateAngle, "constant");
|
||||
myho_image = temp;
|
||||
HTuple width = 0;
|
||||
HTuple height = 0;
|
||||
HOperatorSet.GetImageSize(myho_image, out width, out height);
|
||||
Img_Width = width.I;
|
||||
Img_Height = height.I;
|
||||
}
|
||||
ho_image = myho_image;
|
||||
// 抛出图像处理事件
|
||||
if (ContinuousAcquisition)
|
||||
{
|
||||
@ -1130,6 +1153,8 @@ namespace Model.Vision
|
||||
HOperatorSet.WriteImage(this.ho_image, "bmp", 0, filePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
device.MV_CC_FreeImageBuffer_NET(ref stFrameOut);
|
||||
}
|
||||
else
|
||||
@ -1145,6 +1170,184 @@ namespace Model.Vision
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//public void ReceiveImageWorkThread(object obj)
|
||||
//{
|
||||
// int nRet = MyCamera.MV_OK;
|
||||
// MyCamera device = obj as MyCamera;
|
||||
// MyCamera.MV_FRAME_OUT stFrameOut = new MyCamera.MV_FRAME_OUT();
|
||||
|
||||
// IntPtr pImageBuf = IntPtr.Zero;
|
||||
// int nImageBufSize = 0;
|
||||
|
||||
// //ho_image = new HObject();
|
||||
// HObject myho_image = new HObject();
|
||||
// IntPtr pTemp = IntPtr.Zero;
|
||||
|
||||
// while (m_bGrabbing)
|
||||
// {
|
||||
// nRet = device.MV_CC_GetImageBuffer_NET(ref stFrameOut, 1000);
|
||||
// if (MyCamera.MV_OK == nRet)
|
||||
// {
|
||||
// if (IsColorPixelFormat(stFrameOut.stFrameInfo.enPixelType))
|
||||
// {
|
||||
// if (stFrameOut.stFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||
// {
|
||||
// pTemp = stFrameOut.pBufAddr;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (IntPtr.Zero == pImageBuf || nImageBufSize < (stFrameOut.stFrameInfo.nWidth * stFrameOut.stFrameInfo.nHeight * 3))
|
||||
// {
|
||||
// if (pImageBuf != IntPtr.Zero)
|
||||
// {
|
||||
// Marshal.FreeHGlobal(pImageBuf);
|
||||
// pImageBuf = IntPtr.Zero;
|
||||
// }
|
||||
|
||||
// pImageBuf = Marshal.AllocHGlobal((int)stFrameOut.stFrameInfo.nWidth * stFrameOut.stFrameInfo.nHeight * 3);
|
||||
// if (IntPtr.Zero == pImageBuf)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// nImageBufSize = stFrameOut.stFrameInfo.nWidth * stFrameOut.stFrameInfo.nHeight * 3;
|
||||
// }
|
||||
|
||||
// MyCamera.MV_PIXEL_CONVERT_PARAM stPixelConvertParam = new MyCamera.MV_PIXEL_CONVERT_PARAM();
|
||||
|
||||
// stPixelConvertParam.pSrcData = stFrameOut.pBufAddr;//源数据
|
||||
// stPixelConvertParam.nWidth = stFrameOut.stFrameInfo.nWidth;//图像宽度
|
||||
// stPixelConvertParam.nHeight = stFrameOut.stFrameInfo.nHeight;//图像高度
|
||||
// stPixelConvertParam.enSrcPixelType = stFrameOut.stFrameInfo.enPixelType;//源数据的格式
|
||||
// stPixelConvertParam.nSrcDataLen = stFrameOut.stFrameInfo.nFrameLen;
|
||||
|
||||
// stPixelConvertParam.nDstBufferSize = (uint)nImageBufSize;
|
||||
// stPixelConvertParam.pDstBuffer = pImageBuf;//转换后的数据
|
||||
// stPixelConvertParam.enDstPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed;
|
||||
// nRet = device.MV_CC_ConvertPixelType_NET(ref stPixelConvertParam);//格式转换
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// pTemp = pImageBuf;
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// HOperatorSet.GenImageInterleaved(out myho_image, (HTuple)pTemp, (HTuple)"rgb", (HTuple)stFrameOut.stFrameInfo.nWidth, (HTuple)stFrameOut.stFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||
// }
|
||||
// catch (System.Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.ToString());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// else if (IsMonoPixelFormat(stFrameOut.stFrameInfo.enPixelType))
|
||||
// {
|
||||
// if (stFrameOut.stFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8)
|
||||
// {
|
||||
// pTemp = stFrameOut.pBufAddr;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (IntPtr.Zero == pImageBuf || nImageBufSize < (stFrameOut.stFrameInfo.nWidth * stFrameOut.stFrameInfo.nHeight))
|
||||
// {
|
||||
// if (pImageBuf != IntPtr.Zero)
|
||||
// {
|
||||
// Marshal.FreeHGlobal(pImageBuf);
|
||||
// pImageBuf = IntPtr.Zero;
|
||||
// }
|
||||
|
||||
// pImageBuf = Marshal.AllocHGlobal((int)stFrameOut.stFrameInfo.nWidth * stFrameOut.stFrameInfo.nHeight);
|
||||
// if (IntPtr.Zero == pImageBuf)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// nImageBufSize = stFrameOut.stFrameInfo.nWidth * stFrameOut.stFrameInfo.nHeight;
|
||||
// }
|
||||
|
||||
// MyCamera.MV_PIXEL_CONVERT_PARAM stPixelConvertParam = new MyCamera.MV_PIXEL_CONVERT_PARAM();
|
||||
|
||||
// stPixelConvertParam.pSrcData = stFrameOut.pBufAddr;//源数据
|
||||
// stPixelConvertParam.nWidth = stFrameOut.stFrameInfo.nWidth;//图像宽度
|
||||
// stPixelConvertParam.nHeight = stFrameOut.stFrameInfo.nHeight;//图像高度
|
||||
// stPixelConvertParam.enSrcPixelType = stFrameOut.stFrameInfo.enPixelType;//源数据的格式
|
||||
// stPixelConvertParam.nSrcDataLen = stFrameOut.stFrameInfo.nFrameLen;
|
||||
|
||||
// stPixelConvertParam.nDstBufferSize = (uint)nImageBufSize;
|
||||
// stPixelConvertParam.pDstBuffer = pImageBuf;//转换后的数据
|
||||
// stPixelConvertParam.enDstPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8;
|
||||
// nRet = device.MV_CC_ConvertPixelType_NET(ref stPixelConvertParam);//格式转换
|
||||
// if (MyCamera.MV_OK != nRet)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// pTemp = pImageBuf;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// HOperatorSet.GenImage1Extern(out myho_image, "byte", stFrameOut.stFrameInfo.nWidth, stFrameOut.stFrameInfo.nHeight, pTemp, IntPtr.Zero);
|
||||
// }
|
||||
// catch (System.Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.ToString());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// device.MV_CC_FreeImageBuffer_NET(ref stFrameOut);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// //是否进行图像旋转
|
||||
// if (RotateAngle != 0)
|
||||
// {
|
||||
// HObject temp = null;
|
||||
// HOperatorSet.RotateImage(myho_image, out temp, RotateAngle, "constant");
|
||||
// ho_image = temp;
|
||||
// HTuple width = 0;
|
||||
// HTuple height = 0;
|
||||
// HOperatorSet.GetImageSize(myho_image, out width, out height);
|
||||
// Img_Width = width.I;
|
||||
// Img_Height = height.I;
|
||||
// }
|
||||
// ho_image = myho_image;
|
||||
// // 抛出图像处理事件
|
||||
// if (ContinuousAcquisition)
|
||||
// {
|
||||
// eventProcessImage(this.ho_image);
|
||||
// }
|
||||
|
||||
// if (SaveImageOri)
|
||||
// {
|
||||
// //创建文件夹
|
||||
// if (!Directory.Exists(@"D:/OriginalGraph/" + this.CamName + "/"))
|
||||
// {
|
||||
// Directory.CreateDirectory(@"D:/OriginalGraph/" + this.CamName + "/");
|
||||
// }
|
||||
|
||||
// string filePath = @"D:/OriginalGraph/" + this.CamName + "/" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".bmp"; //模板图片路径 //保存模板图片
|
||||
// HOperatorSet.WriteImage(this.ho_image, "bmp", 0, filePath);
|
||||
// }
|
||||
|
||||
// device.MV_CC_FreeImageBuffer_NET(ref stFrameOut);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (pImageBuf != IntPtr.Zero)
|
||||
// {
|
||||
// Marshal.FreeHGlobal(pImageBuf);
|
||||
// pImageBuf = IntPtr.Zero;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否是彩色
|
||||
/// </summary>
|
||||
@ -1204,5 +1407,7 @@ namespace Model.Vision
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ using Model.HSL;
|
||||
using Model.MotionControl;
|
||||
using Model.Vision;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
@ -1316,6 +1317,10 @@ namespace ViewModel
|
||||
|
||||
FrontStation = ServerComm.CommList.Where(w => w.ShortCode == "FS").FirstOrDefault();
|
||||
FrontStation.ReceiveCallback += FrontStation_ReceiveCallback;
|
||||
|
||||
TestMachine = ServerComm.CommList.Where(w => w.ShortCode == "Force").FirstOrDefault();
|
||||
TestMachine.ReceiveCallback += TestMachine_ReceiveCallback;
|
||||
|
||||
}
|
||||
|
||||
#region 获取输出信号Grid
|
||||
@ -1556,7 +1561,8 @@ namespace ViewModel
|
||||
#region 2、状态监控
|
||||
|
||||
int A1, A2;
|
||||
|
||||
string lastMsg;
|
||||
int msgNumber;
|
||||
/// <summary>
|
||||
/// 状态监控
|
||||
/// </summary>
|
||||
@ -1616,22 +1622,21 @@ namespace ViewModel
|
||||
|
||||
GoHome(); //回原点
|
||||
|
||||
//测试中,获取测试结果
|
||||
if (Testing)
|
||||
if (lastMsg != TestRecStr)
|
||||
{
|
||||
if (TestRecStr.Contains("TESTOK"))
|
||||
CacheLineList[1].State.StatuInfo = lastMsg;
|
||||
CacheLineList[0].State.StatuInfo = TestRecStr;
|
||||
msgNumber++;
|
||||
info = new RecordInfo() { Number = msgNumber, HappenTime = DateTime.Now, Describe = TestRecStr };
|
||||
//异步新增项 这是微软的BUG 只能这么麻烦了
|
||||
MyDispatcher.BeginInvoke(DispatcherPriority.Background, new ParameterizedThreadStart(AddItem), info);
|
||||
|
||||
lastMsg = TestRecStr;
|
||||
if (ExcepList.Count > 50)
|
||||
{
|
||||
Testing = false; //测试结束
|
||||
TestFinish = true; //测试完成信号
|
||||
}
|
||||
else if (TestRecStr.Contains("ALARM")) //测试机回复报错
|
||||
{
|
||||
TestResultStr = "NG";
|
||||
Testing = false; //测试结束
|
||||
TestFinish = true; //测试完成信号
|
||||
MyDispatcher.BeginInvoke(DispatcherPriority.Background, new ParameterizedThreadStart(DelItem), info);
|
||||
}
|
||||
}
|
||||
|
||||
DualControlRun();//双控运行
|
||||
|
||||
GoHome(); //回原点
|
||||
@ -2525,7 +2530,6 @@ namespace ViewModel
|
||||
break;
|
||||
case GengralProcessEnum.Step1:
|
||||
//获取下视觉扫码点
|
||||
//下视觉点位
|
||||
TempPoint = Coper(CurrentMachine.RobotPointList.Where(w => w.PointType == 10).FirstOrDefault());
|
||||
//发送机器人点位
|
||||
Robot.RunRobotPoint(TempPoint);
|
||||
@ -2547,7 +2551,7 @@ namespace ViewModel
|
||||
break;
|
||||
case GengralProcessEnum.Step3:
|
||||
//获取下视觉模板
|
||||
RM = VisualB.VisualEngineeringList[0].VisualEngineeringItemsList[1].MyRectangleModel;
|
||||
RM = VisualB.VisualEngineeringList[0].VisualEngineeringItemsList[2].MyRectangleModel;
|
||||
VisonCount = 0;
|
||||
OutputList[Y11下光源控制].Switchs = true;//光源
|
||||
MyFlow.RunStep++;
|
||||
@ -2573,7 +2577,7 @@ namespace ViewModel
|
||||
}
|
||||
break;
|
||||
case GengralProcessEnum.Step5:
|
||||
//下视觉点位
|
||||
//下视觉定位点位
|
||||
TempPoint = Coper(CurrentMachine.RobotPointList.Where(w => w.PointType == 8).FirstOrDefault());
|
||||
//发送机器人点位
|
||||
Robot.RunRobotPoint(TempPoint);
|
||||
@ -2624,7 +2628,7 @@ namespace ViewModel
|
||||
if (Math.Abs(RM.MyROI.ModelFeaturePiont.AngleU) < 10)
|
||||
{
|
||||
CurrXizui.OfficeU = (double)RM.MyROI.ModelFeaturePiont.AngleU;
|
||||
TempPoint.PointU += (double)RM.MyROI.ModelFeaturePiont.AngleU;
|
||||
TempPoint.PointU -= (double)RM.MyROI.ModelFeaturePiont.AngleU;
|
||||
TempPoint.SpeedGear = 40;
|
||||
MyFlow.RunStep++;
|
||||
MyFlow.RunTime = DateTime.Now;
|
||||
@ -2701,7 +2705,7 @@ namespace ViewModel
|
||||
if (Math.Abs(RM.MyROI.ModelFeaturePiont.DeviationX) < 10 && Math.Abs(RM.MyROI.ModelFeaturePiont.DeviationY) < 10)
|
||||
{
|
||||
CurrXizui.OfficeX = (double)RM.MyROI.ModelFeaturePiont.DeviationX;
|
||||
CurrXizui.OfficeY = -(double)RM.MyROI.ModelFeaturePiont.DeviationY;
|
||||
CurrXizui.OfficeY = (double)RM.MyROI.ModelFeaturePiont.DeviationY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2755,9 +2759,9 @@ namespace ViewModel
|
||||
TempPoint = Coper(CurrBox.PutProPoint1);
|
||||
|
||||
//下视觉定位补偿
|
||||
TempPoint.PointX += CurrXizui.OfficeX;
|
||||
TempPoint.PointX -= CurrXizui.OfficeX;
|
||||
TempPoint.PointY += CurrXizui.OfficeY;
|
||||
TempPoint.PointU += CurrXizui.OfficeU;
|
||||
TempPoint.PointU -= CurrXizui.OfficeU;
|
||||
MyFlow.RunStep++;
|
||||
MyFlow.RunTime = DateTime.Now;
|
||||
break;
|
||||
@ -4020,7 +4024,7 @@ namespace ViewModel
|
||||
/// 测试成功信号,测试机回复
|
||||
/// </summary>
|
||||
bool TestFinish { get; set; }
|
||||
|
||||
int QUERY = 0;
|
||||
/// <summary>
|
||||
/// 测试机回调函数
|
||||
/// </summary>
|
||||
@ -4029,13 +4033,66 @@ namespace ViewModel
|
||||
{
|
||||
if (!String.IsNullOrEmpty(str))
|
||||
{
|
||||
TestRecStr = str;
|
||||
|
||||
if (str.Contains("TEST"))
|
||||
if (str.Contains("TESTOK"))
|
||||
{
|
||||
TestResultStr = TestRecStr;
|
||||
QUERY = 0;
|
||||
var real = str.Replace("QUERY?", "");
|
||||
TestRecStr = real;
|
||||
TestResultStr = real;
|
||||
|
||||
}
|
||||
|
||||
else if (str.Contains("LOAD"))
|
||||
{
|
||||
QUERY = 0;
|
||||
var real = str.Replace("QUERY?", "");
|
||||
real = real.Replace("QUERY?", "");
|
||||
TestRecStr = real;
|
||||
|
||||
}
|
||||
else if (str.Contains("ALARM"))
|
||||
{
|
||||
QUERY = 0;
|
||||
TestRecStr = str;
|
||||
|
||||
}
|
||||
else if (str.Contains("QUERY"))
|
||||
{
|
||||
if (RunStatu == RunStatuEnum.Normal)
|
||||
{
|
||||
QUERY++;
|
||||
if (QUERY > 20)
|
||||
{
|
||||
QUERY = 0;
|
||||
|
||||
TestRecStr = str;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
QUERY = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//测试中,获取测试结果
|
||||
if (Testing)
|
||||
{
|
||||
if (TestRecStr.Contains("TESTOK"))
|
||||
{
|
||||
Testing = false; //测试结束
|
||||
TestFinish = true; //测试完成信号
|
||||
}
|
||||
else if (TestRecStr.Contains("ALARM")) //测试机回复报错
|
||||
{
|
||||
TestResultStr = "NG";
|
||||
Testing = false; //测试结束
|
||||
TestFinish = true; //测试完成信号
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -4911,6 +4968,14 @@ namespace ViewModel
|
||||
{
|
||||
ExcepList.Add((RecordInfo)info);
|
||||
}
|
||||
|
||||
void DelItem(object info)
|
||||
{
|
||||
|
||||
ExcepList.Clear();
|
||||
RaisePropertyChanged("ExcepList");
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 记录检查平结果LOG
|
||||
/// </summary>
|
||||
|
||||
@ -1848,8 +1848,8 @@ namespace ViewModel.Vision
|
||||
HOperatorSet.AffineTransPoint2d(RM.hv_JiuDianCalibrationPar, (HTuple)RM.MyROI.ModelFeaturePiont.PixelRow, (HTuple)RM.MyROI.ModelFeaturePiont.PixelColumn, out PixelRow, out PixelColumn);
|
||||
HOperatorSet.AffineTransPoint2d(RM.hv_JiuDianCalibrationPar, (HTuple)RM.MyROI.ModelFeaturePiont.hv_RefRow, (HTuple)RM.MyROI.ModelFeaturePiont.hv_RefColumn, out hv_RefRow, out hv_RefColumn);
|
||||
|
||||
RM.MyROI.ModelFeaturePiont.DeviationX = Convert.ToDecimal((double)hv_RefRow - (double)PixelRow);
|
||||
RM.MyROI.ModelFeaturePiont.DeviationY = Convert.ToDecimal((double)(hv_RefColumn - PixelColumn));
|
||||
RM.MyROI.ModelFeaturePiont.DeviationX = Convert.ToDecimal((double)(hv_RefColumn - PixelColumn));
|
||||
RM.MyROI.ModelFeaturePiont.DeviationY = Convert.ToDecimal((double)hv_RefRow - (double)PixelRow);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -122,6 +122,12 @@
|
||||
<TextBlock Text="图片保留天数" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
</Viewbox>
|
||||
<ComboBox Grid.Row="8" Grid.Column="6" Grid.ColumnSpan="2" FontSize="20" VerticalAlignment="Center" ItemsSource="{Binding RetentionDaysImageList}" SelectedItem="{Binding MachineObj.RetentionDaysImageNumber}" Background="#4CFFFFFF" Foreground="White"/>
|
||||
|
||||
<Viewbox Grid.Row="12" Grid.Column="4" Grid.ColumnSpan="2">
|
||||
<TextBlock Text="图像旋转(度)" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" />
|
||||
</Viewbox>
|
||||
<TextBox Grid.Row="12" Grid.Column="6" Grid.ColumnSpan="2" HorizontalContentAlignment="Left" VerticalAlignment="Center" Text="{Binding Camera.RotateAngle}" Background="#4CFFFFFF" Foreground="White" FontSize="20"/>
|
||||
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="功能编辑">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user