Commit 13d512f3 刘韬

添加监控相机显示

1 个父辈 92694de8
......@@ -95,6 +95,10 @@
<level value="Info" />
<appender-ref ref="AIOBOX" />
</logger>
<logger name="HIK.IPCamera" additivity="false">
<level value="All" />
<appender-ref ref="Camera" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="RollingLogFileAppender" />
......@@ -135,4 +139,12 @@
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name= "log4net" culture= "neutral" publicKeyToken= "669e0ddf0bb1aa2a" Retargetable= "Yes"/>
<bindingRedirect oldVersion= "0.0.0.0-9.9.9.0" newVersion= "2.0.12.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
......@@ -38,14 +38,16 @@
<ApplicationIcon>box.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
<Reference Include="CodeLibrary, Version=1.0.7844.17688, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\GeneralClassLibrary\CodeLibraryProject\CodeLibrary\bin\Debug\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\dll\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......
......@@ -61,6 +61,7 @@
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.btnClearLog = new System.Windows.Forms.Button();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.chbDebug = new System.Windows.Forms.CheckBox();
this.lblThisSta = new System.Windows.Forms.Label();
......@@ -159,6 +160,8 @@
this.btnUpDownP6 = new System.Windows.Forms.Button();
this.btnUpDownP3 = new System.Windows.Forms.Button();
this.btnUpDownP4 = new System.Windows.Forms.Button();
this.tabPage6 = new System.Windows.Forms.TabPage();
this.uc_boxdebug1 = new OnlineStore.ACSingleStore.useControl.uc_boxdebug();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.料仓操作ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.启动ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -212,14 +215,13 @@
this.英文ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator22 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
this.tabPage6 = new System.Windows.Forms.TabPage();
this.uc_boxdebug1 = new OnlineStore.ACSingleStore.useControl.uc_boxdebug();
this.contextMenuStrip1.SuspendLayout();
this.groupAuto.SuspendLayout();
this.groupBox6.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage4.SuspendLayout();
this.tabPage5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox3.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picAxis4)).BeginInit();
......@@ -227,8 +229,8 @@
this.groupBox7.SuspendLayout();
this.groupAxis.SuspendLayout();
this.groupInout.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.tabPage6.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// timer1
......@@ -463,7 +465,7 @@
this.groupBox6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox6.Location = new System.Drawing.Point(8, 119);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(1230, 286);
this.groupBox6.Size = new System.Drawing.Size(1230, 276);
this.groupBox6.TabIndex = 302;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "批量上下料操作";
......@@ -656,6 +658,7 @@
//
// tabPage5
//
this.tabPage5.Controls.Add(this.pictureBox1);
this.tabPage5.Controls.Add(this.groupBox6);
this.tabPage5.Controls.Add(this.groupBox3);
this.tabPage5.Location = new System.Drawing.Point(4, 30);
......@@ -665,6 +668,19 @@
this.tabPage5.Text = "设备信息";
this.tabPage5.UseVisualStyleBackColor = true;
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Gainsboro;
this.pictureBox1.Location = new System.Drawing.Point(8, 401);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(411, 234);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 303;
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_Click);
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
......@@ -1986,6 +2002,25 @@
this.btnUpDownP4.UseVisualStyleBackColor = true;
this.btnUpDownP4.Click += new System.EventHandler(this.btnUpDownP4_Click);
//
// tabPage6
//
this.tabPage6.Controls.Add(this.uc_boxdebug1);
this.tabPage6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabPage6.Location = new System.Drawing.Point(4, 30);
this.tabPage6.Name = "tabPage6";
this.tabPage6.Padding = new System.Windows.Forms.Padding(3);
this.tabPage6.Size = new System.Drawing.Size(1249, 659);
this.tabPage6.TabIndex = 6;
this.tabPage6.Text = "库位调试";
this.tabPage6.UseVisualStyleBackColor = true;
//
// uc_boxdebug1
//
this.uc_boxdebug1.Location = new System.Drawing.Point(6, 6);
this.uc_boxdebug1.Name = "uc_boxdebug1";
this.uc_boxdebug1.Size = new System.Drawing.Size(1076, 596);
this.uc_boxdebug1.TabIndex = 0;
//
// menuStrip1
//
this.menuStrip1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
......@@ -2368,25 +2403,6 @@
this.toolStripMenuItem6.Text = "日语";
this.toolStripMenuItem6.Click += new System.EventHandler(this.toolStripMenuItem6_Click);
//
// tabPage6
//
this.tabPage6.Controls.Add(this.uc_boxdebug1);
this.tabPage6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabPage6.Location = new System.Drawing.Point(4, 30);
this.tabPage6.Name = "tabPage6";
this.tabPage6.Padding = new System.Windows.Forms.Padding(3);
this.tabPage6.Size = new System.Drawing.Size(1249, 659);
this.tabPage6.TabIndex = 6;
this.tabPage6.Text = "库位调试";
this.tabPage6.UseVisualStyleBackColor = true;
//
// uc_boxdebug1
//
this.uc_boxdebug1.Location = new System.Drawing.Point(6, 6);
this.uc_boxdebug1.Name = "uc_boxdebug1";
this.uc_boxdebug1.Size = new System.Drawing.Size(1076, 596);
this.uc_boxdebug1.TabIndex = 0;
//
// FrmStoreBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
......@@ -2412,6 +2428,7 @@
this.tabControl1.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tabPage5.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.tabPage2.ResumeLayout(false);
......@@ -2424,9 +2441,9 @@
this.groupAxis.PerformLayout();
this.groupInout.ResumeLayout(false);
this.groupInout.PerformLayout();
this.tabPage6.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.tabPage6.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
......@@ -2628,6 +2645,7 @@
private System.Windows.Forms.CheckBox chbDebug;
private System.Windows.Forms.TabPage tabPage6;
private ACSingleStore.useControl.uc_boxdebug uc_boxdebug1;
private System.Windows.Forms.PictureBox pictureBox1;
}
}
......@@ -25,6 +25,7 @@ namespace OnlineStore.AutoInOutStore
private AC_SA_BoxBean store;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
HIKCamera camera = new HIKCamera();
public FrmStoreBox()
{
Control.CheckForIllegalCrossThreadCalls = false;
......@@ -39,6 +40,15 @@ namespace OnlineStore.AutoInOutStore
private void initValue()
{
InitStoreValue();
camera.camera_event += Camera_camera_event;
camera.LoadCameraConfig();
}
private void Camera_camera_event(object sender, Bitmap e)
{
this.Invoke((EventHandler<Bitmap>)delegate {
pictureBox1.Visible = true;
pictureBox1.Image = e;
}, sender, e);
}
private void InitStoreValue()
{
......@@ -207,7 +217,6 @@ namespace OnlineStore.AutoInOutStore
启动ToolStripMenuItem.Enabled = !isOpen;
停止ToolStripMenuItem.Enabled = isOpen;
复位ToolStripMenuItem.Enabled = isOpen;
}
private bool LoadOk = false;
private void FrmTest_Load(object sender, EventArgs e)
......@@ -229,7 +238,7 @@ namespace OnlineStore.AutoInOutStore
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
HideForm();
initValue();
CodeManager.LoadConfig();
this.toolStripMenuItem4.Visible = StoreManager.HasDisableDoorControl;
this.toolStripMenuItem5.Visible = StoreManager.HasDisableDoorControl;
this.toolStripSeparator16.Visible = StoreManager.HasDisableDoorControl;
......@@ -1266,7 +1275,8 @@ namespace OnlineStore.AutoInOutStore
return;
}
IOManager.IOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
CodeLibrary.FrmCodeDecode frm = new FrmCodeDecode(false,false );
CodeLibrary.FrmCodeDecode frm = new FrmCodeDecode();
frm.chbZxing.Checked = false;
frm.ShowDialog();
IOManager.IOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
}
......@@ -1719,5 +1729,24 @@ namespace OnlineStore.AutoInOutStore
StoreManager.UpdateBoxConfig(store.Config);
}
}
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_Click(object sender, MouseEventArgs e)
{
var obj = sender as PictureBox;
if (obj.Dock == DockStyle.Fill)
obj.Dock = DockStyle.None;
}
}
}
......@@ -13,6 +13,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
......@@ -118,12 +119,12 @@ namespace OnlineStore.ACSingleStore.useControl
string[] pa = a.Split('_');
string[] pb = b.Split('_');
if (pa[1].Length == 1)
if (int.TryParse(pa[1],out _))
pa[1] += "A";
if (pb[1].Length == 1)
if (int.TryParse(pb[1], out _))
pb[1] += "A";
var isa = pa[1][0]+(pa[1][1].Equals('A') ? "1" : "2") + pa[2][0] + pa[3].PadLeft(2, '0');
var isb = pb[1][0]+(pb[1][1].Equals('A') ? "1" : "2") + pb[2][0] + pb[3].PadLeft(2, '0');
var isa = Regex.Replace(pa[1], @"[^\d]*", "")+(pa[1][1].Equals('A') ? "1" : "2") + pa[2][0] + pa[3].PadLeft(2, '0');
var isb = Regex.Replace(pb[1], @"[^\d]*", "") + (pb[1][1].Equals('A') ? "1" : "2") + pb[2][0] + pb[3].PadLeft(2, '0');
if (int.Parse(isa) == int.Parse(isb))
......@@ -181,7 +182,7 @@ namespace OnlineStore.ACSingleStore.useControl
//store.PositionNumList.Reverse();
string[] posstr = store.PositionNumList[store.PositionNumList.Count-1].Split('_');
int colcount = int.Parse(posstr[1][0].ToString())+1;
int colcount = int.Parse(Regex.Replace(posstr[1], @"[^\d]*", ""))+1;
for (int i = 0; i < colcount; i++)
{
dataGridView1.Columns.Add("Col" + i + "_A", "Col" + i + "_A");
......@@ -206,7 +207,7 @@ namespace OnlineStore.ACSingleStore.useControl
int ci = store.PositionNumList.Count-1 - i;
string posname = store.PositionNumList[ci];
string[] _posstr = posname.Split('_');
int col = int.Parse(_posstr[1][0].ToString());
int col = int.Parse(Regex.Replace(_posstr[1], @"[^\d]*", ""));
string ab = "A";
if (_posstr[1].Length>1)
ab = _posstr[1][1].ToString();
......@@ -234,10 +235,12 @@ namespace OnlineStore.ACSingleStore.useControl
currentRowIndex++;
}
dataGridView1.Rows.RemoveAt(dataGridView1.Rows.Count - 1);
setData(store.PositionNumList.Last());
}
void setData(string posid) {
AutoStorePosition ktkPosition = CSVPositionReader<AutoStorePosition>.GetPositon(posid);
cmbPosition.Text = posid;
label_size.Text = $"[{ktkPosition.BagWidth}x{ktkPosition.BagHeight}]";
if (ktkPosition != null)
{
txtMiddleP2.Text = ktkPosition.MiddleAxis_Position_P2.ToString();
......
......@@ -63,6 +63,7 @@ namespace OnlineStore.ACSingleStore.useControl
this.btnCycleOut = new System.Windows.Forms.Button();
this.groupAuto = new System.Windows.Forms.GroupBox();
this.btnSavePosition = new System.Windows.Forms.Button();
this.label_size = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.groupAuto.SuspendLayout();
this.SuspendLayout();
......@@ -456,9 +457,9 @@ namespace OnlineStore.ACSingleStore.useControl
//
// cmbPosition
//
this.cmbPosition.Location = new System.Drawing.Point(39, 34);
this.cmbPosition.Location = new System.Drawing.Point(68, 34);
this.cmbPosition.Name = "cmbPosition";
this.cmbPosition.Size = new System.Drawing.Size(157, 23);
this.cmbPosition.Size = new System.Drawing.Size(128, 23);
this.cmbPosition.TabIndex = 286;
this.cmbPosition.Text = "label1";
//
......@@ -535,6 +536,7 @@ namespace OnlineStore.ACSingleStore.useControl
this.groupAuto.Controls.Add(this.btnBatchOutTest);
this.groupAuto.Controls.Add(this.btnCycleOut);
this.groupAuto.Controls.Add(this.btnStart);
this.groupAuto.Controls.Add(this.label_size);
this.groupAuto.Controls.Add(this.cmbPosition);
this.groupAuto.Controls.Add(this.btnOutStore);
this.groupAuto.Controls.Add(this.label30);
......@@ -557,6 +559,14 @@ namespace OnlineStore.ACSingleStore.useControl
this.btnSavePosition.UseVisualStyleBackColor = true;
this.btnSavePosition.Click += new System.EventHandler(this.btnSavePosition_Click);
//
// label_size
//
this.label_size.Location = new System.Drawing.Point(11, 34);
this.label_size.Name = "label_size";
this.label_size.Size = new System.Drawing.Size(51, 23);
this.label_size.TabIndex = 286;
this.label_size.Text = "label1";
//
// uc_boxdebug
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -629,5 +639,6 @@ namespace OnlineStore.ACSingleStore.useControl
private System.Windows.Forms.Button btnCycleOut;
private System.Windows.Forms.GroupBox groupAuto;
private System.Windows.Forms.Button btnSavePosition;
private System.Windows.Forms.Label label_size;
}
}
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>Common</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -33,9 +33,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\log4net.dll</HintPath>
<HintPath>..\..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\dll\Newtonsoft.Json.dll</HintPath>
......
......@@ -36,19 +36,23 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.Camera.VisionLib">
<HintPath>..\..\..\camera\Asa.Camera.VisionLib.dll</HintPath>
</Reference>
<Reference Include="Asa.IOModule.AIOBOX, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
<Reference Include="CodeLibrary, Version=1.0.7844.17688, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\GeneralClassLibrary\CodeLibraryProject\CodeLibrary\bin\Debug\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\log4net.dll</HintPath>
<HintPath>..\..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......@@ -76,6 +80,7 @@
<Compile Include="DeviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="DeviceLibrary\PanasonicServo\BatchAxisController.cs" />
<Compile Include="ResourceControl.cs" />
<Compile Include="store\Camera.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType>
......
......@@ -48,6 +48,7 @@ namespace OnlineStore.DeviceLibrary
continue;
}
//LogUtil.info("加载到配置摄像机名称:" + str.Trim());
if (!cameraNameList.Contains(str.Trim()))
cameraNameList.Add(str.Trim());
}
string[] codeArray = codeStr.Split(spiltChar);
......@@ -99,6 +100,7 @@ namespace OnlineStore.DeviceLibrary
catch (Exception ex)
{
LogUtil.error("加载HIK相机出错:" + ex.ToString());
return;
}
}
string[] names = Camera._cam.Name;
......@@ -167,16 +169,39 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info( " 【" + cameraName + "】取图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
string r = "";
foreach (string codeType in codeTypeList)
{
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, 2000);
//foreach (string codeType in codeTypeList)
//{
// //判断是否是一维码
// if (codeType.ToLower().Equals("barcode"))
// {
// cc = HDCodeHelper.DecodeBarCode(ho_Image);
// }
// else
// {
// cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, 2000);
// }
// foreach (CodeInfo c in cc)
// {
// string str = CodeManager.ReplaceCode(c.CodeStr);
// if (!codeList.Contains(str))
// {
// codeList.Add(str);
// r = r + "##" + str;
// }
// }
//}
RemoteDecodeHelper.RemoteDecodeParam remoteDecodeParam = new RemoteDecodeHelper.RemoteDecodeParam
{
codeTypeList = codeTypeList.ToArray(),
codeCount = QRCodeCount,
timeout = 3000
};
cc = RemoteDecodeHelper.DecodeRequest(ho_Image, remoteDecodeParam);
if (cc==null)
{
cc = new List<CodeInfo>();
// SaveImageToFile(deviceName, cameraName, bit);
LogUtil.info(" 【" + cameraName + "】" + " 扫码失败");
}
foreach (CodeInfo c in cc)
{
......@@ -187,11 +212,6 @@ namespace OnlineStore.DeviceLibrary
r = r + "##" + str;
}
}
}
if (String.IsNullOrEmpty(r))
{
// SaveImageToFile(deviceName, cameraName, bit);
}
LogUtil.info( " 【" + cameraName + "】"+ " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】 :" + r);
}
catch (AccessViolationException e)
......
......@@ -505,10 +505,10 @@
1#AC1_9_3_14,10,8,7,1,1,173300,971572,977672,977672,971572,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_15,9,8,7,1,1,173300,987881,993981,993981,987881,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_16,8,8,7,1,1,173300,1003981,1010081,1010081,1003981,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_17,7,8,7,1,1,173300,1021500,1027600,1027600,1021500,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_18,6,8,7,1,1,173300,1037899,1043999,1043999,1037899,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_19,5,8,7,1,1,173300,1054258,1060358,1060358,1054258,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_20,4,8,7,1,1,173300,1071046,1077146,1077146,1071046,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_21,3,8,7,1,1,173300,1087092,1093192,1093192,1087092,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_22,2,8,7,1,1,173300,1103500,1109600,1109600,1103500,77000,417100,358300,101000,87000,,,,,,,
1#AC1_9_3_23,1,8,7,1,1,173300,1119409,1125509,1125509,1119409,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_17,7,8,7,1,1,173300,1021500,1027600,1027600,1021500,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_18,6,8,7,1,1,173300,1037899,1043999,1043999,1037899,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_19,5,8,7,1,1,173300,1054258,1060358,1060358,1054258,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_20,4,8,7,1,1,173300,1071046,1077146,1077146,1071046,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_21,3,8,7,1,1,173300,1087092,1093192,1093192,1087092,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_22,2,8,7,1,1,173300,1103500,1109600,1109600,1103500,77000,417100,358300,101000,87000,,,,,,,
1#AC1_10_3_23,1,8,7,1,1,173300,1119409,1125509,1125509,1119409,77000,417100,358300,101000,87000,,,,,,,
using Asa.Camera;
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;
namespace OnlineStore
{
public class HIKCamera
{
Thread camerathread;
Asa.Camera.VisionLib camera;
public string Name = "";
public event EventHandler<Bitmap> camera_event;
public string DeviceName = "monitor1";
public void LoadCameraConfig()
{
string path = @".\StoreConfig\Camera.json";
if (!File.Exists(path))
{
LogUtil.error(Name + "找不到监控相机配置文件" + path);
return;
}
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, "HIK.IPCamera");
}
catch (Exception e)
{
LogUtil.error(Name + "加载监控相机配置文件失败:" + e.ToString());
return;
}
camera.Open(DeviceName);
Bitmap bmp = camera.GetImage(DeviceName);
if (bmp == null)
{
LogUtil.error(Name + $"监控相机打开失败");
}
camerathread = new Thread(new ThreadStart(startCamera));
camerathread.Start();
GC.KeepAlive(camerathread);
}
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 / 7);
}
catch
{
errortimes++;
}
}
camera.Close();
camera.Dispose();
}
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());
}
}
string GetFixtureStateFilename(InOutStoreParam inOutParam,StoreMoveType storeMoveType, FixtureState fixtureState)
{
string dir = $"\\image\\Fixture\\{storeMoveType}\\{inOutParam.PositionNum}\\";
Directory.CreateDirectory(dir);
string filename = $"{inOutParam.WareNumber}@@{fixtureState}.jpg";
foreach (var x in Path.GetInvalidFileNameChars())
{
filename = filename.Replace(x.ToString(), "");
}
return dir + filename;
}
enum FixtureState
{
In,
Up,
Down,
Out
}
}
}
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -33,9 +33,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\log4net.dll</HintPath>
<HintPath>..\..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!