Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-AssemblyLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b38ed426
由
LN
编写于
2019-12-31 09:36:47 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
34fc623e
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
99 行增加
和
97 行删除
dll/RFID/Asa.RFID.dll
source/AssemblyLineClient/FrmLineStore.cs
source/Common/Common.csproj
source/Common/util/HttpHelper.cs
source/Common/util/JsonHelper.cs
source/Common/util/MyWebClient.cs
source/DeviceLibrary/assemblyLine/DischargeLine_Partial.cs
source/DeviceLibrary/assemblymanager/SServerManager.cs
dll/RFID/Asa.RFID.dll
查看文件 @
b38ed42
此文件类型无法预览
source/AssemblyLineClient/FrmLineStore.cs
查看文件 @
b38ed42
...
...
@@ -99,7 +99,7 @@ namespace OnlineStore.AssemblyLine
tabControl1
.
Controls
.
Add
(
lineTabPage
);
}
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
{
{
FrmBase
.
GetVersion
(
true
);
if
(!
LineManager
.
Init
())
{
...
...
source/Common/Common.csproj
查看文件 @
b38ed42
...
...
@@ -57,7 +57,6 @@
<Compile Include="util\AcSerialBean.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
<Compile Include="util\FormUtil.cs" />
<Compile Include="util\HttpHelper.cs" />
<Compile Include="util\JsonHelper.cs" />
<Compile Include="util\LogUtil.cs" />
<Compile Include="util\MyWebClient.cs">
...
...
source/Common/util/HttpHelper.cs
查看文件 @
b38ed42
...
...
@@ -22,57 +22,6 @@ namespace OnlineStore.Common
{
return
Post
(
url
,
paramData
,
Encoding
.
UTF8
);
}
public
static
Operation
Post
(
string
url
,
Operation
operation
,
bool
simulate
)
{
try
{
if
(
simulate
)
{
//模拟服务器返回
operation
.
status
=
200
;
operation
.
data
.
Clear
();
operation
.
data
.
Add
(
"posId"
,
"A001"
);
string
pos
=
"D100-111#D102-222#D104-333"
;
operation
.
data
.
Add
(
"pos"
,
pos
);
if
(
operation
.
op
==
1
||
operation
.
op
==
2
)
{
//入库或出库
string
json
=
JsonHelper
.
SerializeObject
(
operation
);
LogUtil
.
error
(
LOGGER
,
"模拟HTTP服务器返回出库入库信息:"
+
json
);
return
operation
;
}
}
else
{
string
json
=
""
;
try
{
json
=
JsonHelper
.
SerializeObject
(
operation
);
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"JsonHelper.SerializeObject(operation) 出错【operation.op="
+
operation
.
op
+
"】"
+
ex
);
}
string
result
=
Post
(
url
,
json
);
if
(!
string
.
IsNullOrEmpty
(
result
))
{
try
{
return
JsonHelper
.
DeserializeJsonToObject
<
Operation
>(
result
);
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"JsonHelper.DeserializeJsonToObject 出错【result="
+
result
+
"】"
+
ex
);
}
}
}
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"Post 出错【operation.op="
+
operation
.
op
+
"】:"
+
ex
);
}
return
null
;
}
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
public
static
string
Post
(
string
url
,
string
paramData
,
Encoding
encoding
)
{
...
...
source/Common/util/JsonHelper.cs
查看文件 @
b38ed42
...
...
@@ -63,36 +63,4 @@ namespace OnlineStore.Common
return
t
;
}
}
///// <summary>
///// 与服务器通信用对象
///// </summary>
//public class Operation
//{
// private string _cid = "";
// public string cid
// {
// get { return _cid; }
// set { _cid = value; }
// }
// public int seq { get; set; }
// public int op { get; set; }
// public int status { get; set; }
// private string _error = "";
// public string error
// {
// get { return _error; }
// set { _error = value; }
// }
// private Dictionary<string, string> _data = new Dictionary<string,string>();
// public Dictionary<string, string> data {
// get { return _data; }
// set { _data = value; }
// }
//}
}
source/Common/util/MyWebClient.cs
查看文件 @
b38ed42
using
System
;
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Security
;
using
System.Reflection
;
using
System.Text
;
namespace
OnlineStore.Common
...
...
@@ -42,4 +46,81 @@ namespace OnlineStore.Common
return
result
;
}
}
public
class
HttpHelper
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
static
string
Post
(
string
url
,
string
paramData
)
{
return
Post
(
url
,
paramData
,
Encoding
.
UTF8
);
}
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
public
static
string
Post
(
string
url
,
string
paramData
,
Encoding
encoding
)
{
if
(
isLog
==
1
)
{
LOGGER
.
Info
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
}
if
(
paramData
!=
"null"
&&
paramData
!=
null
)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string
result
=
""
;
if
(
url
.
ToLower
().
IndexOf
(
"https"
,
System
.
StringComparison
.
Ordinal
)
>
-
1
)
{
ServicePointManager
.
ServerCertificateValidationCallback
=
new
RemoteCertificateValidationCallback
((
sender
,
certificate
,
chain
,
errors
)
=>
{
return
true
;
});
}
try
{
var
wc
=
new
MyWebClient
(
5000
);
if
(
string
.
IsNullOrEmpty
(
wc
.
Headers
[
"Content-Type"
]))
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
wc
.
Encoding
=
encoding
;
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
//LogUtil.info(result);
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"POST ERROR:"
+
e
.
StackTrace
,
1001
);
}
if
(!
result
.
Contains
(
"null"
)
&&
result
.
Length
!=
0
)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
if
(
isLog
==
1
)
{
LOGGER
.
Info
(
"收到服务器数据【"
+
result
+
"】"
);
}
return
result
;
}
public
static
string
Get
(
string
url
)
{
return
Get
(
url
,
Encoding
.
UTF8
);
}
public
static
string
Get
(
string
url
,
Encoding
encoding
)
{
try
{
LogUtil
.
info
(
LOGGER
,
"HTTP GET FROM: "
+
url
);
var
wc
=
new
WebClient
{
Encoding
=
encoding
};
var
readStream
=
wc
.
OpenRead
(
url
);
using
(
var
sr
=
new
StreamReader
(
readStream
,
encoding
))
{
var
result
=
sr
.
ReadToEnd
();
LogUtil
.
info
(
LOGGER
,
"receive << "
+
result
);
return
result
;
}
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"HTTP GET ERROR:"
+
e
.
Message
,
1002
);
}
return
""
;
}
}
}
source/DeviceLibrary/assemblyLine/DischargeLine_Partial.cs
查看文件 @
b38ed42
...
...
@@ -146,8 +146,8 @@ namespace OnlineStore.DeviceLibrary
{
robotIndex
=
2
;
}
SServerManager
.
GetTraySize
(
Name
,
robotIndex
,
LastCodeList
,
out
LastWidth
);
LogInfo
(
hengyiName
+
"出口有料,二维码["
+
lastCode
+
"] 获取料盘尺寸【"
+
LastWidth
+
"】"
);
string
result
=
SServerManager
.
GetTraySize
(
Name
,
robotIndex
,
LastCodeList
,
out
LastWidth
);
LogInfo
(
hengyiName
+
"出口有料,二维码["
+
lastCode
+
"] 获取料盘尺寸【"
+
LastWidth
+
"】
【"
+
result
+
"】
"
);
}
// MoveInfo.EndMove();
}
...
...
source/DeviceLibrary/assemblymanager/SServerManager.cs
查看文件 @
b38ed42
...
...
@@ -177,7 +177,7 @@ namespace OnlineStore.DeviceLibrary
{
return
msg
=
deviceName
+
" 【"
+
robotIndex
+
"】 条码【 "
+
codeStr
+
"】没有收到服务器反馈"
;
}
else
if
(
(!
string
.
IsNullOrEmpty
(
serverResult
.
msg
))
||
serverResult
.
code
.
Equals
(
0
).
Equals
(
false
))
else
if
(
serverResult
.
code
.
Equals
(
0
).
Equals
(
false
))
{
// code: 0为正常,其他为异常,
// msg:消息,
...
...
@@ -220,19 +220,23 @@ namespace OnlineStore.DeviceLibrary
ServerData
serverResult
=
JsonHelper
.
DeserializeJsonToObject
<
ServerData
>(
resultStr
);
if
(
serverResult
==
null
)
{
return
msg
=
deviceName
+
"UpdateTrayLoc【 "
+
barcode
+
"】【"
+
status
+
"】【"
+
locInfo
+
"】没有收到服务器反馈"
;
msg
=
deviceName
+
"UpdateTrayLoc【 "
+
barcode
+
"】【"
+
status
+
"】【"
+
locInfo
+
"】没有收到服务器反馈"
;
}
else
if
(
(!
string
.
IsNullOrEmpty
(
serverResult
.
msg
))
||
serverResult
.
code
.
Equals
(
0
).
Equals
(
false
))
else
if
(
serverResult
.
code
.
Equals
(
0
).
Equals
(
false
))
{
// code: 0为正常,其他为异常, msg: 消息, data: 为空
return
msg
=
deviceName
+
" UpdateTrayLoc【 "
+
barcode
+
"】【"
+
status
+
"】【"
+
locInfo
+
"】 :"
+
"["
+
serverResult
.
code
+
"]"
+
serverResult
.
msg
;
msg
=
deviceName
+
" UpdateTrayLoc【 "
+
barcode
+
"】【"
+
status
+
"】【"
+
locInfo
+
"】 :"
+
"["
+
serverResult
.
code
+
"]"
+
serverResult
.
msg
;
}
if
(!
msg
.
Equals
(
""
))
{
LogUtil
.
error
(
msg
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
deviceName
+
" "
+
ex
.
ToString
());
}
return
""
;
return
msg
;
}
...
...
@@ -256,7 +260,7 @@ namespace OnlineStore.DeviceLibrary
{
return
msg
=
deviceName
+
"PutShelfFinished【 "
+
barcode
+
"】【"
+
rfid
+
"】【"
+
rfidPosId
+
"】没有收到服务器反馈"
;
}
else
if
(
(!
string
.
IsNullOrEmpty
(
serverResult
.
msg
))
||
serverResult
.
code
.
Equals
(
0
).
Equals
(
false
))
else
if
(
serverResult
.
code
.
Equals
(
0
).
Equals
(
false
))
{
return
msg
=
deviceName
+
" PutShelfFinished【 "
+
barcode
+
"】【"
+
rfid
+
"】【"
+
rfidPosId
+
"】 :"
+
serverResult
.
msg
;
}
...
...
@@ -270,7 +274,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
error
(
deviceName
+
" "
+
ex
.
ToString
());
}
return
""
;
}
}
}
public
class
LocStatus
{
...
...
@@ -289,8 +293,9 @@ namespace OnlineStore.DeviceLibrary
}
public
class
ServerData
{
//返回: {"code": 0, "msg":"ok", "data":{"rfid":"xxx","smallEmpty":0,"bigEmpty":0, "packageEmpty":0,"cutPackageTask":0,"packageTask":10,"cutTask":10, "smallTask":5, "bigTask":5}
public
int
code
{
get
;
set
;
}
//{"code":0,"msg":"ok","data":"7"}
//返回: {"code": 0, "msg":"ok", "data":{"rfid":"xxx","smallEmpty":0,"bigEmpty":0, "packageEmpty":0,"cutPackageTask":0,"packageTask":10,"cutTask":10, "smallTask":5, "bigTask":5}
public
int
code
{
get
;
set
;
}
public
string
msg
{
get
;
set
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论