Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
SO20242OutBound
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2c48ddc1
由
LN
编写于
2023-06-09 13:24:51 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加扫码测试按钮
1 个父辈
c6ed25ab
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
163 行增加
和
77 行删除
DeviceLibrary/DeviceLibrary/CodeManager.cs
DeviceLibrary/theMachine/RobotManage.cs
SharedDLL/HuichuanLibrary.dll
TheMachine/FormMain.Designer.cs
TheMachine/FormMain.cs
TheMachine/Program.cs
TheMachine/TheMachine.csproj
DeviceLibrary/DeviceLibrary/CodeManager.cs
查看文件 @
2c48ddc
...
@@ -163,11 +163,26 @@ namespace DeviceLibrary
...
@@ -163,11 +163,26 @@ namespace DeviceLibrary
public
static
void
CloseCamera
(
string
cameraName
)
public
static
void
CloseCamera
(
string
cameraName
)
{
{
Camera
.
_cam
.
Close
(
cameraName
);
try
{
Camera
.
_cam
.
Close
(
cameraName
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"CloseCamera error :"
+
ex
.
ToString
());
}
}
}
public
static
void
CloseAllCamera
()
public
static
void
CloseAllCamera
()
{
{
Camera
.
_cam
.
CloseAll
();
try
{
Camera
.
_cam
.
CloseAll
();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"CloseAllCamera error :"
+
ex
.
ToString
());
}
}
}
...
...
DeviceLibrary/theMachine/RobotManage.cs
查看文件 @
2c48ddc
...
@@ -151,7 +151,7 @@ namespace DeviceLibrary
...
@@ -151,7 +151,7 @@ namespace DeviceLibrary
LogUtil
.
info
(
"开始关闭系统."
);
LogUtil
.
info
(
"开始关闭系统."
);
IOManager
.
CloseAllConnection
();
IOManager
.
CloseAllConnection
();
CameraA
.
stopCamera
();
CameraA
.
stopCamera
();
CodeManager
.
CloseAllCamera
();
if
(
mainMachine
!=
null
)
if
(
mainMachine
!=
null
)
{
{
// mainMachine.SingleDoor.Dispose();
// mainMachine.SingleDoor.Dispose();
...
@@ -162,6 +162,10 @@ namespace DeviceLibrary
...
@@ -162,6 +162,10 @@ namespace DeviceLibrary
UserPause
(
""
,
userpause
);
UserPause
(
""
,
userpause
);
}
}
public
static
void
UserPause
(
string
msg
=
""
,
bool
userpause
=
true
)
{
public
static
void
UserPause
(
string
msg
=
""
,
bool
userpause
=
true
)
{
if
(
mainMachine
==
null
)
{
return
;
}
UserPauseSet
?.
Invoke
(
null
,
userpause
);
UserPauseSet
?.
Invoke
(
null
,
userpause
);
mainMachine
.
UserPause
=
userpause
;
mainMachine
.
UserPause
=
userpause
;
if
(
userpause
)
if
(
userpause
)
...
...
SharedDLL/HuichuanLibrary.dll
查看文件 @
2c48ddc
此文件类型无法预览
TheMachine/FormMain.Designer.cs
查看文件 @
2c48ddc
...
@@ -39,6 +39,8 @@ namespace TheMachine
...
@@ -39,6 +39,8 @@ namespace TheMachine
this
.
toolStripSeparator4
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripSeparator4
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
禁用蜂鸣器
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
禁用蜂鸣器
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator1
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripSeparator1
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripMenuItem1
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator5
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
退出
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
退出
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
语言
toolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
语言
toolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
简体中文
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
简体中文
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
...
@@ -58,8 +60,8 @@ namespace TheMachine
...
@@ -58,8 +60,8 @@ namespace TheMachine
this
.
btn_IgnoreX09
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_IgnoreX09
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_PauseBuzzer
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_PauseBuzzer
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
listView1
=
new
System
.
Windows
.
Forms
.
ListView
();
this
.
listView1
=
new
System
.
Windows
.
Forms
.
ListView
();
this
.
toolStripSeparator5
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
btnUpScan
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
toolStripMenuItem1
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
btnDownScan
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
menuStrip1
.
SuspendLayout
();
this
.
menuStrip1
.
SuspendLayout
();
this
.
tabc
.
SuspendLayout
();
this
.
tabc
.
SuspendLayout
();
this
.
tabP1
.
SuspendLayout
();
this
.
tabP1
.
SuspendLayout
();
...
@@ -104,32 +106,32 @@ namespace TheMachine
...
@@ -104,32 +106,32 @@ namespace TheMachine
// btn_run
// btn_run
//
//
this
.
btn_run
.
Name
=
"btn_run"
;
this
.
btn_run
.
Name
=
"btn_run"
;
this
.
btn_run
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
btn_run
.
Size
=
new
System
.
Drawing
.
Size
(
1
76
,
26
);
this
.
btn_run
.
Text
=
"启动"
;
this
.
btn_run
.
Text
=
"启动"
;
this
.
btn_run
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_run_Click
);
this
.
btn_run
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_run_Click
);
//
//
// toolStripSeparator2
// toolStripSeparator2
//
//
this
.
toolStripSeparator2
.
Name
=
"toolStripSeparator2"
;
this
.
toolStripSeparator2
.
Name
=
"toolStripSeparator2"
;
this
.
toolStripSeparator2
.
Size
=
new
System
.
Drawing
.
Size
(
17
7
,
6
);
this
.
toolStripSeparator2
.
Size
=
new
System
.
Drawing
.
Size
(
17
3
,
6
);
//
//
// btn_stop
// btn_stop
//
//
this
.
btn_stop
.
Name
=
"btn_stop"
;
this
.
btn_stop
.
Name
=
"btn_stop"
;
this
.
btn_stop
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
btn_stop
.
Size
=
new
System
.
Drawing
.
Size
(
1
76
,
26
);
this
.
btn_stop
.
Text
=
"停止"
;
this
.
btn_stop
.
Text
=
"停止"
;
this
.
btn_stop
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_stop_Click
);
this
.
btn_stop
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_stop_Click
);
//
//
// toolStripSeparator3
// toolStripSeparator3
//
//
this
.
toolStripSeparator3
.
Name
=
"toolStripSeparator3"
;
this
.
toolStripSeparator3
.
Name
=
"toolStripSeparator3"
;
this
.
toolStripSeparator3
.
Size
=
new
System
.
Drawing
.
Size
(
17
7
,
6
);
this
.
toolStripSeparator3
.
Size
=
new
System
.
Drawing
.
Size
(
17
3
,
6
);
//
//
// 启用调试模式ToolStripMenuItem
// 启用调试模式ToolStripMenuItem
//
//
this
.
启用调试模式
ToolStripMenuItem
.
Enabled
=
false
;
this
.
启用调试模式
ToolStripMenuItem
.
Enabled
=
false
;
this
.
启用调试模式
ToolStripMenuItem
.
Name
=
"启用调试模式ToolStripMenuItem"
;
this
.
启用调试模式
ToolStripMenuItem
.
Name
=
"启用调试模式ToolStripMenuItem"
;
this
.
启用调试模式
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
启用调试模式
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
76
,
26
);
this
.
启用调试模式
ToolStripMenuItem
.
Tag
=
"not"
;
this
.
启用调试模式
ToolStripMenuItem
.
Tag
=
"not"
;
this
.
启用调试模式
ToolStripMenuItem
.
Text
=
"启用配置模式"
;
this
.
启用调试模式
ToolStripMenuItem
.
Text
=
"启用配置模式"
;
this
.
启用调试模式
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
启用调试模式
ToolStripMenuItem_Click
);
this
.
启用调试模式
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
启用调试模式
ToolStripMenuItem_Click
);
...
@@ -137,24 +139,36 @@ namespace TheMachine
...
@@ -137,24 +139,36 @@ namespace TheMachine
// toolStripSeparator4
// toolStripSeparator4
//
//
this
.
toolStripSeparator4
.
Name
=
"toolStripSeparator4"
;
this
.
toolStripSeparator4
.
Name
=
"toolStripSeparator4"
;
this
.
toolStripSeparator4
.
Size
=
new
System
.
Drawing
.
Size
(
17
7
,
6
);
this
.
toolStripSeparator4
.
Size
=
new
System
.
Drawing
.
Size
(
17
3
,
6
);
//
//
// 禁用蜂鸣器ToolStripMenuItem
// 禁用蜂鸣器ToolStripMenuItem
//
//
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Name
=
"禁用蜂鸣器ToolStripMenuItem"
;
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Name
=
"禁用蜂鸣器ToolStripMenuItem"
;
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
76
,
26
);
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Text
=
"禁用蜂鸣器"
;
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Text
=
"禁用蜂鸣器"
;
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
禁用蜂鸣器
ToolStripMenuItem_Click
);
this
.
禁用蜂鸣器
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
禁用蜂鸣器
ToolStripMenuItem_Click
);
//
//
// toolStripSeparator1
// toolStripSeparator1
//
//
this
.
toolStripSeparator1
.
Name
=
"toolStripSeparator1"
;
this
.
toolStripSeparator1
.
Name
=
"toolStripSeparator1"
;
this
.
toolStripSeparator1
.
Size
=
new
System
.
Drawing
.
Size
(
177
,
6
);
this
.
toolStripSeparator1
.
Size
=
new
System
.
Drawing
.
Size
(
173
,
6
);
//
// toolStripMenuItem1
//
this
.
toolStripMenuItem1
.
Name
=
"toolStripMenuItem1"
;
this
.
toolStripMenuItem1
.
Size
=
new
System
.
Drawing
.
Size
(
176
,
26
);
this
.
toolStripMenuItem1
.
Text
=
"扫码测试"
;
this
.
toolStripMenuItem1
.
Click
+=
new
System
.
EventHandler
(
this
.
toolStripMenuItem1_Click
);
//
// toolStripSeparator5
//
this
.
toolStripSeparator5
.
Name
=
"toolStripSeparator5"
;
this
.
toolStripSeparator5
.
Size
=
new
System
.
Drawing
.
Size
(
173
,
6
);
//
//
// 退出ToolStripMenuItem
// 退出ToolStripMenuItem
//
//
this
.
退出
ToolStripMenuItem
.
Name
=
"退出ToolStripMenuItem"
;
this
.
退出
ToolStripMenuItem
.
Name
=
"退出ToolStripMenuItem"
;
this
.
退出
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
退出
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
76
,
26
);
this
.
退出
ToolStripMenuItem
.
Text
=
"退出"
;
this
.
退出
ToolStripMenuItem
.
Text
=
"退出"
;
this
.
退出
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
退出
ToolStripMenuItem_Click
);
this
.
退出
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
退出
ToolStripMenuItem_Click
);
//
//
...
@@ -171,7 +185,7 @@ namespace TheMachine
...
@@ -171,7 +185,7 @@ namespace TheMachine
// 简体中文ToolStripMenuItem
// 简体中文ToolStripMenuItem
//
//
this
.
简体中文
ToolStripMenuItem
.
Name
=
"简体中文ToolStripMenuItem"
;
this
.
简体中文
ToolStripMenuItem
.
Name
=
"简体中文ToolStripMenuItem"
;
this
.
简体中文
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
简体中文
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
44
,
26
);
this
.
简体中文
ToolStripMenuItem
.
Tag
=
"not"
;
this
.
简体中文
ToolStripMenuItem
.
Tag
=
"not"
;
this
.
简体中文
ToolStripMenuItem
.
Text
=
"简体中文"
;
this
.
简体中文
ToolStripMenuItem
.
Text
=
"简体中文"
;
this
.
简体中文
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
简体中文
ToolStripMenuItem_Click
);
this
.
简体中文
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
简体中文
ToolStripMenuItem_Click
);
...
@@ -179,7 +193,7 @@ namespace TheMachine
...
@@ -179,7 +193,7 @@ namespace TheMachine
// englishToolStripMenuItem
// englishToolStripMenuItem
//
//
this
.
englishToolStripMenuItem
.
Name
=
"englishToolStripMenuItem"
;
this
.
englishToolStripMenuItem
.
Name
=
"englishToolStripMenuItem"
;
this
.
englishToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
80
,
26
);
this
.
englishToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
1
44
,
26
);
this
.
englishToolStripMenuItem
.
Tag
=
"not"
;
this
.
englishToolStripMenuItem
.
Tag
=
"not"
;
this
.
englishToolStripMenuItem
.
Text
=
"English"
;
this
.
englishToolStripMenuItem
.
Text
=
"English"
;
this
.
englishToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
englishToolStripMenuItem_Click
);
this
.
englishToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
englishToolStripMenuItem_Click
);
...
@@ -217,6 +231,8 @@ namespace TheMachine
...
@@ -217,6 +231,8 @@ namespace TheMachine
//
//
// pnl
// pnl
//
//
this
.
pnl
.
Controls
.
Add
(
this
.
btnDownScan
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnUpScan
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnResetOut4
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnResetOut4
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnResetOut3
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnResetOut3
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnResetOut2
);
this
.
pnl
.
Controls
.
Add
(
this
.
btnResetOut2
);
...
@@ -374,17 +390,29 @@ namespace TheMachine
...
@@ -374,17 +390,29 @@ namespace TheMachine
this
.
listView1
.
TabIndex
=
2
;
this
.
listView1
.
TabIndex
=
2
;
this
.
listView1
.
UseCompatibleStateImageBehavior
=
false
;
this
.
listView1
.
UseCompatibleStateImageBehavior
=
false
;
//
//
// toolStripSeparator5
// btnUpScan
//
//
this
.
toolStripSeparator5
.
Name
=
"toolStripSeparator5"
;
this
.
btnUpScan
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
toolStripSeparator5
.
Size
=
new
System
.
Drawing
.
Size
(
177
,
6
);
this
.
btnUpScan
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
//
this
.
btnUpScan
.
Location
=
new
System
.
Drawing
.
Point
(
862
,
171
);
// toolStripMenuItem1
this
.
btnUpScan
.
Name
=
"btnUpScan"
;
//
this
.
btnUpScan
.
Size
=
new
System
.
Drawing
.
Size
(
130
,
32
);
this
.
toolStripMenuItem1
.
Name
=
"toolStripMenuItem1"
;
this
.
btnUpScan
.
TabIndex
=
275
;
this
.
toolStripMenuItem1
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
26
);
this
.
btnUpScan
.
Text
=
"上层扫码测试"
;
this
.
toolStripMenuItem1
.
Text
=
"扫码测试"
;
this
.
btnUpScan
.
UseVisualStyleBackColor
=
true
;
this
.
toolStripMenuItem1
.
Click
+=
new
System
.
EventHandler
(
this
.
toolStripMenuItem1_Click
);
this
.
btnUpScan
.
Click
+=
new
System
.
EventHandler
(
this
.
btnUpScan_Click
);
//
// btnDownScan
//
this
.
btnDownScan
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnDownScan
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnDownScan
.
Location
=
new
System
.
Drawing
.
Point
(
862
,
209
);
this
.
btnDownScan
.
Name
=
"btnDownScan"
;
this
.
btnDownScan
.
Size
=
new
System
.
Drawing
.
Size
(
130
,
32
);
this
.
btnDownScan
.
TabIndex
=
276
;
this
.
btnDownScan
.
Text
=
"下层扫码测试"
;
this
.
btnDownScan
.
UseVisualStyleBackColor
=
true
;
this
.
btnDownScan
.
Click
+=
new
System
.
EventHandler
(
this
.
btnDownScan_Click
);
//
//
// FormMain
// FormMain
//
//
...
@@ -446,6 +474,8 @@ namespace TheMachine
...
@@ -446,6 +474,8 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
Button
btnResetOut2
;
private
System
.
Windows
.
Forms
.
Button
btnResetOut2
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
toolStripMenuItem1
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
toolStripMenuItem1
;
private
System
.
Windows
.
Forms
.
ToolStripSeparator
toolStripSeparator5
;
private
System
.
Windows
.
Forms
.
ToolStripSeparator
toolStripSeparator5
;
private
System
.
Windows
.
Forms
.
Button
btnDownScan
;
private
System
.
Windows
.
Forms
.
Button
btnUpScan
;
}
}
}
}
TheMachine/FormMain.cs
查看文件 @
2c48ddc
...
@@ -6,7 +6,8 @@ using OnlineStore.LoadCSVLibrary;
...
@@ -6,7 +6,8 @@ using OnlineStore.LoadCSVLibrary;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.ExceptionServices
;
using
System.Runtime.ExceptionServices
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Threading
;
using
System.Threading
;
...
@@ -704,7 +705,40 @@ namespace TheMachine
...
@@ -704,7 +705,40 @@ namespace TheMachine
frm
.
ShowDialog
();
frm
.
ShowDialog
();
frm
.
Dispose
();
frm
.
Dispose
();
}
}
catch
{
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错:"
+
ex
.
ToString
());
}
}
private
void
btnUpScan_Click
(
object
sender
,
EventArgs
e
)
{
string
[]
camers
=
Setting_Init
.
CameraScan_IN_1
;
List
<
CodeLibrary
.
CodeInfo
>
codeInfos
=
CodeManager
.
CameraScan
(
camers
.
ToList
());
string
lastCode
=
""
;
foreach
(
CodeLibrary
.
CodeInfo
ca
in
codeInfos
)
{
lastCode
+=
ca
.
CodeStr
+
"#"
;
}
LogUtil
.
info
(
"["
+
String
.
Join
(
","
,
camers
)
+
"]扫码测试结果:\r\n"
+
lastCode
);
MessageBox
.
Show
(
"["
+
String
.
Join
(
","
,
camers
)
+
crc
.
GetString
(
"Res0109"
,
"]扫码测试结果:"
)
+
lastCode
);
}
private
void
btnDownScan_Click
(
object
sender
,
EventArgs
e
)
{
string
[]
camers
=
Setting_Init
.
CameraScan_IN_2
;
List
<
CodeLibrary
.
CodeInfo
>
codeInfos
=
CodeManager
.
CameraScan
(
camers
.
ToList
());
string
lastCode
=
""
;
foreach
(
CodeLibrary
.
CodeInfo
ca
in
codeInfos
)
{
lastCode
+=
ca
.
CodeStr
+
"#"
;
}
LogUtil
.
info
(
"["
+
String
.
Join
(
","
,
camers
)
+
"]扫码测试结果:\r\n"
+
lastCode
);
MessageBox
.
Show
(
"["
+
String
.
Join
(
","
,
camers
)
+
crc
.
GetString
(
"Res0109"
,
"]扫码测试结果:"
)
+
lastCode
);
}
}
}
}
}
}
\ No newline at end of file
\ No newline at end of file
TheMachine/Program.cs
查看文件 @
2c48ddc
using
ConfigHelper
;
using
ConfigHelper
;
using
log4net.Config
;
using
log4net.Config
;
using
Microsoft.Win32.TaskScheduler
;
//
using Microsoft.Win32.TaskScheduler;
using
OnlineStore.Common
;
using
OnlineStore.Common
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -48,7 +48,7 @@ namespace TheMachine
...
@@ -48,7 +48,7 @@ namespace TheMachine
}
}
}
}
AddOrUpdateStartupTask
();
//
AddOrUpdateStartupTask();
Config
.
LoadMyConfig
(
new
Setting_Init
().
GetType
());
Config
.
LoadMyConfig
(
new
Setting_Init
().
GetType
());
Application
.
ThreadException
+=
Application_ThreadException
;
Application
.
ThreadException
+=
Application_ThreadException
;
Application
.
SetUnhandledExceptionMode
(
UnhandledExceptionMode
.
CatchException
);
Application
.
SetUnhandledExceptionMode
(
UnhandledExceptionMode
.
CatchException
);
...
@@ -62,16 +62,23 @@ namespace TheMachine
...
@@ -62,16 +62,23 @@ namespace TheMachine
Application
.
Run
(
new
FormMain
());
Application
.
Run
(
new
FormMain
());
}
}
private
static
void
CurrentDomain_UnhandledException
(
object
sender
,
UnhandledExceptionEventArgs
e
)
static
void
CurrentDomain_UnhandledException
(
object
sender
,
UnhandledExceptionEventArgs
e
)
{
{
LogU
til
.
error
(
e
.
ToString
()
);
LogU
nhandledException
(
"CurrentDomain_UnhandledException"
,
e
.
ToString
()
+
""
+
e
.
ExceptionObject
.
ToString
()
+
" "
);
}
}
private
static
void
Application_ThreadException
(
object
sender
,
ThreadExceptionEventArgs
e
)
static
void
Application_ThreadException
(
object
sender
,
System
.
Threading
.
ThreadExceptionEventArgs
e
)
{
{
LogU
til
.
error
(
e
.
ToString
()
);
LogU
nhandledException
(
"Application_ThreadException"
,
e
.
ToString
()
+
""
+
e
.
Exception
.
ToString
()
+
" "
);
}
}
static
void
LogUnhandledException
(
string
type
,
string
exceptionobj
)
{
//这里可以进一步地写日志
LogUtil
.
error
(
"【"
+
type
+
"】"
+
exceptionobj
);
MessageBox
.
Show
(
exceptionobj
,
type
);
LogUtil
.
error
(
"【"
+
type
+
"】"
+
exceptionobj
);
}
#
region
Win32
函数的声明
#
region
Win32
函数的声明
...
@@ -104,43 +111,43 @@ namespace TheMachine
...
@@ -104,43 +111,43 @@ namespace TheMachine
public
const
int
SW_RESTORE
=
9
;
public
const
int
SW_RESTORE
=
9
;
#
endregion
#
endregion
public
static
void
AddOrUpdateStartupTask
()
//
public static void AddOrUpdateStartupTask()
{
//
{
// 获取当前程序的路径和名称
//
// 获取当前程序的路径和名称
string
appPath
=
Process
.
GetCurrentProcess
().
MainModule
.
FileName
;
//
string appPath = Process.GetCurrentProcess().MainModule.FileName;
string
TaskName
=
"AutoStartup_"
+
Process
.
GetCurrentProcess
().
MainModule
.
ModuleName
;
//
string TaskName = "AutoStartup_" + Process.GetCurrentProcess().MainModule.ModuleName;
// 创建或更新计划任务
//
// 创建或更新计划任务
using
(
TaskService
taskService
=
new
TaskService
())
//
using (TaskService taskService = new TaskService())
{
//
{
// 获取任务定义,如果不存在则创建新的任务定义
//
// 获取任务定义,如果不存在则创建新的任务定义
TaskDefinition
taskDefinition
;
//
TaskDefinition taskDefinition;
if
(
taskService
.
GetTask
(
TaskName
)
!=
null
)
//
if (taskService.GetTask(TaskName) != null)
{
//
{
taskDefinition
=
taskService
.
GetTask
(
TaskName
).
Definition
;
//
taskDefinition = taskService.GetTask(TaskName).Definition;
}
//
}
else
//
else
{
//
{
taskDefinition
=
taskService
.
NewTask
();
//
taskDefinition = taskService.NewTask();
taskDefinition
.
RegistrationInfo
.
Description
=
TaskName
;
//
taskDefinition.RegistrationInfo.Description = TaskName;
}
//
}
if
(
taskDefinition
.
Triggers
.
Count
==
0
||
taskDefinition
.
Triggers
[
0
].
TriggerType
!=
TaskTriggerType
.
Logon
)
//
if (taskDefinition.Triggers.Count == 0 || taskDefinition.Triggers[0].TriggerType != TaskTriggerType.Logon)
{
//
{
// 设置触发器为用户登录后启动
//
// 设置触发器为用户登录后启动
LogonTrigger
logonTrigger
=
(
LogonTrigger
)
taskDefinition
.
Triggers
.
Add
(
new
LogonTrigger
());
//
LogonTrigger logonTrigger = (LogonTrigger)taskDefinition.Triggers.Add(new LogonTrigger());
logonTrigger
.
Delay
=
TimeSpan
.
FromSeconds
(
5
);
//
logonTrigger.Delay = TimeSpan.FromSeconds(5);
}
//
}
// 设置操作为启动应用程序
//
// 设置操作为启动应用程序
taskDefinition
.
Actions
.
Clear
();
//
taskDefinition.Actions.Clear();
taskDefinition
.
Actions
.
Add
(
new
ExecAction
(
appPath
,
null
,
System
.
IO
.
Path
.
GetDirectoryName
(
appPath
)));
//
taskDefinition.Actions.Add(new ExecAction(appPath, null, System.IO.Path.GetDirectoryName(appPath)));
// 设置任务的运行权限为管理员权限
//
// 设置任务的运行权限为管理员权限
taskDefinition
.
Principal
.
RunLevel
=
TaskRunLevel
.
Highest
;
//
taskDefinition.Principal.RunLevel = TaskRunLevel.Highest;
// 保存任务
//
// 保存任务
taskService
.
RootFolder
.
RegisterTaskDefinition
(
TaskName
,
taskDefinition
,
TaskCreation
.
CreateOrUpdate
,
null
,
null
,
TaskLogonType
.
InteractiveToken
,
null
);
//
taskService.RootFolder.RegisterTaskDefinition(TaskName, taskDefinition, TaskCreation.CreateOrUpdate, null, null, TaskLogonType.InteractiveToken, null);
}
//
}
}
//
}
}
}
}
}
TheMachine/TheMachine.csproj
查看文件 @
2c48ddc
...
@@ -53,12 +53,8 @@
...
@@ -53,12 +53,8 @@
<SpecificVersion>False</SpecificVersion>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SharedDLL\log4net.dll</HintPath>
<HintPath>..\SharedDLL\log4net.dll</HintPath>
</Reference>
</Reference>
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.10.1.0, Culture=neutral, PublicKeyToken=e25603a88b3aa7da, processorArchitecture=MSIL">
<HintPath>..\packages\TaskScheduler.2.10.1\lib\net452\Microsoft.Win32.TaskScheduler.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.CSharp" />
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论