Commit fc8303c0 LN

增加扫码方式配置,datalogic=0,halcon=1

1 个父辈 aa4cd176
此文件类型无法预览
......@@ -53,6 +53,10 @@
<ApplicationIcon>box.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="CodeLibrary, Version=1.0.7499.24663, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\..\dll\log4net.dll</HintPath>
</Reference>
......
......@@ -7,7 +7,6 @@
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1"/>
<add key="App_Title" value="AC_SA_料仓_1"/>
<add key="scanner_start_command" value="S"/>
<!-- 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)-->
<add key="StartBlowValue" value="4"/>
<!-- 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)-->
......@@ -17,7 +16,6 @@
<!--<add key="http.server" value="http://localhost:80/"/>-->
<!--storeType-->
<add key="store_count" value="1"/>
<!--start one store config-->
<add key="Store_Position_Config" value="\StoreConfig\AC\linePositions.csv"/>
<add key="Store_ConfigPath" value="\StoreConfig\AC\StoreConfig.csv"/>
<add key="Store_Type" value="RC_AC_SA"/>
......@@ -26,21 +24,19 @@
<add key="InOutDefaultPosition" value="8000"/>
<add key="Config_Pwd" value="123456"/>
<add key="Config_Pwd" value="123456"/>
<!--出库等待料盘拿走的时间,秒-->
<add key="OutStoreWaitSeconds" value="10"/>
<!--温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪-->
<add key="HumitureControllerType" value="0"/>
<!--解码方式,0=halcon 解码,1=西安料仓 使用zxing解码,2=成都料仓-->
<add key="DeCodeType" value="0"/>
<add key ="DefaultPWD" value ="123456"/>
<add key="UseAIOBOX" value="1"/>
<!--是否使用蜂鸣器-->
<add key ="UseBuzzer" value ="1"/>
<add key ="StartScan_CMD" value ="S"/>
<add key ="ShowLanguageMsg" value ="1"/>
<!--每盘料扫码的次数-->
<add key ="MaxScanCount" value ="2"/>
<!--halcon扫码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\"/>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
......@@ -16,6 +16,7 @@ using log4net;
using OnlineStore.DeviceLibrary;
using System.IO.Ports;
using OnlineStore.LoadCSVLibrary;
using CodeLibrary;
namespace OnlineStore.ACSingleStore
{
......@@ -168,6 +169,7 @@ namespace OnlineStore.ACSingleStore
{
groupHistory.Visible = false;
}
btnCodeLearn.Visible = store.Config.ScanCodeType.Equals(1);
// this.tabControl1.TabPages.Remove(tabPage3);
// groupCode.Visible = false;
}
......@@ -787,7 +789,7 @@ namespace OnlineStore.ACSingleStore
private void 扫码测试ToolStripMenuItem_Click(object sender, EventArgs e)
{
store.dlScanSocket.StartConnect();
ScanManager.Instance.StartConnect();
store.GetCameraCode();
}
......@@ -1233,5 +1235,19 @@ namespace OnlineStore.ACSingleStore
bool result= store.BtnNextPro();
btnHul.Visible = store.NeedShowBtn();
}
private void btnCodeLearn_Click(object sender, EventArgs e)
{
if(store.Config.ScanCodeType.Equals(1))
{
if (Camera._cam != null)
{
Camera._cam.CloseAll();
}
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode();
frm.ShowDialog();
frm.Dispose();
}
}
}
}
......@@ -20,10 +20,6 @@ namespace OnlineStore.Common
/// 系统主界面标题
/// </summary>
public static string App_Title = "App_Title";
/// <summary>
/// 扫码枪开始命令发送给socket的消息
/// </summary>
public static string StartScan_CMD = "StartScan_CMD";
public static string http_server = "http.server";
public static string Store_CID = "Store_CID";
......@@ -39,14 +35,7 @@ namespace OnlineStore.Common
public static string Store_ConfigPath = "Store_ConfigPath";
public static string Store_Position_Config = "Store_Position_Config";
///// <summary>
///// 摄像机名称,多个中间使用#分割
///// </summary>
//public static string CameraName = "CameraName";
///// <summary>
///// 需要识别的二维码类型,多个中间使用#分割
///// </summary>
//public static string CodeType = "CodeType";
/// <summary>
/// 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)
......@@ -57,11 +46,6 @@ namespace OnlineStore.Common
/// </summary>
public static string StopBlowValue = "StopBlowValue";
///// <summary>
///// 配置文件路径 Data Matrix ECC 200.dcm
///// </summary>
//public static string CodeParamPath = "CodeParamPath";
/// <summary>
/// 进出轴最大待机点,需要小于3000
/// </summary>
......@@ -104,5 +88,7 @@ namespace OnlineStore.Common
public static string Default_Language= "Default_Language";
public static string MaxScanCount = "MaxScanCount";
public static string CodeParamPath = "CodeParamPath";
}
}
......@@ -39,6 +39,12 @@
<Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\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">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\log4net.dll</HintPath>
......@@ -59,7 +65,8 @@
<Compile Include="acSingleStore\AC_SA_BoxBean.cs" />
<Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" />
<Compile Include="acSingleStore\StoreManager.cs" />
<Compile Include="dataLogic\DLScanSocket.cs" />
<Compile Include="scanCode\dataLogic\DLScanSocket.cs" />
<Compile Include="scanCode\halcon\HalconScan.cs" />
<Compile Include="IO\AIManager.cs" />
<Compile Include="IO\AIOBOX\AIOAIManager.cs" />
<Compile Include="IO\AIOBOX\AIOBOXManager.cs" />
......@@ -72,6 +79,7 @@
<Compile Include="PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="ResourceControl.cs" />
<Compile Include="scanCode\ScanManager.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs">
<SubType>Code</SubType>
......
......@@ -132,8 +132,13 @@ PRO,模拟转换系数,AI_ConvertPosition,55,,,,,,,
,,,,,,,,, ,
PRO,默认的料盘宽度(多种尺寸为0),Default_TrayWidth,7,,,,,,,
PRO,特殊二维码尺寸配置,CodeSizeConfig,XA=13x48#XB=13x32,,,,,,,
PRO,大盘宽度(13寸或15寸),Big_TrayWidth,15,,,,,, ,
,,,,,,,,,,
PRO,解码方式0=datalogic;1=halcon,ScanCodeType,1,,,,,,,
,,,,,,,,, ,
PRO,扫码枪IP,Scanner_Ip,192.168.201.21,,,,,,,
PRO,扫码枪端口号,Scanner_Port,51236,,,,,,,
PRO,DataLogic扫码枪-IP,Scanner_Ip,192.168.201.21,,,,,,,
PRO,DataLogic扫码枪端口号,Scanner_Port,51236,,,,,,,
PRO,DataLogic扫码枪-开始扫码命令,StartScan_CMD,51236,,,,,,,
,,,,,,,,, ,
PRO,大盘宽度(13寸或15寸),Big_TrayWidth,15,,,,,,,
PRO,halcon-相机名称多个用#分割,CameraName,GigE:MV-CE100-30GC (00C69898483),,,,,,,
PRO,halcon-条码类型多个用#分割,CodeType,QR Code#Data Matrix ECC 200#Micro QR Code,,,,,,,
......@@ -16,7 +16,6 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public partial class AC_SA_BoxBean : KTK_Store
{
public DLScanSocket dlScanSocket;
private static bool IsIntSlvBlock = false;
/// <summary>
/// 开始运行
......@@ -46,21 +45,14 @@ namespace OnlineStore.DeviceLibrary
public int MaxScanCount = ConfigAppSettings.GetIntValue(Setting_Init.MaxScanCount);
public int CurrScanCount = 1;
//public ScanSocket scanSocket = new ScanSocket();
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
private System.Timers.Timer IoCheckTimer = new System.Timers.Timer();
public AC_SA_BoxBean(AC_SA_Config config)
{
// int value= CalHeight(37);
Init();
serverConnectTimer = new System.Timers.Timer();
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = false;
serverConnectTimer.Elapsed += server_connect_timer_Tick;
IoCheckTimer = new System.Timers.Timer();
IoCheckTimer.Interval = 400;
IoCheckTimer.AutoReset = true;
IoCheckTimer.Enabled = false;
IoCheckTimer.Elapsed += IoCheckTimer_Elapsed;
//添加调试
if (config.IsInDebug == 1)
......@@ -90,8 +82,7 @@ namespace OnlineStore.DeviceLibrary
}
}
}
dlScanSocket = new DLScanSocket(config.Scanner_Ip, config.Scanner_Port, onCodeReceived);
ScanManager.LoadConfig( config, onCodeReceived);
//初始化摄像机配置
// CodeManager.LoadConfig( );
IOManager.Init();
......@@ -208,7 +199,7 @@ namespace OnlineStore.DeviceLibrary
storeStatus = StoreStatus.ResetMove;
//启动温湿度服务器
HumitureController.Init(Config.Humiture_Port);
dlScanSocket.StartConnect();
ScanManager.Instance.StartConnect();
ReturnHome();
StartTime = DateTime.Now;
mainTimer.Enabled = true;
......@@ -675,7 +666,7 @@ namespace OnlineStore.DeviceLibrary
mainTimer.Enabled = false;
TimeSpan span = DateTime.Now - StartTime;
IsRun = false;
dlScanSocket.Close();
ScanManager.Instance.Close();
IOManager.instance.CloseAllDO();
LogUtil.info(LOGGER, StoreName + ",停止运行,总运行时间:" + span.ToString());
......@@ -1128,7 +1119,7 @@ namespace OnlineStore.DeviceLibrary
// GetCameraCode();
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanTime = DateTime.Now;
dlScanSocket.BeginScan();
ScanManager.Instance.BeginScan();
}
}
else
......@@ -1549,7 +1540,7 @@ namespace OnlineStore.DeviceLibrary
{
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanTime = DateTime.Now;
dlScanSocket.BeginScan();
ScanManager.Instance.BeginScan();
}
else
{
......@@ -1582,7 +1573,7 @@ namespace OnlineStore.DeviceLibrary
}
if (!String.IsNullOrEmpty(code))
{
message = message +"="+codeSize+"="+ code + dlScanSocket.spiltStr;
message = message +"="+codeSize+"="+ code + ScanManager.Instance.spiltStr;
}
}
return message;
......
......@@ -248,7 +248,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(LOGGER, StoreName + " 启动入库【" + posId + "】出错,叉子料盘检测有料");
return;
}
LogUtil.info(LOGGER, StoreName + " 启动入库【" + posId + "】", storeMoveColor);
LogUtil.info(LOGGER, StoreName + " 启动入库【" + posId + "】");
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
StoreMove.NewMove(StoreMoveType.InStore, param);
......@@ -478,7 +478,7 @@ namespace OnlineStore.DeviceLibrary
{
TimeSpan span = DateTime.Now - startInStoreTime;
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
LogUtil.info(LOGGER, StoreName + " 【" + posId + "】 入库结束[" + FormUtil.GetSpanStr(span) + "]", storeMoveColor);
LogUtil.info(LOGGER, StoreName + " 【" + posId + "】 入库结束[" + FormUtil.GetSpanStr(span) + "]");
StoreMove.EndMove();
storeRunStatus = StoreRunStatus.Runing;
//设备连接,入库后,BOX恢复原始状态
......@@ -518,7 +518,7 @@ namespace OnlineStore.DeviceLibrary
return false;
}
storeStatus = StoreStatus.OutStoreExecute;
LogUtil.info(LOGGER, StoreName + "启动出库【" + posId + "】 ", storeMoveColor);
LogUtil.info(LOGGER, StoreName + "启动出库【" + posId + "】 ");
storeRunStatus = StoreRunStatus.Busy;
StoreMove.NewMove(StoreMoveType.OutStore, param);
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
......@@ -718,7 +718,7 @@ namespace OnlineStore.DeviceLibrary
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
storeStatus = StoreStatus.StoreOnline;
LogUtil.info(LOGGER, StoreName + " 【" + posId + "】出库结束[" + FormUtil.GetSpanStr(span) + "]", storeMoveColor);
LogUtil.info(LOGGER, StoreName + " 【" + posId + "】出库结束[" + FormUtil.GetSpanStr(span) + "]");
StoreMove.EndMove();
storeRunStatus = StoreRunStatus.Runing;
//InOutEndProcess(StoreMoveType.OutStore);
......@@ -896,12 +896,12 @@ namespace OnlineStore.DeviceLibrary
private void InStoreLog(string msg)
{
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
LogUtil.info(LOGGER, "【" + posId + "】" + msg, storeMoveColor);
LogUtil.info(LOGGER, "【" + posId + "】" + msg);
}
private void OutStoreLog(string msg)
{
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
LogUtil.info(LOGGER, "【" + posId + "】" + msg, storeMoveColor);
LogUtil.info(LOGGER, "【" + posId + "】" + msg);
}
......
......@@ -23,6 +23,7 @@ namespace OnlineStore.DeviceLibrary
public static AC_SA_Config Config = null;
private static bool isInit = false;
public static bool IsConnectServer = !ConfigAppSettings.GetValue(Setting_Init.http_server).Equals("");
public StoreManager()
{
}
......@@ -95,10 +96,8 @@ namespace OnlineStore.DeviceLibrary
}
return Store;
}
/// <summary>
/// 修改了料仓配置,更新缓存,更新配置文件(只能更新PRO的配置)
/// </summary>
/// <param name="kTK_LA_Store_Config"></param>
public static void UpdateBoxConfig(AC_SA_Config storeConfig)
{
try
......@@ -155,4 +154,11 @@ namespace OnlineStore.DeviceLibrary
return host + api_nextFeeder;
}
}
public class ScanType
{
public const int DataLogic = 0;
public const int Halcon = 1;
}
}
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public abstract class ScanManager
{
public string spiltStr = "##";
public static ScanManager Instance = null;
public static void LoadConfig(AC_SA_Config config, OnCodeRevice onCodeReceived)
{
if (config.ScanCodeType.Equals(0))
{
Instance = new DLScanSocket(config.Scanner_Ip, config.Scanner_Port, onCodeReceived);
}
else
{
Instance = new HalconScan(config.CameraName, config.CodeType, onCodeReceived);
}
}
public delegate void OnCodeRevice(string[] codeList);
public abstract bool StartConnect(bool isMustCon = false);
public abstract void Close();
public abstract void BeginScan();
}
}
\ No newline at end of file
......@@ -7,8 +7,9 @@ using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class DLScanSocket
{ /// <summary>
public class DLScanSocket: ScanManager
{
/// <summary>
/// 扫码枪链接
/// </summary>
private TcpClient scannerSocket;
......@@ -18,7 +19,7 @@ namespace OnlineStore.DeviceLibrary
private bool isScannerRun = false;
private string ScannerIP = "";
private int ScannerPort = 0;
public delegate void OnCodeRevice(string[] codeList);
public event OnCodeRevice CodeReviceEvent;
public DLScanSocket(string serverIp, int port,OnCodeRevice revicePro)
{
......@@ -29,7 +30,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 开启扫码枪
/// </summary>
public bool StartConnect( bool isMustCon = false)
public override bool StartConnect( bool isMustCon = false)
{
bool result = true;
try
......@@ -53,18 +54,8 @@ namespace OnlineStore.DeviceLibrary
}
return result;
}
//public void TimerCheck()
//{
// if (!scannerSocket.IsConnected())
// {
// StartConnect( false );
// LogUtil.info( "重新连接扫码枪【" + ScannerIP + "】 ");
// }
//}
/// <summary>
/// 停止扫码枪
/// </summary>
public void Close()
public override void Close()
{
try
{
......@@ -76,15 +67,12 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("出错:" + ex);
}
}
/// <summary>
/// 发送扫码命令开始扫码
/// </summary>
public void BeginScan()
public override void BeginScan()
{
try
{
string str = ConfigAppSettings.GetValue(Setting_Init.StartScan_CMD);
scannerSocket.send(str);
scannerSocket.send(StoreManager.Config.StartScan_CMD);
}
catch (Exception ex)
{
......@@ -92,13 +80,11 @@ namespace OnlineStore.DeviceLibrary
}
}
public string spiltStr = "##";
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="message"></param>
protected virtual void onCodeReceived(string message)
protected void onCodeReceived(string message)
{
try
{
......
......@@ -25,14 +25,7 @@ namespace OnlineStore.DeviceLibrary
/// 9=出库执行,10=出仓完成,11=出库失败
/// </summary>
public StoreStatus storeStatus = StoreStatus.ResetMove;
/// <summary>
/// 提示消息,一般发给服务器后清空(LineBean表示报警提示消息,BoxBean表示出入库失败的原因记录)
/// </summary>
// public string WarnMsg = "";
/// <summary>
/// 日志颜色
/// </summary>
protected static Color storeMoveColor = Color.Blue;
protected static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public string StoreName { get; set; }
public int StoreID { get; set; }
......@@ -44,7 +37,8 @@ namespace OnlineStore.DeviceLibrary
/// 定时器
/// </summary>
protected System.Timers.Timer mainTimer;
protected System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
protected System.Timers.Timer IoCheckTimer = new System.Timers.Timer();
private bool isInit = false;
/// <summary>
/// 初始化
......@@ -54,6 +48,14 @@ namespace OnlineStore.DeviceLibrary
if (!isInit)
{
StoreMove = new StoreMoveInfo(StoreID);
IoCheckTimer = new System.Timers.Timer();
IoCheckTimer.Interval = 400;
IoCheckTimer.AutoReset = true;
IoCheckTimer.Enabled = false;
serverConnectTimer = new System.Timers.Timer();
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = false;
mainTimer = new System.Timers.Timer();
mainTimer.Enabled = false;
......
......@@ -17,16 +17,6 @@ namespace OnlineStore.LoadCSVLibrary
{
}
///// <summary>
///// 温湿度传感器地址/COM口配置
///// </summary>
//[ConfigProAttribute("TemperateServer_Port")]
//public int TemperateServer_Port { get; set; }
///// <summary>
///// 温湿度 传感器地址
///// </summary>
//[ConfigProAttribute("Temperate_ServerAddress")]
//public string Temperate_Serveraddress { get; set; }
/// <summary>
/// 预警温度
/// </summary>
......@@ -57,16 +47,16 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
[ConfigProAttribute("IsHasDoorLimit")]
public int IsHasDoorLimit { get; set; }
/// <summary>
/// PRO 扫码枪IP Scanner_Ip 192.168.200.13
/// </summary>
[ConfigProAttribute("Scanner_Ip")]
public string Scanner_Ip { get; set; }
/// <summary>
/// PRO 扫码枪端口号 Scanner_Port 51236
/// </summary>
[ConfigProAttribute("Scanner_Port")]
public int Scanner_Port { get; set; }
///// <summary>
///// PRO 扫码枪IP Scanner_Ip 192.168.200.13
///// </summary>
//[ConfigProAttribute("Scanner_Ip")]
//public string Scanner_Ip { get; set; }
///// <summary>
///// PRO 扫码枪端口号 Scanner_Port 51236
///// </summary>
//[ConfigProAttribute("Scanner_Port")]
//public int Scanner_Port { get; set; }
/// <summary>
/// PRO (轴一)旋转轴原点目标速度 MiddleAxis_TargetSpeed 30000
/// </summary>
......@@ -567,6 +557,39 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("Big_TrayWidth")]
public int Big_TrayWidth { get; set; }
private Dictionary<string, string> CodeSizeMap =null ;
/// <summary>
/// PPRO,解码方式0=datalogic;1=halcon,ScanCodeType,1,,,,,,,
/// /// </summary>
[ConfigProAttribute("ScanCodeType")]
public int ScanCodeType { get; set; }
/// <summary>
/// PRO,DataLogic扫码枪-IP,Scanner_Ip,192.168.201.21,,,,,,,
/// /// </summary>
[ConfigProAttribute("Scanner_Ip")]
public string Scanner_Ip { get; set; }
/// <summary>
/// PRO,DataLogic扫码枪端口号,Scanner_Port,51236
/// /// </summary>
[ConfigProAttribute("Scanner_Port")]
public int Scanner_Port { get; set; }
/// <summary>
/// PRO,DataLogic扫码枪-开始扫码命令,StartScan_CMD,S,,,,,,,,,
/// /// </summary>
[ConfigProAttribute("StartScan_CMD")]
public string StartScan_CMD { get; set; }
/// <summary>
/// PRO,halcon-相机名称多个用#分割,CameraName,GigE:MV-CE100-30GC (00C69898483),,,,,,,
/// /// </summary>
[ConfigProAttribute("CameraName")]
public string CameraName { get; set; }
/// <summary>
/// PRO, halcon-条码类型,CodeType,QR Code#Data Matrix ECC 200#Micro QR Code
/// /// </summary>
[ConfigProAttribute("CodeType")]
public string CodeType { get; set; }
private static char codeSpilt= '#';
public string GetCodeSize(string code)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!