Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
SO853-AutoCountMachine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit c0c94c7b
由
刘韬
编写于
2024-10-19 13:03:47 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
稳定版
1 个父辈
a63d2c11
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
827 行增加
和
104 行删除
Common/Setting_Init.cs
DeviceLibrary/AutoScan/MachineBase.cs
DeviceLibrary/AutoScan/MoveStep.cs
DeviceLibrary/AutoScan/XRayMachine.Ledprocess.cs
DeviceLibrary/AutoScan/XRayMachine.SideMove.cs
DeviceLibrary/AutoScan/XRayMachine.XRay.cs
DeviceLibrary/AutoScan/XRayMachine.cs
DeviceLibrary/AutoScan/common/LabelParam.cs
DeviceLibrary/AutoScan/common/MoveInfo.cs
DeviceLibrary/AutoScan/common/RemoteClient.cs
DeviceLibrary/AutoScan/common/RemoteCommon.cs
DeviceLibrary/AutoScan/common/Snowflake.cs
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/DeviceLibrary/databaseProc.cs
DeviceLibrary/app.config
DeviceLibrary/packages.config
SO853-AutoCountMachine/App.config
SO853-AutoCountMachine/Form1.Designer.cs
SO853-AutoCountMachine/Form1.cs
SO853-AutoCountMachine/SettingControl.Designer.cs
SO853-AutoCountMachine/SettingControl.cs
SO853-AutoCountMachine/XrayControl.cs
Common/Setting_Init.cs
查看文件 @
c0c94c7
...
...
@@ -73,5 +73,12 @@ namespace OnlineStore.Common
public
static
MyConfig
<
int
>
Camera_QRCodeCount
=
3
;
[
MyConfigComment
(
"解码的超时时间"
)]
public
static
MyConfig
<
int
>
Camera_CodeTimeOut
=
2000
;
[
MyConfigComment
(
"MT WebSocket服务器地址"
)]
public
static
MyConfig
<
string
>
Device_MT_Server
=
"ws://127.0.0.1:26901/"
;
[
MyConfigComment
(
"设备界面语言"
)]
public
static
MyConfig
<
string
>
Device_Default_Language
=
"zh-CN"
;
}
}
DeviceLibrary/AutoScan/MachineBase.cs
查看文件 @
c0c94c7
...
...
@@ -190,6 +190,14 @@ namespace DeviceLibrary
{
isOk
=
false
;
}
MoveInfo
.
WaitList
.
ForEach
((
w
)
=>
{
if
(
w
.
WaitType
.
Equals
(
WaitEnum
.
W014_Msg
))
{
w
.
IsEnd
=
true
;
Msg
.
add
(
w
.
ActionMsg
,
(
MsgLevel
)
w
.
Data
);
}
});
foreach
(
WaitResultInfo
wait
in
MoveInfo
.
WaitList
)
{
if
(
wait
.
IsEnd
)
...
...
DeviceLibrary/AutoScan/MoveStep.cs
查看文件 @
c0c94c7
...
...
@@ -58,6 +58,8 @@ namespace DeviceLibrary
SideMove_06
,
SideMove_07
,
SideMove_08
,
SideMove_RequestPutReel
,
SideMove_StartPutReel
,
SideMove_09
,
SideMove_10
,
SideMove_11
,
...
...
DeviceLibrary/AutoScan/XRayMachine.Ledprocess.cs
查看文件 @
c0c94c7
...
...
@@ -19,8 +19,8 @@ namespace DeviceLibrary
void
LedProcessInit
()
{
AlarmLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
Alarm_Led
].
GetIOAddr
(),
DeviceName
);
StandbyLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
Standby
_Led
].
GetIOAddr
(),
DeviceName
);
RunningLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
Run
_Led
].
GetIOAddr
(),
DeviceName
);
StandbyLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
Run
_Led
].
GetIOAddr
(),
DeviceName
);
RunningLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
Standby
_Led
].
GetIOAddr
(),
DeviceName
);
TrayOKLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
Pass_Led
].
GetIOAddr
(),
DeviceName
);
TrayNGLed
=
new
Led
(
Config
.
DOList
[
IO_XRay_Type
.
NG_Led
].
GetIOAddr
(),
DeviceName
);
ledtimer
=
new
System
.
Threading
.
Timer
(
new
TimerCallback
(
LedProcess
),
null
,
0
,
1000
);
...
...
@@ -30,7 +30,7 @@ namespace DeviceLibrary
void
LedProcess
(
object
o
)
{
AlarmLed
.
LedState
=
LedState
.
off
;
//
StandbyLed.LedState = LedState.off;
StandbyLed
.
LedState
=
LedState
.
off
;
RunningLed
.
LedState
=
LedState
.
off
;
if
(
runStatus
==
RunStatus
.
Running
)
...
...
@@ -84,7 +84,10 @@ namespace DeviceLibrary
AlarmBuzzer
.
ON
();
}
else
if
(
MoveInfo
.
MoveStep
==
MoveStep
.
XRay_06_WaitMatchPN
)
{
AlarmLed
.
LedState
=
LedState
.
blink
;
AlarmBuzzer
.
ON
();
}
else
{
AlarmBuzzer
.
OFF
();
...
...
DeviceLibrary/AutoScan/XRayMachine.SideMove.cs
查看文件 @
c0c94c7
...
...
@@ -56,6 +56,16 @@ namespace DeviceLibrary
}
break
;
case
MoveStep
.
SideMove_01
:
if
(
RobotManage
.
offlinemode
&&
RobotManage
.
offlinereelLocation
.
isTower
==
"2"
)
{
Msg
.
add
(
"请手动取走线体末端料盘"
,
MsgLevel
.
info
);
if
(
IOValue
(
IO_XRay_Type
.
ExitLine_Reel_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
ExitLine_Reel_Info
=
null
;
SideMoveInfo
.
log
(
"料盘已取走"
);
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
}
return
;
}
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_02
);
SideMove_Z_Axis
.
AbsMove
(
SideMoveInfo
,
Config
.
SideMove_Z_P1
,
Config
.
SideMove_Z_P1_speed
);
SideMoveInfo
.
log
(
"出料档停退到P1"
);
...
...
@@ -65,6 +75,7 @@ namespace DeviceLibrary
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_03
);
SideMove_X_Axis
.
AbsMove
(
SideMoveInfo
,
Config
.
SideMove_X_P2
,
Config
.
SideMove_X_P2_speed
);
SideMoveInfo
.
log
(
"横移到取料点P2"
);
ExitLine_Location_Axis
.
AbsMove
(
MoveInfo
,
ExitLine_Location_Axis
.
GetAclPosition
()+
5000
,
Config
.
ExitLine_Location_7_speed
);
break
;
case
MoveStep
.
SideMove_03
:
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_04
);
...
...
@@ -114,10 +125,17 @@ namespace DeviceLibrary
SideMoveInfo
.
log
(
"横移到放料点P3"
);
break
;
case
MoveStep
.
SideMove_08
:
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_09
);
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_RequestPutReel
);
SideMoveInfo
.
log
(
"等待可以放料"
);
break
;
case
MoveStep
.
SideMove_RequestPutReel
:
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_RequestPutReel
);
SideMoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
5000
));
RemoteCommon
.
RequestPutReel
(
Remote
,
SideMoveInfo
.
ReelParam
,
out
string
msg
);
SideMoveInfo
.
Msg
(
msg
,
MsgLevel
.
info
);
SideMoveInfo
.
log
(
"等待可以放料"
);
break
;
case
MoveStep
.
SideMove_
09
:
case
MoveStep
.
SideMove_
StartPutReel
:
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_10
);
var
p3
=
Config
.
SideMove_Z_P3
-
(
SideMoveInfo
.
ReelParam
.
PlateH
-
8
-
suckReelRetryTimes
*
4
)
*
1000
;
SideMove_Z_Axis
.
AbsMove
(
SideMoveInfo
,
p3
,
Config
.
SideMove_Z_P3_speed
);
...
...
@@ -139,6 +157,7 @@ namespace DeviceLibrary
break
;
case
MoveStep
.
SideMove_13
:
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_14
);
RemoteCommon
.
PutReelFinish
(
Remote
,
SideMoveInfo
.
ReelParam
,
out
_
);
SideMove_X_Axis
.
AbsMove
(
SideMoveInfo
,
Config
.
SideMove_X_P1
,
Config
.
SideMove_X_P1_speed
);
SideMoveInfo
.
log
(
"横移到待机点P1"
);
break
;
...
...
DeviceLibrary/AutoScan/XRayMachine.XRay.cs
查看文件 @
c0c94c7
...
...
@@ -332,13 +332,14 @@ namespace DeviceLibrary
MoveInfo
.
NextMoveStep
(
MoveStep
.
XRay_Extra_03
);
MoveInfo
.
log
(
$
"获取到选定数量{rightcount}, 分别数量:{string.Join("
,
", selectcount)}, 总数据:{countlist}"
);
MoveInfo
.
ReelParam
.
QTY
=
rightcount
;
var
cl
=
ServerConn
.
inputCounterDataByXRayMachine
(
MoveInfo
.
ReelParam
.
WareCode
,
rightcount
);
if
(
cl
==
null
)
{
MoveInfo
.
ReelParam
.
IsNg
=
true
;
MoveInfo
.
ReelParam
.
NgMsg
=
"点料数量上传失败"
;
MoveInfo
.
ReelParam
.
logresult
();
}
//var cl = ServerConn.inputCounterDataByXRayMachine(MoveInfo.ReelParam.WareCode, rightcount);
//if (cl == null)
//{
// MoveInfo.ReelParam.IsNg = true;
// MoveInfo.ReelParam.NgMsg = "点料数量上传失败";
// MoveInfo.ReelParam.logresult();
//}
MoveInfo
.
ReelParam
.
logresult
();
}
break
;
case
MoveStep
.
XRay_Extra_03
:
...
...
@@ -478,6 +479,10 @@ namespace DeviceLibrary
dst
.
Save
(
"ResOut\\"
+
Path
.
GetFileNameWithoutExtension
(
xrayImagePath
)
+
"-Mark.png"
);
dst
.
Dispose
();
}
MoveInfo
.
ReelParam
.
xrayfile
=
xrayImagePath
;
MoveInfo
.
ReelParam
.
resultfile
=
"ResOut\\"
+
Path
.
GetFileNameWithoutExtension
(
xrayImagePath
)
+
"-Mark.png"
;
MoveInfo
.
ReelParam
.
Algo
=
algoData
.
Algo
;
if
(
result
!=
0
)
{
MoveInfo
.
ReelParam
.
IsNg
=
true
;
...
...
@@ -509,16 +514,22 @@ namespace DeviceLibrary
Directory
.
Move
(
Path
.
Combine
(
root
,
resfilename
),
resfile
);
if
(!
RobotManage
.
offlinemode
&&
!
dontlog
)
{
var
cl
=
ServerConn
.
inputCounterDataByXRayMachine
(
MoveInfo
.
ReelParam
.
WareCode
,
count
);
if
(
cl
==
null
)
{
MoveInfo
.
ReelParam
.
IsNg
=
true
;
MoveInfo
.
ReelParam
.
NgMsg
=
"点料数量上传失败"
;
MoveInfo
.
ReelParam
.
logresult
();
}
//
var cl = ServerConn.inputCounterDataByXRayMachine(MoveInfo.ReelParam.WareCode, count);
//
if (cl == null)
//
{
//
MoveInfo.ReelParam.IsNg = true;
//
MoveInfo.ReelParam.NgMsg = "点料数量上传失败";
//
MoveInfo.ReelParam.logresult();
//
}
}
//if (RobotManage.offlinemode && RobotManage.offlinereelLocation.isTower == "2")
//{
// MoveInfo.ReelParam.logresult();
//}
MoveInfo
.
ReelParam
.
logresult
();
}
else
{
else
{
MoveInfo
.
ReelParam
.
IsNg
=
true
;
MoveInfo
.
ReelParam
.
NgMsg
=
"点料结果为0"
;
MoveInfo
.
ReelParam
.
logresult
();
...
...
DeviceLibrary/AutoScan/XRayMachine.cs
查看文件 @
c0c94c7
...
...
@@ -38,7 +38,7 @@ namespace DeviceLibrary
AxisBean
ExitLine_Location_Axis
;
AxisBean
SideMove_X_Axis
;
AxisBean
SideMove_Z_Axis
;
public
RemoteClient
Remote
;
public
bool
Init
(
out
string
msg
)
{
ConfigHelper
.
Config
.
Get
(
"xray_light_delay"
,
1000
);
...
...
@@ -65,6 +65,21 @@ namespace DeviceLibrary
IOMonitor
.
RegisterIO
(
IO_XRay_Type
.
Entry_Open
,
Config
,
IO_VALUE
.
LOW
,
delegate
()
{
XRayDoorOpen
();
});
AlarmBuzzer
.
SetOnOffAction
(()
=>
{
IOMove
(
IO_XRay_Type
.
Alarm_Buzzer
,
IO_VALUE
.
HIGH
);
},
()
=>
{
IOMove
(
IO_XRay_Type
.
Alarm_Buzzer
,
IO_VALUE
.
LOW
);
});
Remote
=
new
RemoteClient
(
"XRAY02"
,
Setting_Init
.
Device_MT_Server
);
Remote
.
AddAction
(
"StartPutReel"
,
(
requestLoadInfo
)
=>
{
if
(
SideMoveInfo
.
MoveStep
==
MoveStep
.
SideMove_RequestPutReel
)
{
//SideMoveInfo.ReelParam = requestLoadInfo.LoadParam.clone();
SideMoveInfo
.
NextMoveStep
(
MoveStep
.
SideMove_StartPutReel
);
SideMoveInfo
.
log
(
"开始放料"
);
return
true
;
}
SideMoveInfo
.
log
(
"当前不在放料步骤"
);
return
false
;
});
LogUtil
.
info
(
DeviceName
+
" init end"
);
}
catch
(
Exception
e
){
...
...
DeviceLibrary/AutoScan/common/LabelParam.cs
查看文件 @
c0c94c7
...
...
@@ -99,7 +99,7 @@ namespace DeviceLibrary
/// </summary>
public
ReelDest
ReelDest
{
get
;
set
;
}
public
string
xrayfile
,
resultfile
,
Algo
;
public
ReelParam
clone
()
{
return
this
.
MemberwiseClone
()
as
ReelParam
;
}
...
...
@@ -139,7 +139,7 @@ namespace DeviceLibrary
sw
.
Close
();
sw
.
Dispose
();
}
databaseProc
.
Current
.
InsertOrUpdateRI
(
UID
,
PN
,
ReeID
,
IsNg
,
NgMsg
,
QTY
,
LabelState
,
ReelDest
.
ToString
(),
WareCode
);
databaseProc
.
Current
.
InsertOrUpdateRI
(
UID
,
PN
,
ReeID
,
IsNg
,
NgMsg
,
QTY
,
LabelState
,
ReelDest
.
ToString
(),
WareCode
,
xrayfile
,
resultfile
,
Algo
);
}
public
string
GetImgName
()
{
...
...
@@ -155,4 +155,46 @@ namespace DeviceLibrary
Tower
,
Unknow
}
public
enum
RemoteResult
{
None
,
Timeout
,
False
,
True
}
[
Serializable
]
public
class
RemoteLoad
{
/// <summary>
/// 动作
/// </summary>
public
string
Action
;
public
long
Seq
;
/// <summary>
/// 设备名称
/// </summary>
public
string
GroupName
;
/// <summary>
/// 消息
/// </summary>
public
string
Msg
;
/// <summary>
/// 物料信息
/// </summary>
public
RequestLoadInfo
RequestLoadInfo
;
}
[
Serializable
]
public
class
RequestLoadInfo
{
/// <summary>
/// 目的地设备名称
/// </summary>
public
string
DeviceGroupName
;
/// <summary>
/// 料盘数据
/// </summary>
public
ReelParam
LoadParam
;
//public DoorStatusE DoorStatus;
}
}
DeviceLibrary/AutoScan/common/MoveInfo.cs
查看文件 @
c0c94c7
...
...
@@ -142,7 +142,10 @@ namespace DeviceLibrary
LogUtil
.
error
(
msg
);
}
}
public
void
Msg
(
string
msg
,
MsgLevel
msgLevel
)
{
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
msg
,
msgLevel
));
}
public
void
StopwatchReset
()
{
Stopwatch
.
Restart
();
}
...
...
@@ -161,7 +164,15 @@ namespace DeviceLibrary
IsEnd
=
false
;
CanWhileMoveCount
=
0
;
}
public
static
WaitResultInfo
WaitMsg
(
string
msg
,
MsgLevel
msgLevel
)
{
WaitResultInfo
wait
=
new
WaitResultInfo
();
wait
.
WaitType
=
WaitEnum
.
W014_Msg
;
wait
.
ActionMsg
=
msg
;
wait
.
IsEnd
=
true
;
wait
.
Data
=
msgLevel
;
return
wait
;
}
public
static
WaitResultInfo
WaitIO
(
string
ioType
,
IO_VALUE
ioValue
)
{
WaitResultInfo
wait
=
new
WaitResultInfo
();
...
...
@@ -336,6 +347,7 @@ namespace DeviceLibrary
/// </summary>
public
Func
<
WaitResultInfo
,
bool
>
Action
{
get
;
set
;
}
public
string
ActionMsg
{
get
;
set
;
}
public
dynamic
Data
{
get
;
set
;
}
}
internal
class
WaitEnum
...
...
@@ -376,5 +388,9 @@ namespace DeviceLibrary
/// 通用代理等待方法
/// </summary>
internal
static
int
W013_Action
=
13
;
/// <summary>
/// 等待时反馈消息
/// </summary>
internal
static
int
W014_Msg
=
14
;
}
}
DeviceLibrary/AutoScan/common/RemoteClient.cs
0 → 100644
查看文件 @
c0c94c7
using
DeviceLibrary
;
using
log4net
;
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Timers
;
public
class
RemoteClient
{
public
string
GroupName
;
public
string
Serveraddr
;
WebSocket4Net
.
WebSocket
webSocket
;
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
"RollingLogFileAppender"
);
System
.
Timers
.
Timer
timer
;
public
RemoteClient
(
string
groupName
,
string
serveraddr
)
{
GroupName
=
groupName
;
Serveraddr
=
serveraddr
;
timer
=
new
System
.
Timers
.
Timer
(
1000
*
10
);
timer
.
Enabled
=
false
;
timer
.
AutoReset
=
true
;
timer
.
Elapsed
+=
Timer_Elapsed
;
webSocket
=
new
WebSocket4Net
.
WebSocket
(
Serveraddr
+
GroupName
);
LOGGER
.
Info
(
"webSocket:"
+
serveraddr
+
GroupName
);
webSocket
.
MessageReceived
+=
WebSocket_MessageReceived
;
webSocket
.
Closed
+=
WebSocket_Closed
;
webSocket
.
Opened
+=
WebSocket_Opened
;
//webSocket.AutoSendPingInterval = 2;
//webSocket.EnableAutoSendPing = true;
LOGGER
.
Info
(
"webSocket open"
);
webSocket
.
Open
();
timer
.
Start
();
}
private
void
WebSocket_Opened
(
object
sender
,
EventArgs
e
)
{
LOGGER
.
Info
(
$
"Remote:{GroupName} 连接成功"
);
LastState
=
webSocket
.
State
;
}
private
void
WebSocket_Closed
(
object
sender
,
EventArgs
e
)
{
if
(
LastState
!=
webSocket
.
State
)
{
LOGGER
.
Error
(
$
"Remote:{GroupName} 掉线了"
);
}
LastState
=
webSocket
.
State
;
}
WebSocket4Net
.
WebSocketState
LastState
=
WebSocket4Net
.
WebSocketState
.
None
;
public
bool
IsOnline
{
get
=>
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Open
;
}
int
errstatuscounr
=
0
;
private
void
Timer_Elapsed
(
object
sender
,
ElapsedEventArgs
e
)
{
Debug
.
WriteLine
(
"WebSocketState:"
+
webSocket
.
State
);
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Closed
)
{
try
{
LOGGER
.
Info
(
$
"Remote:{GroupName} 重新连接"
);
webSocket
.
Open
();
timeoutCount
=
0
;
errstatuscounr
=
0
;
}
catch
{
}
}
else
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Connecting
)
{
errstatuscounr
++;
if
(
errstatuscounr
>
5
)
{
LOGGER
.
Error
(
$
"Remote:{GroupName} Connecting 超时"
);
try
{
webSocket
.
Close
();
}
catch
{
}
webSocket
.
Open
();
errstatuscounr
=
0
;
}
}
else
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Open
)
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Seq
=
DateTime
.
Now
.
Ticks
;
remoteLoad
.
Action
=
"Heartbeats"
;
remoteLoad
.
GroupName
=
GroupName
;
SendAndWait
(
remoteLoad
,
out
_
);
//webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
}
}
volatile
RemoteResult
lastresult
=
RemoteResult
.
None
;
volatile
string
msg
;
private
void
WebSocket_MessageReceived
(
object
sender
,
WebSocket4Net
.
MessageReceivedEventArgs
e
)
{
bool
isok
=
false
;
lastresult
=
RemoteResult
.
None
;
msg
=
""
;
RemoteLoad
remoteLoad
;
try
{
remoteLoad
=
JsonConvert
.
DeserializeObject
<
RemoteLoad
>(
e
.
Message
);
}
catch
{
LOGGER
.
Error
(
"Cant Deserialize remote command:"
+
e
.
Message
);
return
;
}
switch
(
remoteLoad
.
Action
)
{
case
"OK"
:
case
"FAIL"
:
msg
=
remoteLoad
.
Msg
;
lastresult
=
remoteLoad
.
Action
==
"OK"
?
RemoteResult
.
True
:
RemoteResult
.
False
;
LOGGER
.
Info
(
"Revice Command Callback:"
+
remoteLoad
.
GroupName
+
" - "
+
remoteLoad
.
Action
+
" - "
+
remoteLoad
.
Msg
+
" ,Seq:"
+
remoteLoad
.
Seq
);
return
;
default
:
if
(
actionlist
.
ContainsKey
(
remoteLoad
.
Action
))
{
LOGGER
.
Info
(
"Revice remote command:"
+
remoteLoad
.
Action
+
",Seq:"
+
remoteLoad
.
Seq
);
isok
=
actionlist
[
remoteLoad
.
Action
].
Invoke
(
remoteLoad
.
RequestLoadInfo
);
}
else
LOGGER
.
Info
(
"unknow remote command:"
+
remoteLoad
.
Action
);
break
;
}
SendResult
(
isok
,
remoteLoad
.
Seq
);
}
Dictionary
<
string
,
Func
<
RequestLoadInfo
,
bool
>>
actionlist
=
new
Dictionary
<
string
,
Func
<
RequestLoadInfo
,
bool
>>();
public
void
AddAction
(
string
actionName
,
Func
<
RequestLoadInfo
,
bool
>
action
)
{
actionlist
[
actionName
]
=
action
;
}
int
timeoutCount
=
0
;
RemoteResult
WaitResult
(
out
string
msg
,
int
waittime
=
3000
)
{
while
(
lastresult
==
RemoteResult
.
None
&&
waittime
>
0
)
{
System
.
Threading
.
Thread
.
Sleep
(
50
);
waittime
=
waittime
-
50
;
}
if
(
lastresult
==
RemoteResult
.
None
)
{
LOGGER
.
Error
(
"等待远程反馈超时"
);
timeoutCount
++;
lastresult
=
RemoteResult
.
Timeout
;
if
(
timeoutCount
>
3
)
{
LOGGER
.
Error
(
"强制断开连接"
);
webSocket
.
Close
();
timeoutCount
=
0
;
}
}
else
{
timeoutCount
=
0
;
}
msg
=
this
.
msg
;
return
lastresult
;
}
/// <summary>
/// 发送并等待结果
/// </summary>
/// <param name="remoteLoad"></param>
/// <param name="waittime"></param>
/// <returns></returns>
public
RemoteResult
SendAndWait
(
RemoteLoad
remoteLoad
,
out
string
msg
,
int
waittime
=
3000
)
{
lock
(
webSocket
)
{
remoteLoad
.
Seq
=
DateTime
.
Now
.
Ticks
;
remoteLoad
.
GroupName
=
GroupName
;
if
(
remoteLoad
.
RequestLoadInfo
!=
null
)
{
if
(
string
.
IsNullOrEmpty
(
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
))
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
}
lastresult
=
RemoteResult
.
None
;
LOGGER
.
Info
(
$
"Send remote command: {GroupName} - "
+
remoteLoad
.
Action
+
$
", seq:{remoteLoad.Seq}"
);
webSocket
.
Send
(
JsonConvert
.
SerializeObject
(
remoteLoad
));
return
WaitResult
(
out
msg
,
waittime
);
}
}
void
SendResult
(
bool
result
,
long
Seq
)
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Seq
=
Seq
;
remoteLoad
.
Action
=
result
?
"OK"
:
"FAIL"
;
remoteLoad
.
GroupName
=
GroupName
;
webSocket
.
Send
(
JsonConvert
.
SerializeObject
(
remoteLoad
));
}
}
DeviceLibrary/AutoScan/common/RemoteCommon.cs
0 → 100644
查看文件 @
c0c94c7
using
OnlineStore.Common
;
namespace
DeviceLibrary
{
public
class
RemoteCommon
{
//public RemoteClient Remote { get; set; }
/// <summary>
/// 发送托盘需求
/// </summary>
/// <param name="TrayType"></param>
public
static
RemoteResult
RequestPutReel
(
RemoteClient
Remote
,
ReelParam
reelParam
,
out
string
msg
)
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Action
=
"RequestPutReel"
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
LoadParam
=
reelParam
.
clone
();
return
Remote
.
SendAndWait
(
remoteLoad
,
out
msg
);
}
/// <summary>
/// 发送物料已放好
/// </summary>
/// <param name="reelParam"></param>
public
static
RemoteResult
PutReelFinish
(
RemoteClient
Remote
,
ReelParam
reelParam
,
out
string
msg
)
{
LogUtil
.
info
(
"PutReelFinish:"
+
reelParam
.
ToStr
());
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Action
=
"PutReelFinish"
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
LoadParam
=
reelParam
.
clone
();
return
Remote
.
SendAndWait
(
remoteLoad
,
out
msg
);
}
}
}
DeviceLibrary/AutoScan/common/Snowflake.cs
0 → 100644
查看文件 @
c0c94c7
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
/// <summary>
/// 动态生产有规律的ID Snowflake算法是Twitter的工程师为实现递增而不重复的ID实现的
/// http://blog.csdn.net/w200221626/article/details/52064976
/// C# 实现 Snowflake算法
/// </summary>
public
class
Snowflake
{
private
static
long
machineId
;
//机器ID
private
static
long
datacenterId
=
0L
;
//数据ID
private
static
long
sequence
=
0L
;
//计数从零开始
private
static
long
twepoch
=
687888001020L
;
//唯一时间随机量
private
static
long
machineIdBits
=
5L
;
//机器码字节数
private
static
long
datacenterIdBits
=
5L
;
//数据字节数
public
static
long
maxMachineId
=
-
1L
^
-
1L
<<
(
int
)
machineIdBits
;
//最大机器ID
private
static
long
maxDatacenterId
=
-
1L
^
(-
1L
<<
(
int
)
datacenterIdBits
);
//最大数据ID
private
static
long
sequenceBits
=
12L
;
//计数器字节数,12个字节用来保存计数码
private
static
long
machineIdShift
=
sequenceBits
;
//机器码数据左移位数,就是后面计数器占用的位数
private
static
long
datacenterIdShift
=
sequenceBits
+
machineIdBits
;
private
static
long
timestampLeftShift
=
sequenceBits
+
machineIdBits
+
datacenterIdBits
;
//时间戳左移动位数就是机器码+计数器总字节数+数据字节数
public
static
long
sequenceMask
=
-
1L
^
-
1L
<<
(
int
)
sequenceBits
;
//一微秒内可以产生计数,如果达到该值则等到下一微妙在进行生成
private
static
long
lastTimestamp
=
-
1L
;
//最后时间戳
private
static
object
syncRoot
=
new
object
();
//加锁对象
static
Snowflake
snowflake
;
public
static
Snowflake
Instance
()
{
if
(
snowflake
==
null
)
snowflake
=
new
Snowflake
();
return
snowflake
;
}
public
Snowflake
()
{
Snowflakes
(
0L
,
-
1
);
}
public
Snowflake
(
long
machineId
)
{
Snowflakes
(
machineId
,
-
1
);
}
public
Snowflake
(
long
machineId
,
long
datacenterId
)
{
Snowflakes
(
machineId
,
datacenterId
);
}
private
void
Snowflakes
(
long
machineId
,
long
datacenterId
)
{
if
(
machineId
>=
0
)
{
if
(
machineId
>
maxMachineId
)
{
throw
new
Exception
(
"机器码ID非法"
);
}
Snowflake
.
machineId
=
machineId
;
}
if
(
datacenterId
>=
0
)
{
if
(
datacenterId
>
maxDatacenterId
)
{
throw
new
Exception
(
"数据中心ID非法"
);
}
Snowflake
.
datacenterId
=
datacenterId
;
}
}
/// <summary>
/// 生成当前时间戳
/// </summary>
/// <returns>毫秒</returns>
private
static
long
GetTimestamp
()
{
//让他2000年开始
return
(
long
)(
DateTime
.
UtcNow
-
new
DateTime
(
2000
,
1
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
)).
TotalMilliseconds
;
}
/// <summary>
/// 获取下一微秒时间戳
/// </summary>
/// <param name="lastTimestamp"></param>
/// <returns></returns>
private
static
long
GetNextTimestamp
(
long
lastTimestamp
)
{
long
timestamp
=
GetTimestamp
();
int
count
=
0
;
while
(
timestamp
<=
lastTimestamp
)
//这里获取新的时间,可能会有错,这算法与comb一样对机器时间的要求很严格
{
count
++;
if
(
count
>
10
)
throw
new
Exception
(
"机器的时间可能不对"
);
Thread
.
Sleep
(
1
);
timestamp
=
GetTimestamp
();
}
return
timestamp
;
}
/// <summary>
/// 获取长整形的ID
/// </summary>
/// <returns></returns>
public
long
GetId
()
{
lock
(
syncRoot
)
{
long
timestamp
=
GetTimestamp
();
if
(
Snowflake
.
lastTimestamp
==
timestamp
)
{
//同一微妙中生成ID
sequence
=
(
sequence
+
1
)
&
sequenceMask
;
//用&运算计算该微秒内产生的计数是否已经到达上限
if
(
sequence
==
0
)
{
//一微妙内产生的ID计数已达上限,等待下一微妙
timestamp
=
GetNextTimestamp
(
Snowflake
.
lastTimestamp
);
}
}
else
{
//不同微秒生成ID
sequence
=
0L
;
}
if
(
timestamp
<
lastTimestamp
)
{
throw
new
Exception
(
"时间戳比上一次生成ID时时间戳还小,故异常"
);
}
Snowflake
.
lastTimestamp
=
timestamp
;
//把当前时间戳保存为最后生成ID的时间戳
long
Id
=
((
timestamp
-
twepoch
)
<<
(
int
)
timestampLeftShift
)
|
(
datacenterId
<<
(
int
)
datacenterIdShift
)
|
(
machineId
<<
(
int
)
machineIdShift
)
|
sequence
;
return
Id
;
}
}
}
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
c0c94c7
...
...
@@ -65,12 +65,86 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\1053_CycleLine\TheMachine\bin\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SuperSocket.ClientEngine, Version=0.10.0.0, Culture=neutral, PublicKeyToken=ee9af13f57f00acc, processorArchitecture=MSIL">
<HintPath>..\packages\SuperSocket.ClientEngine.Core.0.10.0\lib\net45\SuperSocket.ClientEngine.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Specialized, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Specialized.4.3.0\lib\net46\System.Collections.Specialized.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<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.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Linq, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.NameResolution, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.NameResolution.4.3.0\lib\net46\System.Net.NameResolution.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Security, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Security.4.3.0\lib\net46\System.Net.Security.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
...
...
@@ -81,6 +155,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WebSocket4Net, Version=0.15.2.11, Culture=neutral, PublicKeyToken=eb4e154b696bf72a, processorArchitecture=MSIL">
<HintPath>..\packages\WebSocket4Net.0.15.2\lib\net45\WebSocket4Net.dll</HintPath>
</Reference>
<Reference Include="X-Ray, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\X-Ray\X-Ray\bin\Debug\X-Ray.dll</HintPath>
...
...
@@ -93,8 +170,11 @@
<Compile Include="AutoScan\common\Led.cs" />
<Compile Include="AutoScan\common\NamedPipeClient.cs" />
<Compile Include="AutoScan\common\OcrProcess.cs" />
<Compile Include="AutoScan\common\RemoteClient.cs" />
<Compile Include="AutoScan\common\RemoteCommon.cs" />
<Compile Include="AutoScan\common\SensorDebounce.cs" />
<Compile Include="AutoScan\common\ServerConn.cs" />
<Compile Include="AutoScan\common\Snowflake.cs" />
<Compile Include="AutoScan\common\TextBlock.cs" />
<Compile Include="AutoScan\common\LabelParam.cs" />
<Compile Include="AutoScan\MachineBase.cs" />
...
...
DeviceLibrary/DeviceLibrary/databaseProc.cs
查看文件 @
c0c94c7
...
...
@@ -30,12 +30,13 @@ namespace DeviceLibrary
return
_databaseProc
;
}
}
public
long
GetID
()
{
public
long
GetID
()
{
return
id
.
nextId
();
}
private
databaseProc
()
{
SQLiteHelper
.
SetConnectionString
(
"
sys.db"
);
SQLiteHelper
.
SetConnectionString
(
Application
.
StartupPath
+
"\\
sys.db"
);
string
sql
;
...
...
@@ -72,21 +73,28 @@ CREATE TABLE ""ReelInfo"" (
sql
=
"alter table ReelInfo add column Slot integer;"
;
//sh.ExecuteNonQuery(sql);
}
if
(!
sc
.
Contains
(
"imgfileid
varchar(80)
"
))
if
(!
sc
.
Contains
(
"imgfileid
TEXT
"
))
{
sql
=
"alter table MaterialQuantity add column imgfileid varchar(80);"
;
//sh.ExecuteNonQuery(sql);
sql
=
"alter table ReelInfo add column imgfileid TEXT;"
;
sh
.
ExecuteNonQuery
(
sql
);
sql
=
"alter table ReelInfo add column resultimage TEXT;"
;
sh
.
ExecuteNonQuery
(
sql
);
}
if
(!
sc
.
Contains
(
"algo TEXT"
))
{
sql
=
"alter table ReelInfo add column algo TEXT;"
;
sh
.
ExecuteNonQuery
(
sql
);
}
}
}
public
void
InsertOrUpdateRI
(
long
uid
,
string
PN
,
string
RI
,
bool
isng
,
string
ngmsg
,
int
quantity
,
string
lblstate
,
string
OMSG
,
string
tdbarcode
)
public
void
InsertOrUpdateRI
(
long
uid
,
string
PN
,
string
RI
,
bool
isng
,
string
ngmsg
,
int
quantity
,
string
lblstate
,
string
OMSG
,
string
tdbarcode
,
string
XRayFile
,
string
ResultFile
,
string
algo
)
{
string
sql
=
"SELECT COUNT(*) FROM ReelInfo WHERE ID = "
+
uid
.
ToString
();
string
sql
=
"SELECT COUNT(*) FROM ReelInfo WHERE ID = "
+
uid
.
ToString
();
long
sc
=
(
long
)
sh
.
ExecuteScalar
(
sql
);
if
(
sc
==
0
)
{
sql
=
"INSERT INTO ReelInfo VALUES(@id, @PN, @RI, @isng, @ngmsg,@quantity,@lblstate,@OMSG,@tdbarcode,@datetime)"
;
sql
=
"INSERT INTO ReelInfo VALUES(@id, @PN, @RI, @isng, @ngmsg,@quantity,@lblstate,@OMSG,@tdbarcode,@datetime
,@imgfileid,@resultimage,@algo
)"
;
SQLiteParameter
[]
para
=
new
SQLiteParameter
[]
{
new
SQLiteParameter
(
"@id"
,
uid
),
new
SQLiteParameter
(
"@PN"
,
PN
),
...
...
@@ -97,11 +105,15 @@ CREATE TABLE ""ReelInfo"" (
new
SQLiteParameter
(
"@lblstate"
,
lblstate
),
new
SQLiteParameter
(
"@OMSG"
,
OMSG
),
new
SQLiteParameter
(
"@tdbarcode"
,
tdbarcode
),
new
SQLiteParameter
(
"@datetime"
,
DateTime
.
Now
)
new
SQLiteParameter
(
"@datetime"
,
DateTime
.
Now
),
new
SQLiteParameter
(
"@imgfileid"
,
XRayFile
),
new
SQLiteParameter
(
"@resultimage"
,
ResultFile
),
new
SQLiteParameter
(
"@algo"
,
algo
)
};
sh
.
ExecuteNonQuery
(
sql
,
para
);
}
else
{
else
{
sql
=
@
"
UPDATE
ReelInfo
SET
...
...
@@ -121,9 +133,14 @@ id =@id";
new
SQLiteParameter
(
"@OMSG"
,
OMSG
),
};
sh
.
ExecuteNonQuery
(
sql
,
para
);
}
}
}
public
void
DeleteDataByDate
(
int
day
)
{
string
sql
=
"DELETE FROM ReelInfo WHERE DateTime < date('now', '-"
+
day
+
" days');"
;
SQLiteParameter
[]
para
=
new
SQLiteParameter
[]
{
};
sh
.
ExecuteNonQuery
(
sql
,
para
);
}
public
void
InsertLog
(
string
device
,
string
action
,
object
state
,
string
log
=
""
)
{
string
sql
=
"INSERT INTO ReelInfo VALUES(NULL, @device,@action, @state, @log,@datetime,NULL)"
;
...
...
@@ -163,11 +180,11 @@ id =@id";
return
i
;
}
public
DataTable
GetDatabydate
(
DateTime
startData
,
DateTime
endDate
)
public
DataTable
GetDatabydate
(
DateTime
startData
,
DateTime
endDate
,
bool
SortDESC
=
false
)
{
string
where
=
""
;
string
sql
=
@
"SELECT * FROM ReelInfo WHERE
(
datetime
BETWEEN
@startData
AND
@endDate
)
" + where + "
ORDER
BY
datetime
ASC
"
;
(
datetime
BETWEEN
@startData
AND
@endDate
)
" + where + "
ORDER
BY
datetime
" + (SortDESC ? "
DESC
" : "
ASC
")
;
SQLiteParameter
[]
para
=
new
SQLiteParameter
[]
{
new
SQLiteParameter
(
"@startData"
,
startData
),
...
...
@@ -176,10 +193,10 @@ id =@id";
DataTable
dt
=
sh
.
ExecuteQuery
(
sql
,
para
);
return
dt
;
}
public
DataTable
GetDatabyWhereString
(
string
where
)
public
DataTable
GetDatabyWhereString
(
string
where
,
bool
SortDESC
=
false
)
{
string
sql
=
@"SELECT * FROM ReelInfo WHERE "
+
where
+
" ORDER BY datetime ASC"
;
string
sql
=
@"SELECT * FROM ReelInfo WHERE "
+
where
+
" ORDER BY datetime "
+
(
SortDESC
?
"DESC"
:
"ASC"
)
;
DataTable
dt
=
sh
.
ExecuteQuery
(
sql
);
return
dt
;
}
...
...
DeviceLibrary/app.config
查看文件 @
c0c94c7
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configSections
>
<
sectionGroup
name
=
"userSettings"
type
=
"System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<
section
name
=
"DeviceLibrary.Properties.Settings1"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition
=
"MachineToLocalUser"
requirePermission
=
"false"
/>
<
section
name
=
"DeviceLibrary.Properties.Settings1"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition
=
"MachineToLocalUser"
requirePermission
=
"false"
/>
</
sectionGroup
>
</
configSections
>
<
runtime
>
<
assemblyBinding
xmlns
=
"urn:schemas-microsoft-com:asm.v1"
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"log4net"
publicKeyToken
=
"669e0ddf0bb1aa2a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.0.12.0"
newVersion
=
"2.0.12.0"
/>
<
assemblyIdentity
name
=
"log4net"
publicKeyToken
=
"669e0ddf0bb1aa2a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.0.12.0"
newVersion
=
"2.0.12.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
...
...
@@ -26,4 +26,4 @@
</
setting
>
</
DeviceLibrary
.
Properties
.
Settings1
>
</
userSettings
>
<
startup
><
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.8"
/></
startup
></
configuration
>
<
startup
><
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.8"
/></
startup
></
configuration
>
DeviceLibrary/packages.config
查看文件 @
c0c94c7
<?
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
=
"SuperSocket.ClientEngine.Core"
version
=
"0.10.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Collections.Specialized"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Data.SQLite.Core"
version
=
"1.0.114.3"
targetFramework
=
"net461"
/>
<
package
id
=
"System.IO"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Linq"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Net.NameResolution"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Net.Security"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Net.Sockets"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Runtime"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Runtime.Extensions"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Runtime.InteropServices"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Security.Cryptography.Algorithms"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Security.Cryptography.Encoding"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Security.Cryptography.Primitives"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Security.Cryptography.X509Certificates"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Text.RegularExpressions"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Threading"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.Threading.Timer"
version
=
"4.3.0"
targetFramework
=
"net48"
/>
<
package
id
=
"System.ValueTuple"
version
=
"4.5.0"
targetFramework
=
"net461"
/>
<
package
id
=
"WebSocket4Net"
version
=
"0.15.2"
targetFramework
=
"net48"
/>
</
packages
>
\ No newline at end of file
SO853-AutoCountMachine/App.config
查看文件 @
c0c94c7
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configSections
>
<
section
name
=
"log4net"
type
=
"log4net.Config.Log4NetConfigurationSectionHandler,log4net"
/>
<
section
name
=
"log4net"
type
=
"log4net.Config.Log4NetConfigurationSectionHandler,log4net"
/>
<
sectionGroup
name
=
"applicationSettings"
type
=
"System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<
section
name
=
"AutoCountMachine.Properties.Settings"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
<
section
name
=
"AutoCountMachine.Properties.Settings"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
</
sectionGroup
>
<
sectionGroup
name
=
"userSettings"
type
=
"System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<
section
name
=
"AutoCountMachine.Properties.Settings"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition
=
"MachineToLocalUser"
requirePermission
=
"false"
/>
<
section
name
=
"DeviceLibrary.Properties.Settings1"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition
=
"MachineToLocalUser"
requirePermission
=
"false"
/>
<
section
name
=
"AutoCountMachine.Properties.Settings"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition
=
"MachineToLocalUser"
requirePermission
=
"false"
/>
<
section
name
=
"DeviceLibrary.Properties.Settings1"
type
=
"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition
=
"MachineToLocalUser"
requirePermission
=
"false"
/>
</
sectionGroup
>
</
configSections
>
<
appSettings
>
<!--是否开机自动启动料仓-->
<
add
key
=
"App_AutoRun"
value
=
"1"
/>
<
add
key
=
"Default_Language"
value
=
"zh-CN"
/>
<
add
key
=
"CodeType"
value
=
"QR Code#Data Matrix ECC 200#barcode"
/>
<
add
key
=
"App_AutoRun"
value
=
"1"
/>
<
add
key
=
"Default_Language"
value
=
"zh-CN"
/>
<
add
key
=
"CodeType"
value
=
"QR Code#Data Matrix ECC 200#barcode"
/>
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<
add
key
=
"CodeParamPath"
value
=
"Conifg\"
/>
<
add
key
=
"CodeCount"
value
=
"3"
/>
<
add
key
=
"Code_Block_Size_List"
value
=
"11"
/>
<
add
key
=
"inputCounterDataByXRayMachine"
value
=
"http://10.69.221.80/SCTAEXTERNAL001/api/inputCounterDataByXRayMachine"
/>
<
add
key
=
"DetermineReelStorageLocation"
value
=
"http://10.69.221.80/SCTARLC001/api/RLC/DetermineReelStorageLocation"
/>
<
add
key
=
"CodeParamPath"
value
=
"Conifg\"
/>
<
add
key
=
"CodeCount"
value
=
"3"
/>
<
add
key
=
"Code_Block_Size_List"
value
=
"11"
/>
<
add
key
=
"inputCounterDataByXRayMachine"
value
=
"http://10.69.221.80/SCTAEXTERNAL001/api/inputCounterDataByXRayMachine"
/>
<
add
key
=
"DetermineReelStorageLocation"
value
=
"http://10.69.221.80/SCTARLC001/api/RLC/DetermineReelStorageLocation"
/>
</
appSettings
>
<
log4net
>
<
appender
name
=
"RollingLogFileAppender"
type
=
"log4net.Appender.RollingFileAppender"
>
<
file
value
=
"logs/AutoScanAndLabel.log"
/>
<
param
name
=
"Encoding"
value
=
"UTF-8"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyy-MM-dd"
/>
<
file
value
=
"logs/AutoScanAndLabel.log"
/>
<
param
name
=
"Encoding"
value
=
"UTF-8"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyy-MM-dd"
/>
<
layout
type
=
"log4net.Layout.PatternLayout"
>
<
conversionPattern
value
=
"[%date][%t]%-5p %m%n"
/>
<
conversionPattern
value
=
"[%date][%t]%-5p %m%n"
/>
</
layout
>
</
appender
>
<
appender
name
=
"LngResource"
type
=
"log4net.Appender.RollingFileAppender"
>
<
file
value
=
"logs/LngResource.log"
/>
<
param
name
=
"Encoding"
value
=
"UTF-8"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyy-MM-dd"
/>
<
file
value
=
"logs/LngResource.log"
/>
<
param
name
=
"Encoding"
value
=
"UTF-8"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyy-MM-dd"
/>
<
layout
type
=
"log4net.Layout.PatternLayout"
>
<
conversionPattern
value
=
"[%date][%t]%-5p %m%n"
/>
<
conversionPattern
value
=
"[%date][%t]%-5p %m%n"
/>
</
layout
>
</
appender
>
<
logger
name
=
"RollingLogFileAppender"
>
<
level
value
=
"ALL"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
<
level
value
=
"ALL"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
</
logger
>
<
logger
name
=
"HCBOARD"
>
<
level
value
=
"ALL"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
<
level
value
=
"ALL"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
</
logger
>
<
logger
name
=
"LngResource"
>
<
level
value
=
"Info"
/>
<
appender
-
ref
ref
=
"LngResource"
/>
<
level
value
=
"Info"
/>
<
appender
-
ref
ref
=
"LngResource"
/>
</
logger
>
<!--<
root
>
<
level
value
=
"Info"
/>
...
...
@@ -62,13 +62,13 @@
</
root
>-->
</
log4net
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.8"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.8"
/>
</
startup
>
<
runtime
>
<
assemblyBinding
xmlns
=
"urn:schemas-microsoft-com:asm.v1"
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"log4net"
publicKeyToken
=
"669e0ddf0bb1aa2a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.0.12.0"
newVersion
=
"2.0.12.0"
/>
<
assemblyIdentity
name
=
"log4net"
publicKeyToken
=
"669e0ddf0bb1aa2a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.0.12.0"
newVersion
=
"2.0.12.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
...
...
SO853-AutoCountMachine/Form1.Designer.cs
查看文件 @
c0c94c7
...
...
@@ -331,11 +331,13 @@ namespace AutoCountMachine
"NG"
,
"MSD"
,
"PAPER"
,
"TOWER"
});
"TOWER"
,
"LineEND"
});
this
.
cmb_runmode
.
Location
=
new
System
.
Drawing
.
Point
(
817
,
147
);
this
.
cmb_runmode
.
Name
=
"cmb_runmode"
;
this
.
cmb_runmode
.
Size
=
new
System
.
Drawing
.
Size
(
152
,
29
);
this
.
cmb_runmode
.
TabIndex
=
4
;
this
.
cmb_runmode
.
Visible
=
false
;
this
.
cmb_runmode
.
SelectedIndexChanged
+=
new
System
.
EventHandler
(
this
.
cmb_runmode_SelectedIndexChanged
);
//
// groupBox2
...
...
SO853-AutoCountMachine/Form1.cs
查看文件 @
c0c94c7
using
CodeLibrary
;
using
Asa
;
using
CodeLibrary
;
using
ConfigHelper
;
using
DeviceLibrary
;
using
OnlineStore.Common
;
...
...
@@ -52,7 +53,7 @@ namespace AutoCountMachine
private
string
Crc_GetLanguageEvent
()
{
return
ConfigAppSettings
.
GetValue
(
"Default_Language"
)
;
return
Setting_Init
.
Device_Default_Language
;
}
private
void
Form1_Shown
(
object
sender
,
EventArgs
e
)
...
...
@@ -416,6 +417,8 @@ namespace AutoCountMachine
p
.
StartInfo
.
WorkingDirectory
=
Application
.
StartupPath
;
p
.
Start
();
p
.
WaitForExit
();
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
XrayImage
.
ReloadTpl
();
Pn_Algo_Match
.
LoadFile
();
});
}
...
...
@@ -441,6 +444,10 @@ namespace AutoCountMachine
RobotManage
.
offlinereelLocation
.
isTower
=
"1"
;
RobotManage
.
offlinemode
=
true
;
break
;
case
"LineEND"
:
RobotManage
.
offlinereelLocation
.
isTower
=
"2"
;
RobotManage
.
offlinemode
=
true
;
break
;
}
}
...
...
@@ -479,14 +486,14 @@ namespace AutoCountMachine
private
void
简体中文
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
ConfigAppSettings
.
SaveValue
(
"Default_Language"
,
"zh-CN"
)
;
Setting_Init
.
Device_Default_Language
=
"zh-CN"
;
crc
.
LanguageChange
();
}
private
void
englishToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
ConfigAppSettings
.
SaveValue
(
"Default_Language"
,
"en-US"
)
;
Setting_Init
.
Device_Default_Language
=
"en-US"
;
crc
.
LanguageChange
();
}
...
...
@@ -497,14 +504,17 @@ namespace AutoCountMachine
MessageBox
.
Show
(
"当前尚未点过物料"
);
return
;
}
RobotManage
.
xrayMachine
.
MoveInfo
.
NextMoveStep
(
MoveStep
.
XRay_06_WaitMatchPN2
);
if
(
RobotManage
.
xrayMachine
.
MoveInfo
.
MoveStep
==
MoveStep
.
XRay_06_WaitMatchPN
||
RobotManage
.
xrayMachine
.
MoveInfo
.
MoveStep
==
MoveStep
.
XRay_06_WaitMatchPN2
)
RobotManage
.
xrayMachine
.
MoveInfo
.
NextMoveStep
(
MoveStep
.
XRay_06_WaitMatchPN2
);
Task
.
Run
(()
=>
{
Process
p
=
new
Process
();
p
.
StartInfo
=
new
ProcessStartInfo
(
"AlgoMatch\\AlgoMatch.exe"
);
p
.
StartInfo
.
WorkingDirectory
=
Application
.
StartupPath
;
p
.
StartInfo
.
Arguments
=
"singlecount "
+
RobotManage
.
xrayMachine
.
xrayImagePath
;
p
.
StartInfo
.
Arguments
=
"singlecount "
+
RobotManage
.
xrayMachine
.
xrayImagePath
+
" "
+
Setting_Init
.
Device_Default_Language
+
" 0"
;
p
.
Start
();
p
.
WaitForExit
();
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
XrayImage
.
ReloadTpl
();
Pn_Algo_Match
.
LoadFile
();
if
(
RobotManage
.
xrayMachine
.
MoveInfo
.
MoveStep
==
MoveStep
.
XRay_06_WaitMatchPN
||
RobotManage
.
xrayMachine
.
MoveInfo
.
MoveStep
==
MoveStep
.
XRay_06_WaitMatchPN2
)
RobotManage
.
xrayMachine
.
MoveInfo
.
NextMoveStep
(
MoveStep
.
XRay_07_TryAgain
);
...
...
SO853-AutoCountMachine/SettingControl.Designer.cs
查看文件 @
c0c94c7
...
...
@@ -45,7 +45,6 @@ namespace AutoCountMachine
this
.
rb_datafilter_lastMonth
=
new
System
.
Windows
.
Forms
.
RadioButton
();
this
.
rb_datafilter_thismonth
=
new
System
.
Windows
.
Forms
.
RadioButton
();
this
.
tabPage3
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
nbdtControl1
=
new
AutoCountMachine
.
UCCOMMON
.
NBDTControl
();
this
.
tabPage1
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
cb_newpnalert
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
linkLabel1
=
new
System
.
Windows
.
Forms
.
LinkLabel
();
...
...
@@ -53,6 +52,7 @@ namespace AutoCountMachine
this
.
cb_autorun
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cb_EnableBuzzer
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
tabPage4
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
nbdtControl1
=
new
AutoCountMachine
.
UCCOMMON
.
NBDTControl
();
this
.
ngalgoControl1
=
new
AutoCountMachine
.
NGALGOControl
();
this
.
tabControl1
.
SuspendLayout
();
this
.
tabPage2
.
SuspendLayout
();
...
...
@@ -185,6 +185,7 @@ namespace AutoCountMachine
this
.
dataGridView1
.
SelectionMode
=
System
.
Windows
.
Forms
.
DataGridViewSelectionMode
.
FullRowSelect
;
this
.
dataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
758
,
394
);
this
.
dataGridView1
.
TabIndex
=
0
;
this
.
dataGridView1
.
MouseClick
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
dataGridView1_MouseClick
);
//
// rb_datafilter_custom
//
...
...
@@ -208,7 +209,7 @@ namespace AutoCountMachine
this
.
rb_datafilter_last30
.
TabStop
=
true
;
this
.
rb_datafilter_last30
.
Text
=
"最近30天"
;
this
.
rb_datafilter_last30
.
UseVisualStyleBackColor
=
true
;
this
.
rb_datafilter_last30
.
C
heckedChanged
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_last30_CheckedChanged
);
this
.
rb_datafilter_last30
.
C
lick
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_last30_CheckedChanged
);
//
// rb_datafilter_today
//
...
...
@@ -220,7 +221,7 @@ namespace AutoCountMachine
this
.
rb_datafilter_today
.
TabStop
=
true
;
this
.
rb_datafilter_today
.
Text
=
"今天"
;
this
.
rb_datafilter_today
.
UseVisualStyleBackColor
=
true
;
this
.
rb_datafilter_today
.
C
heckedChanged
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_today_CheckedChanged
);
this
.
rb_datafilter_today
.
C
lick
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_today_CheckedChanged
);
//
// rb_datafilter_lastMonth
//
...
...
@@ -232,7 +233,7 @@ namespace AutoCountMachine
this
.
rb_datafilter_lastMonth
.
TabStop
=
true
;
this
.
rb_datafilter_lastMonth
.
Text
=
"上月"
;
this
.
rb_datafilter_lastMonth
.
UseVisualStyleBackColor
=
true
;
this
.
rb_datafilter_lastMonth
.
C
heckedChanged
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_lastMonth_CheckedChanged
);
this
.
rb_datafilter_lastMonth
.
C
lick
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_lastMonth_CheckedChanged
);
//
// rb_datafilter_thismonth
//
...
...
@@ -244,7 +245,7 @@ namespace AutoCountMachine
this
.
rb_datafilter_thismonth
.
TabStop
=
true
;
this
.
rb_datafilter_thismonth
.
Text
=
"本月"
;
this
.
rb_datafilter_thismonth
.
UseVisualStyleBackColor
=
true
;
this
.
rb_datafilter_thismonth
.
C
heckedChanged
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_thismonth_CheckedChanged
);
this
.
rb_datafilter_thismonth
.
C
lick
+=
new
System
.
EventHandler
(
this
.
rb_datafilter_thismonth_CheckedChanged
);
//
// tabPage3
//
...
...
@@ -257,14 +258,6 @@ namespace AutoCountMachine
this
.
tabPage3
.
Text
=
"流程配置"
;
this
.
tabPage3
.
UseVisualStyleBackColor
=
true
;
//
// nbdtControl1
//
this
.
nbdtControl1
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
nbdtControl1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
3
);
this
.
nbdtControl1
.
Name
=
"nbdtControl1"
;
this
.
nbdtControl1
.
Size
=
new
System
.
Drawing
.
Size
(
891
,
481
);
this
.
nbdtControl1
.
TabIndex
=
0
;
//
// tabPage1
//
this
.
tabPage1
.
Controls
.
Add
(
this
.
cb_newpnalert
);
...
...
@@ -345,6 +338,14 @@ namespace AutoCountMachine
this
.
tabPage4
.
Text
=
"NG PN"
;
this
.
tabPage4
.
UseVisualStyleBackColor
=
true
;
//
// nbdtControl1
//
this
.
nbdtControl1
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
nbdtControl1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
3
);
this
.
nbdtControl1
.
Name
=
"nbdtControl1"
;
this
.
nbdtControl1
.
Size
=
new
System
.
Drawing
.
Size
(
891
,
481
);
this
.
nbdtControl1
.
TabIndex
=
0
;
//
// ngalgoControl1
//
this
.
ngalgoControl1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
...
...
SO853-AutoCountMachine/SettingControl.cs
查看文件 @
c0c94c7
using
ConfigHelper
;
using
Asa
;
using
ConfigHelper
;
using
DeviceLibrary
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -90,6 +93,8 @@ namespace AutoCountMachine
this
.
cb_autorun
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_autorun_CheckedChanged
);
rb_datafilter_today
.
Checked
=
true
;
cb_newpnalert
.
Checked
=
Config
.
Get
(
"NewPnAlert"
,
true
);
rb_datafilter_today_CheckedChanged
(
this
,
EventArgs
.
Empty
);
}
private
void
RoleManger_RoleChange
(
object
sender
,
Role
e
)
...
...
@@ -130,7 +135,7 @@ namespace AutoCountMachine
void
setData
(
DateTime
startData
,
DateTime
endDate
)
{
DataTable
dt
=
databaseProc
.
Current
.
GetDatabydate
(
startData
,
endDate
);
DataTable
dt
=
databaseProc
.
Current
.
GetDatabydate
(
startData
,
endDate
,
true
);
showData
(
dt
);
}
void
showData
(
DataTable
dt
)
...
...
@@ -201,5 +206,99 @@ namespace AutoCountMachine
{
Config
.
Set
(
"NewPnAlert"
,
cb_newpnalert
.
Checked
);
}
private
void
dataGridView1_MouseClick
(
object
sender
,
MouseEventArgs
e
)
{
if
(
e
.
Button
==
MouseButtons
.
Left
)
{
int
currentMouseOverRow
=
dataGridView1
.
HitTest
(
e
.
X
,
e
.
Y
).
RowIndex
;
if
(
currentMouseOverRow
>=
0
)
{
var
pn
=
dataGridView1
.
Rows
[
currentMouseOverRow
].
Cells
[
1
].
Value
;
ContextMenu
m
=
new
ContextMenu
();
m
.
Tag
=
"not"
;
m
.
MenuItems
.
Add
(
new
MenuItem
(
string
.
Format
(
crc
.
GetString
(
"Res0075.c4aa1667"
,
"重新点数 {0}"
),
pn
)));
m
.
MenuItems
.
Add
(
new
MenuItem
(
crc
.
GetString
(
"Res0100.73c74189"
,
"导出XRay图像"
)));
m
.
MenuItems
[
0
].
Click
+=
SettingControl_Click
;
m
.
MenuItems
[
0
].
Tag
=
dataGridView1
.
Rows
[
currentMouseOverRow
];
m
.
MenuItems
[
1
].
Click
+=
HistoryControl_Click
;
m
.
MenuItems
[
1
].
Tag
=
dataGridView1
.
Rows
[
currentMouseOverRow
];
m
.
Show
(
dataGridView1
,
new
Point
(
e
.
X
,
e
.
Y
));
}
}
}
private
void
HistoryControl_Click
(
object
sender
,
EventArgs
e
)
{
var
row
=
(
DataGridViewRow
)((
MenuItem
)
sender
).
Tag
;
var
src
=
row
.
Cells
[
10
].
Value
.
ToString
();
var
src1
=
row
.
Cells
[
11
].
Value
.
ToString
();
if
(!
File
.
Exists
(
src
))
{
MessageBox
.
Show
(
crc
.
GetString
(
"Res0126.2904b4c5"
,
"当前图像文件已被清理"
));
return
;
}
SaveFileDialog
saveFile
=
new
SaveFileDialog
();
saveFile
.
Filter
=
"PNG files (*.PNG)|*.PNG"
;
saveFile
.
FileName
=
Path
.
GetFileName
(
src
);
//saveFile.RestoreDirectory = true;
if
(
saveFile
.
ShowDialog
()
==
DialogResult
.
OK
)
{
try
{
File
.
Copy
(
src
,
saveFile
.
FileName
);
var
newf
=
Path
.
GetDirectoryName
(
saveFile
.
FileName
)
+
"\\"
+
Path
.
GetFileNameWithoutExtension
(
saveFile
.
FileName
)
+
"-Mark.png"
;
if
(
File
.
Exists
(
src1
))
File
.
Copy
(
src1
,
newf
);
else
MessageBox
.
Show
(
crc
.
GetString
(
"Res0128.95c9b889"
,
"可能因为点料失败,缺失结果文件"
));
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(),
crc
.
GetString
(
"Res0127.9fe8f323"
,
"文件导出失败"
));
}
}
}
private
void
SettingControl_Click
(
object
sender
,
EventArgs
e
)
{
//var xrayfile = ((MenuItem)sender).Tag.ToString();
var
row
=
(
DataGridViewRow
)((
MenuItem
)
sender
).
Tag
;
var
barcode
=
row
.
Cells
[
8
].
Value
.
ToString
();
var
xrayfile
=
row
.
Cells
[
10
].
Value
.
ToString
();
xrayfile
=
xrayfile
.
Replace
(
"\\\\"
,
"\\"
);
if
(
string
.
IsNullOrEmpty
(
xrayfile
))
return
;
var
src1
=
row
.
Cells
[
11
].
Value
.
ToString
();
var
uid
=
(
long
)
row
.
Cells
[
0
].
Value
;
int
.
TryParse
(
row
.
Cells
[
5
].
Value
.
ToString
(),
out
int
qty
);
if
(
string
.
IsNullOrWhiteSpace
(
xrayfile
)
||
!
File
.
Exists
(
xrayfile
))
{
MessageBox
.
Show
(
crc
.
GetString
(
"Res0076.f0771934"
,
"找不到文件:"
)
+
xrayfile
);
return
;
}
Task
.
Run
(()
=>
{
Process
p
=
new
Process
();
p
.
StartInfo
=
new
ProcessStartInfo
(
"AlgoMatch\\AlgoMatch.exe"
);
p
.
StartInfo
.
WorkingDirectory
=
Application
.
StartupPath
;
p
.
StartInfo
.
Arguments
=
"singlecount "
+
xrayfile
+
" "
+
Setting_Init
.
Device_Default_Language
+
" "
+
qty
;
p
.
Start
();
p
.
WaitForExit
();
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
XrayImage
.
ReloadTpl
();
Pn_Algo_Match
.
LoadFile
();
});
}
}
}
SO853-AutoCountMachine/XrayControl.cs
查看文件 @
c0c94c7
using
DeviceLibrary
;
using
Asa
;
using
DeviceLibrary
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
...
...
@@ -250,6 +251,8 @@ namespace AutoCountMachine
p
.
Start
();
p
.
BeginOutputReadLine
();
p
.
WaitForExit
();
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
XrayImage
.
ReloadTpl
();
Pn_Algo_Match
.
LoadFile
();
p
.
Dispose
();
//countstate?.Invoke(this, "完成点料");
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论