Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
SO1196_X800
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9d5f1ef3
由
刘韬
编写于
2023-07-13 13:08:48 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
91e80306
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
152 行增加
和
22 行删除
Common/Setting_Init.cs
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
DeviceLibrary/theMachine/MainMachine _BtnProcess.cs
DeviceLibrary/theMachine/MainMachine.cs
DeviceLibrary/theMachine/MainMachine_Counting.cs
DeviceLibrary/theMachine/MainMachine_InMove.cs
TheMachine/Program.cs
TheMachine/SettingControl.Designer.cs
TheMachine/SettingControl.cs
TheMachine/TheMachine.csproj
Common/Setting_Init.cs
查看文件 @
9d5f1ef
...
...
@@ -30,6 +30,9 @@ namespace OnlineStore.Common
[
MyConfigComment
(
"是否启用蜂鸣器"
)]
public
static
MyConfig
<
bool
>
Device_EnableBuzzer
=
true
;
[
MyConfigComment
(
"是否必须包含PN"
)]
public
static
MyConfig
<
bool
>
Device_MustHavePN
=
false
;
[
MyConfigComment
(
"X高压端口"
)]
public
static
MyConfig
<
string
>
XRay_Port
=
"http://192.168.1.4:50001"
;
...
...
@@ -51,6 +54,12 @@ namespace OnlineStore.Common
[
MyConfigComment
(
"启用管理员密码"
)]
public
static
MyConfig
<
bool
>
User_Enable
=
false
;
[
MyConfigComment
(
"SO20117_Authurl"
)]
public
static
MyConfig
<
string
>
SO20117_Authurl
=
"http://10.44.160.15:21021/api/TokenAuth/Authenticate"
;
[
MyConfigComment
(
"SO20117_pnurl"
)]
public
static
MyConfig
<
string
>
SO20117_pnurl
=
"http://10.44.160.15:21021/api/services/app/Reel/GetReelInfoById"
;
[
MyConfigComment
(
"NG箱当前料盘数量"
)]
public
static
MyConfig
<
int
>
Temp_NGBox_Count
=
0
;
[
MyConfigComment
(
"NG箱最大料盘数量"
)]
...
...
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
查看文件 @
9d5f1ef
using
OnlineStore
;
using
Newtonsoft.Json
;
using
OnlineStore
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
DeviceLibrary
{
class
ServerCommunication
public
class
ServerCommunication
{
volatile
StoreStatus
_storeStatus
=
StoreStatus
.
Debugging
;
public
StoreStatus
storeStatus
{
...
...
@@ -501,9 +504,88 @@ namespace DeviceLibrary
path
=
path
.
Substring
(
0
,
path
.
Length
-
1
);
return
path
;
}
static
SO20017Data
sO20017AuthResult
=
null
;
public
static
string
GetPnByReelid
(
string
reelid
)
{
if
(
sO20017AuthResult
==
null
||
sO20017AuthResult
.
ExportTime
<
DateTime
.
Now
)
{
//http://10.44.160.15:21021/api/TokenAuth/Authenticate
string
authstring
=
@
"{
""
userNameOrEmailAddress
""
:
""
admin
""
,
""
password
""
:
""
123
qwe
""
,
""
rememberClient
""
:
true
}
";
//LogUtil.info(Setting_Init.SO20117_Authurl);
MyWebClient
wc
=
new
MyWebClient
(
15000
);
try
{
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
var
recivedata
=
wc
.
UploadData
(
Setting_Init
.
SO20117_Authurl
,
Encoding
.
UTF8
.
GetBytes
(
authstring
));
var
recivestring
=
Encoding
.
UTF8
.
GetString
(
recivedata
);
//LogUtil.info(recivestring);
sO20017AuthResult
=
JsonConvert
.
DeserializeObject
<
SO20017Data
>(
recivestring
);
sO20017AuthResult
.
ExportTime
=
DateTime
.
Now
.
AddSeconds
(
sO20017AuthResult
.
result
.
expireInSeconds
-
60
);
LogUtil
.
info
(
sO20017AuthResult
.
ExportTime
.
ToString
());
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
ex
.
ToString
());
}
}
if
(
sO20017AuthResult
==
null
)
return
""
;
MyWebClient
wc2
=
new
MyWebClient
(
15000
);
try
{
string
authstring
=
"Bearer "
+
sO20017AuthResult
.
result
.
accessToken
;
//LogUtil.info(authstring);
wc2
.
Headers
.
Add
(
"Authorization"
,
authstring
);
string
url
=
Setting_Init
.
SO20117_pnurl
+
"?reelid="
+
reelid
;
//LogUtil.info(url);
var
revdata
=
wc2
.
DownloadData
(
url
);
var
revstring
=
Encoding
.
UTF8
.
GetString
(
revdata
);
LogUtil
.
info
(
revstring
);
var
data
=
JsonConvert
.
DeserializeObject
<
SO20017Data
>(
revstring
);
if
(!
string
.
IsNullOrEmpty
(
data
.
result
.
partNoId
))
{
return
data
.
result
.
partNoId
;
}
else
LogUtil
.
info
(
JsonConvert
.
SerializeObject
(
data
.
result
));
}
catch
(
Exception
ex
)
{
if
(
ex
.
GetType
().
Name
==
"WebException"
)
{
WebException
we
=
(
WebException
)
ex
;
using
(
HttpWebResponse
hr
=
(
HttpWebResponse
)
we
.
Response
)
{
int
statusCode
=
(
int
)
hr
.
StatusCode
;
StringBuilder
sb
=
new
StringBuilder
();
StreamReader
sr
=
new
StreamReader
(
hr
.
GetResponseStream
(),
Encoding
.
UTF8
);
sb
.
Append
(
sr
.
ReadToEnd
());
LogUtil
.
error
(
string
.
Format
(
"StatusCode:{0},Content:{1}"
,
statusCode
,
sb
));
// StatusCode:401,Content:test
}
}
LogUtil
.
error
(
ex
.
ToString
());
}
return
""
;
}
}
public
class
SO20017Data
{
public
SO20017Result
result
;
public
DateTime
ExportTime
=
DateTime
.
Now
;
}
public
class
SO20017Result
{
public
string
accessToken
;
public
long
expireInSeconds
;
public
string
partNoId
;
}
public
class
ResultData
{
//{"code":0,"msg":"ok","data":"7"}
...
...
DeviceLibrary/theMachine/MainMachine _BtnProcess.cs
查看文件 @
9d5f1ef
...
...
@@ -118,14 +118,18 @@ namespace DeviceLibrary
{
Thread
.
Sleep
(
500
);
}
Label_X_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
while
(!
Label_X_Axis
.
IsHomeMoveEnd
)
{
Thread
.
Sleep
(
500
);
}
Label_R_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
while
(!
Label_R_Axis
.
IsHomeMoveEnd
)
{
Thread
.
Sleep
(
500
);
}
Label_X_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
}
Label_Y_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
while
(!
Label_
X_Axis
.
IsHomeMoveEnd
||
!
Label_
Y_Axis
.
IsHomeMoveEnd
)
while
(!
Label_Y_Axis
.
IsHomeMoveEnd
)
{
Thread
.
Sleep
(
500
);
}
...
...
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
9d5f1ef
...
...
@@ -350,7 +350,6 @@ namespace DeviceLibrary
CylinderMove
(
ResetMoveInfo
,
IO_Type
.
Unloading_Car_Location_Down
,
IO_Type
.
Unloading_Car_Location_Up
,
IO_VALUE
.
LOW
);
}
ResetMoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset_01
);
PrintJob
=
null
;
break
;
...
...
@@ -360,6 +359,7 @@ namespace DeviceLibrary
Loading_Batch_Axis
.
HomeMove
(
null
,
forceHome
);
Unloading_Batch_Axis
.
HomeMove
(
null
,
forceHome
);
Label_Z_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
GrabImageEX
();
break
;
case
MoveStep
.
H02_HomeReset_02
:
ResetMoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset
);
...
...
@@ -376,12 +376,12 @@ namespace DeviceLibrary
case
MoveStep
.
H02_HomeReset_1
:
ResetMoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset_2
);
ResetMoveInfo
.
log
(
"贴标X轴回原"
);
Label_X_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
Label_R_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
Label_X_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
break
;
case
MoveStep
.
H02_HomeReset_2
:
ResetMoveInfo
.
NextMoveStep
(
MoveStep
.
H03_HomeReset
);
ResetMoveInfo
.
log
(
"贴标Y轴回原"
);
Label_R_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
Label_Y_Axis
.
HomeMove
(
ResetMoveInfo
,
forceHome
);
break
;
case
MoveStep
.
H03_HomeReset
:
...
...
DeviceLibrary/theMachine/MainMachine_Counting.cs
查看文件 @
9d5f1ef
...
...
@@ -64,7 +64,7 @@ namespace DeviceLibrary
}
else
{
Msg
.
add
(
"点料机放料位没有检测到料盘"
,
MsgLevel
.
alarm
);
RobotManage
.
UserPause
(
"点料机放料位没有检测到料盘"
);
//
RobotManage.UserPause("点料机放料位没有检测到料盘");
}
break
;
case
MoveStep
.
Count_02
:
...
...
@@ -167,12 +167,26 @@ namespace DeviceLibrary
}
}
}
if
(
string
.
IsNullOrWhiteSpace
(
CountMoveInfo
.
MoveParam
.
PN
))
{
CountMoveInfo
.
log
(
"从MES获取PN reelid="
+
CountMoveInfo
.
MoveParam
.
ReeID
);
var
pn
=
ServerCommunication
.
GetPnByReelid
(
CountMoveInfo
.
MoveParam
.
ReeID
);
CountMoveInfo
.
MoveParam
.
PN
=
pn
;
}
//var xx = CountMoveInfo.MoveParam.codeInfos.Find(c=> { return c.CodeStr.StartsWith("S20") && c.CodeType == "barcode"; });
//if (xx != null)
//{
// CountMoveInfo.MoveParam.codeInfos.Remove(xx);
// CountMoveInfo.log("移除了一个点料标签上的reelid");
//}
if
(
Setting_Init
.
Device_MustHavePN
&&
string
.
IsNullOrWhiteSpace
(
CountMoveInfo
.
MoveParam
.
PN
))
{
CountMoveInfo
.
NextMoveStep
(
MoveStep
.
Count_ReadyOut
);
CountMoveInfo
.
log
(
$
"未识别到PN,送到NG口"
);
CountMoveInfo
.
MoveParam
.
IsNg
=
true
;
CountMoveInfo
.
MoveParam
.
NgMsg
=
"未识别到PN"
;
}
CountMoveInfo
.
log
(
"codeProcess:"
+
CountMoveInfo
.
MoveParam
.
ReeID
+
";"
+
CountMoveInfo
.
MoveParam
.
PN
);
}
}
...
...
@@ -257,7 +271,7 @@ namespace DeviceLibrary
CountMoveInfo
.
log
(
"料盘已取走"
);
break
;
case
MoveStep
.
Count_20
:
if
(
IOValue
(
IO_Type
.
Counting_ExitDoor_Close
).
Equals
(
IO_VALUE
.
HIGH
))
if
(
IOValue
(
IO_Type
.
Counting_ExitDoor_Close
).
Equals
(
IO_VALUE
.
HIGH
)
||
OutMoveInfo
.
MoveStep
>=
MoveStep
.
Out_03
)
{
CountMoveInfo
.
NextMoveStep
(
MoveStep
.
Count_21
);
CountMoveInfo
.
log
(
"出口门已关闭"
);
...
...
DeviceLibrary/theMachine/MainMachine_InMove.cs
查看文件 @
9d5f1ef
...
...
@@ -168,7 +168,7 @@ namespace DeviceLibrary
}
else
{
Msg
.
add
(
"点料区有料盘无法继续"
,
MsgLevel
.
alarm
);
RobotManage
.
UserPause
(
"点料区有料盘无法继续"
);
//
RobotManage.UserPause("点料区有料盘无法继续");
}
break
;
case
MoveStep
.
In_16
:
...
...
TheMachine/Program.cs
查看文件 @
9d5f1ef
...
...
@@ -23,6 +23,8 @@ namespace TheMachine
[
STAThread
]
static
void
Main
()
{
int
rightangle
=
239
;
List
<
int
>
angles
=
new
List
<
int
>
{
10
,
112
,
239
,
124
,
358
};
List
<
int
>
xxxxx
=
new
List
<
int
>
{
358
,
300
,
310
,
10
,
50
,
100
,
90
,
90
,
90
};
...
...
@@ -83,6 +85,9 @@ namespace TheMachine
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
XmlConfigurator
.
Configure
();
//var pn= ServerCommunication.GetPnByReelid("S202306181351530002");
//LogUtil.info(pn);
//return;
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
Form1
());
...
...
TheMachine/SettingControl.Designer.cs
查看文件 @
9d5f1ef
...
...
@@ -38,11 +38,12 @@ namespace TheMachine
this
.
cb_labelselect
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
btn_Calibration
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
X
光调试
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
buttonmunial
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_closexray
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_takephoto
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_openxray
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
uC_SetUserPassword1
=
new
TheMachine
.
UC_SetUserPassword
();
this
.
buttonmunial
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cb_musthavepn
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
groupBox1
.
SuspendLayout
();
this
.
X
光调试
.
SuspendLayout
();
this
.
SuspendLayout
();
...
...
@@ -60,7 +61,7 @@ namespace TheMachine
// cb_EnableBuzzer
//
this
.
cb_EnableBuzzer
.
AutoSize
=
true
;
this
.
cb_EnableBuzzer
.
Location
=
new
System
.
Drawing
.
Point
(
14
,
52
);
this
.
cb_EnableBuzzer
.
Location
=
new
System
.
Drawing
.
Point
(
14
,
48
);
this
.
cb_EnableBuzzer
.
Name
=
"cb_EnableBuzzer"
;
this
.
cb_EnableBuzzer
.
Size
=
new
System
.
Drawing
.
Size
(
84
,
16
);
this
.
cb_EnableBuzzer
.
TabIndex
=
9
;
...
...
@@ -142,6 +143,16 @@ namespace TheMachine
this
.
X
光调试
.
TabStop
=
false
;
this
.
X
光调试
.
Text
=
"groupBox2"
;
//
// buttonmunial
//
this
.
buttonmunial
.
Location
=
new
System
.
Drawing
.
Point
(
26
,
125
);
this
.
buttonmunial
.
Name
=
"buttonmunial"
;
this
.
buttonmunial
.
Size
=
new
System
.
Drawing
.
Size
(
146
,
43
);
this
.
buttonmunial
.
TabIndex
=
13
;
this
.
buttonmunial
.
Text
=
"手动点料"
;
this
.
buttonmunial
.
UseVisualStyleBackColor
=
true
;
this
.
buttonmunial
.
Click
+=
new
System
.
EventHandler
(
this
.
buttonmunial_Click
);
//
// btn_closexray
//
this
.
btn_closexray
.
Location
=
new
System
.
Drawing
.
Point
(
178
,
27
);
...
...
@@ -181,15 +192,16 @@ namespace TheMachine
this
.
uC_SetUserPassword1
.
Size
=
new
System
.
Drawing
.
Size
(
405
,
272
);
this
.
uC_SetUserPassword1
.
TabIndex
=
10
;
//
//
buttonmunial
//
cb_musthavepn
//
this
.
buttonmunial
.
Location
=
new
System
.
Drawing
.
Point
(
26
,
125
);
this
.
buttonmunial
.
Name
=
"buttonmunial"
;
this
.
buttonmunial
.
Size
=
new
System
.
Drawing
.
Size
(
146
,
43
);
this
.
buttonmunial
.
TabIndex
=
13
;
this
.
buttonmunial
.
Text
=
"手动点料"
;
this
.
buttonmunial
.
UseVisualStyleBackColor
=
true
;
this
.
buttonmunial
.
Click
+=
new
System
.
EventHandler
(
this
.
buttonmunial_Click
);
this
.
cb_musthavepn
.
AutoSize
=
true
;
this
.
cb_musthavepn
.
Location
=
new
System
.
Drawing
.
Point
(
14
,
74
);
this
.
cb_musthavepn
.
Name
=
"cb_musthavepn"
;
this
.
cb_musthavepn
.
Size
=
new
System
.
Drawing
.
Size
(
96
,
16
);
this
.
cb_musthavepn
.
TabIndex
=
9
;
this
.
cb_musthavepn
.
Text
=
"必须匹配到PN"
;
this
.
cb_musthavepn
.
UseVisualStyleBackColor
=
true
;
this
.
cb_musthavepn
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_EnableBuzzer_CheckedChanged
);
//
// SettingControl
//
...
...
@@ -198,6 +210,7 @@ namespace TheMachine
this
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
Controls
.
Add
(
this
.
uC_SetUserPassword1
);
this
.
Controls
.
Add
(
this
.
cb_autorun
);
this
.
Controls
.
Add
(
this
.
cb_musthavepn
);
this
.
Controls
.
Add
(
this
.
cb_EnableBuzzer
);
this
.
Name
=
"SettingControl"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
818
,
561
);
...
...
@@ -224,5 +237,6 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
Button
btn_openxray
;
private
System
.
Windows
.
Forms
.
Button
btn_printertest
;
private
System
.
Windows
.
Forms
.
Button
buttonmunial
;
private
System
.
Windows
.
Forms
.
CheckBox
cb_musthavepn
;
}
}
TheMachine/SettingControl.cs
查看文件 @
9d5f1ef
...
...
@@ -70,6 +70,7 @@ namespace TheMachine
Config
.
PropertyBind
(
Setting_Init
.
Device_EnableBuzzer
.
Key
,
cb_EnableBuzzer
,
"Checked"
,
"CheckedChanged"
,
true
);
Config
.
PropertyBind
(
Setting_Init
.
Printer_Labelname
.
Key
,
cb_labelselect
,
"SelectedItem"
,
"SelectedValueChanged"
);
Config
.
PropertyBind
(
Setting_Init
.
App_AutoRun
.
Key
,
cb_autorun
,
"Checked"
,
"CheckedChanged"
,
false
);
Config
.
PropertyBind
(
Setting_Init
.
Device_MustHavePN
.
Key
,
cb_musthavepn
,
"Checked"
,
"CheckedChanged"
,
false
);
this
.
cb_autorun
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_autorun_CheckedChanged
);
loadlabellist
();
}
...
...
TheMachine/TheMachine.csproj
查看文件 @
9d5f1ef
...
...
@@ -188,6 +188,7 @@
</Compile>
<EmbeddedResource Include="AboutBox1.resx">
<DependentUpon>AboutBox1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="AxisControl.resx">
<DependentUpon>AxisControl.cs</DependentUpon>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论