Commit 9eae4e77 刘韬

优化料仓选择

1 个父辈 f56d3329
......@@ -66,6 +66,9 @@
<HintPath>..\..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.NonGeneric, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Collections.NonGeneric.4.3.0\lib\net46\System.Collections.NonGeneric.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml.Linq" />
......@@ -149,6 +152,12 @@
<Compile Include="useControl\uc_AxisDebug.Designer.cs">
<DependentUpon>uc_AxisDebug.cs</DependentUpon>
</Compile>
<Compile Include="useControl\uc_boxdebug.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="useControl\uc_boxdebug.Designer.cs">
<DependentUpon>uc_boxdebug.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="FrmInOutStore.resx">
<DependentUpon>FrmInOutStore.cs</DependentUpon>
</EmbeddedResource>
......@@ -192,6 +201,10 @@
<EmbeddedResource Include="useControl\uc_AxisDebug.resx">
<DependentUpon>uc_AxisDebug.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="useControl\uc_boxdebug.resx">
<DependentUpon>uc_boxdebug.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="resource\language.resource">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
......@@ -74,7 +74,6 @@ namespace OnlineStore.ACSingleStore
cmbWriteIO.DataSource = new List<ConfigIO>(boxBean.Config.StoreDOList.Values);
cmbWriteIO.ValueMember = "ProName";
cmbWriteIO.DisplayMember = "DisplayStr";
cmbWriteValue.SelectedIndex = 0;
}
private void Control_Click(object sender, EventArgs e)
{
......@@ -112,22 +111,7 @@ namespace OnlineStore.ACSingleStore
LogUtil.error(LOGGER, ex.StackTrace);
}
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = (IO_VALUE)cmbWriteValue.SelectedIndex;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private ConfigIO GetSelectDO()
{
......@@ -189,19 +173,7 @@ namespace OnlineStore.ACSingleStore
}
}
private void cmbWriteValue_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0)
{
return;
}
e.DrawBackground();
e.DrawFocusRectangle();
if (cmbWriteValue.Items.Count > e.Index)
{
e.Graphics.DrawString(cmbWriteValue.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
}
}
private void btnReadIO_Click(object sender, EventArgs e)
{
......@@ -257,23 +229,6 @@ namespace OnlineStore.ACSingleStore
double result = Math.Round((aiValue - defaultValue) / xishu, 2);
return result;
}
private void btnReadAllDi_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = (IO_VALUE)cmbWriteValue.SelectedIndex;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDI(deviceName, (byte)slaveId );
}
private void btnReadAllDo_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = (IO_VALUE)cmbWriteValue.SelectedIndex;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDO(deviceName, (byte)slaveId);
}
private void btnOpenDoor_Click(object sender, EventArgs e)
{
LogUtil.info("点击按钮:" + btnOpenDoor.Text);
......@@ -331,5 +286,39 @@ namespace OnlineStore.ACSingleStore
{
}
private void btn_SetHigh_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = IO_VALUE.HIGH;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = 0;// FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private void btn_setlow_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = 0;// FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Collections.NonGeneric" version="4.3.0" targetFramework="net461" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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
......@@ -12,6 +12,8 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -41,9 +43,25 @@
<HintPath>..\..\dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.114.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
......@@ -77,7 +95,17 @@
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.114.0" targetFramework="net461" />
<package id="System.Buffers" version="4.4.0" targetFramework="net461" />
<package id="System.Data.SQLite.Core" version="1.0.114.3" targetFramework="net461" />
<package id="System.Memory" version="4.5.3" targetFramework="net461" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net461" />
</packages>
\ No newline at end of file
......@@ -36,6 +36,12 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.CameraFactory">
<HintPath>..\..\..\camera\Asa.CameraFactory.dll</HintPath>
</Reference>
<Reference Include="Asa.HIK.IPCamera">
<HintPath>..\..\..\camera\Asa.HIK.IPCamera.dll</HintPath>
</Reference>
<Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference>
......@@ -53,6 +59,7 @@
<HintPath>..\..\..\HuichuanLibrary\HuichuanLibrary\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
......@@ -77,6 +84,7 @@
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="PanasonicServo\HC\HCAxisManager.cs" />
<Compile Include="ResourceControl.cs" />
<Compile Include="store\Camera.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType>
......@@ -113,6 +121,7 @@
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="packages.config" />
<None Include="StoreConfig\AC\linePositions.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -122,6 +131,7 @@
<None Include="StoreConfig\AC\StoreConfig.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="StoreConfig\Camera.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
{
"HIKIPCamera": [
{
"Name": "monitor",
"IP": "192.168.1.64",
"User": "admin",
"Pwd": "acc123456",
"Port": "8000"
}
]
}
\ No newline at end of file
......@@ -28,6 +28,8 @@ namespace OnlineStore.DeviceLibrary
public string autoMsg = "";
public int AutoStartIndex = -1;
public bool IsInOutStoreAuto = false; //是否开启自动出入库
public bool Double_Alternate = false;
public bool hasDoublePlate = false;
#endregion
#region 出入库参数
......@@ -159,36 +161,7 @@ namespace OnlineStore.DeviceLibrary
{
timeOutMs = 650000;
}
/*
//如果是门开关信号,增加重写功能
if (!wait.IsEnd && span.TotalSeconds < StoreMove.TimeOutSeconds)
{
if (((wait.IoType.Equals(IO_Type.Door_Down) && wait.IoValue.Equals(IO_VALUE.HIGH))) ||
((wait.IoType.Equals(IO_Type.Door_Up) && wait.IoValue.Equals(IO_VALUE.LOW))))
{
//关门
if ((!IOManager.DOValue(IO_Type.Door_Down).Equals(IO_VALUE.HIGH)) ||
(!IOManager.DOValue(IO_Type.Door_Up).Equals(IO_VALUE.LOW)))
{
LogUtil.error("等待[" + NotOkMsg + "],重写关门指令( Door_Down = HIGH ,Door_Up=LOW )");
IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.LOW);
}
}
else if (((wait.IoType.Equals(IO_Type.Door_Down) && wait.IoValue.Equals(IO_VALUE.LOW))) ||
((wait.IoType.Equals(IO_Type.Door_Up) && wait.IoValue.Equals(IO_VALUE.HIGH))))
{
//开门
if ((!IOManager.DOValue(IO_Type.Door_Down).Equals(IO_VALUE.LOW)) ||
(!IOManager.DOValue(IO_Type.Door_Up).Equals(IO_VALUE.HIGH)))
{
LogUtil.error("等待[" + NotOkMsg + "],重写开门指令( Door_Down = LOW ,Door_Up=HIGH )");
IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.HIGH);
}
}
}*/
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs)
{
ConfigIO io = Config.getWaitIO(wait.IoType);
......@@ -886,34 +859,65 @@ namespace OnlineStore.DeviceLibrary
waitOutStoreList.Add(code);
}
}
/// <summary>
/// PosId, InOut,isSuccess
/// </summary>
public event Action<string,StoreMoveType,bool> InOutEndProcessEvent;
bool Alternate = true;
private void InOutEndProcess(StoreMoveType storeMoveType)
{
try
{
CurrInOutCount++;
CurrInOutACount++;
string oldposid = PositionNumList[autoPositionIndex];
InOutEndProcessEvent?.Invoke(oldposid, storeMoveType, true);
//是否自动进入出库状态
if (!autoNext)
{
return;
}
if (storeMoveType.Equals(StoreMoveType.InStore) && Double_Alternate && !hasDoublePlate)
{
string posid = PositionNumList[autoPositionIndex--];
LogUtil.info(LOGGER, StoreName + "自动进入双盘下一个入库:posid=" + posid);
hasDoublePlate = true;
autoMsg = "自动入库:" + posid;
StartInStoreMove(new InOutStoreParam("AAAA", posid));
return;
}
if (storeMoveType.Equals(StoreMoveType.InStore))
{
if (Double_Alternate && Alternate)
{
autoPositionIndex += 2;
Alternate = false;
}
else if (Double_Alternate && !Alternate)
{
autoPositionIndex--;
Alternate = true;
}
// autoPositionIndex = newIndex;
string posid = PositionNumList[autoPositionIndex];
//判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把出库信息存入排队列表中");
LogUtil.info(LOGGER, StoreName + $"自动进入下一个出库:{autoPositionIndex} posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把出库信息存入排队列表中");
Reset(false);
autoMsg = "自动出库:" + posid;
AddWaitOutInfo(new FixtureCodeInfo(0, "", posid));
}
else
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid);
LogUtil.info(LOGGER, StoreName + $"自动进入下一个出库:{autoPositionIndex} posid=" + posid);
autoMsg = "自动出库:" + posid;
StartOutStoreMove(new InOutStoreParam("", posid));
}
......@@ -923,12 +927,12 @@ namespace OnlineStore.DeviceLibrary
int newIndex = autoPositionIndex - autoJiange;
if (newIndex < 0)
{
if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
{
newIndex = AutoStartIndex;
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
}
else
//if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
//{
// newIndex = AutoStartIndex;
// LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
//}
//else
{
autoNext = false;
autoMsg = "自动出入库结束!";
......@@ -942,21 +946,14 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
LogUtil.info(LOGGER, StoreName + $"自动进入下一个入库:{autoPositionIndex} posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
Reset(false);
autoMsg = "自动入库:" + posid;
AddWaitOutInfo(new FixtureCodeInfo(0, "AAAA", posid));
}
//else if (CurrInOutCount >= Config.Box_ResetMCount)
//{
// LogUtil.info(LOGGER, StoreName + "自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutCount + "次,需要重置BOX旋转轴,先把出库信息存入排队列表中");
// //ResetMiddleAxis(false);
// autoMsg = "自动入库:" + posid;
// AddWaitOutInfo(new FixtureCodeInfo(0, "AAAA", posid));
//}
else
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个入库:posid=" + posid);
LogUtil.info(LOGGER, StoreName + $"自动进入下一个入库:{autoPositionIndex} posid=" + posid);
autoMsg = "自动入库:" + posid;
StartInStoreMove(new InOutStoreParam("AAAA", posid));
}
......
......@@ -130,7 +130,7 @@ namespace OnlineStore.DeviceLibrary
{
Camera._cam.CloseAll();
}
public static event EventHandler<Bitmap> camera_event;
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan()
......@@ -154,13 +154,14 @@ namespace OnlineStore.DeviceLibrary
HalconDotNet.HObject ho_Image = null;
try
{
ho_Image = Camera._cam.CaptureOnImage(cameraName);
ho_Image = Camera._cam.CaptureOnImage(cameraName,out Bitmap bitmap);
if (ho_Image == null)
{
LogUtil.error(" 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
CloseCamera(cameraName);
continue;
}
camera_event?.Invoke(null,bitmap);
LogUtil.info(" 【" + cameraName + "】取图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
string r = "";
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Runtime" version="4.3.1" targetFramework="net461" />
</packages>
\ No newline at end of file
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.Threading;
using System.Threading.Tasks;
namespace OnlineStore
{
public class HIKCamera
{
Thread camerathread;
Asa.HIK.IPCamera camera;
public string Name = "";
public event EventHandler<Bitmap> camera_event;
public void LoadCameraConfig()
{
string path = @".\StoreConfig\Camera.json";
if (!File.Exists(path))
{
LogUtil.error(Name + "找不到监控相机配置文件" + path);
return;
}
camera = new Asa.HIK.IPCamera(path);
bool rtn = camera.Load();
if (!rtn)
{
LogUtil.error(Name + "加载监控相机配置文件失败");
return;
}
camerathread = new Thread(new ThreadStart(startCamera));
camerathread.Start();
GC.KeepAlive(camerathread);
}
void startCamera()
{
if (!camera.IsOpen[0])
{
var rtn = camera.Open(0);
if (!rtn)
LogUtil.error(Name + "打开监控相机失败");
}
while (camera.IsOpen[0])
{
var rtn = camera.GrabOne(0, out Bitmap bmp);
if (rtn)
{
camera_event?.Invoke(this, bmp);
}
Thread.Sleep(1000 / 7);
}
camera.Close(0);
camera.Dispose();
}
void CameraGrabOne(string filename)
{
try
{
LogUtil.info(Name + "库位文件名:" + filename);
//return;
if (!camera.IsOpen[0])
{
camera.Open(0);
LogUtil.error(Name + "打开监控相机失败2");
}
var rtn = camera.GrabOne(0, out Bitmap bmp);
if (rtn)
{
if (File.Exists(filename))
File.Delete(filename);
bmp.Save(filename, ImageFormat.Jpeg);
bmp.Dispose();
}
else
{
rtn = camera.GrabOne(0, out bmp);
if (rtn)
{
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
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!