Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a9171799
由
LN
编写于
2020-06-23 10:44:06 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
超时改为3秒,入库验证增加超时处理。出库增加信号检测。
1 个父辈
41b47a48
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
97 行增加
和
119 行删除
source/ACSingleStore/FrmStoreBox.Designer.cs
source/ACSingleStore/FrmStoreBox.cs
source/Common/util/HttpHelper.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
source/DeviceLibrary/store/StoreStep.cs
source/ACSingleStore/FrmStoreBox.Designer.cs
查看文件 @
a917179
此文件的差异被折叠,
点击展开。
source/ACSingleStore/FrmStoreBox.cs
查看文件 @
a917179
此文件的差异被折叠,
点击展开。
source/Common/util/HttpHelper.cs
查看文件 @
a917179
...
...
@@ -19,89 +19,52 @@ namespace OnlineStore.Common
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
);
}
//public static bool PingURLIP(string url, int ms = 100)
//{
// string[] urlArray = url.Split('/');
// if (urlArray.Length > 3)
// {
// string ip = urlArray[2];
// Ping pingSender = new Ping();
// PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
// if (reply.Status == IPStatus.Success)
// {
// //通
// return true;
// }
// else
// {
// //不通
// return false;
// }
// }
// return true;
//}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="operation"></param>
/// <param name="simulate">是否模拟服务器返回结果</param>
/// <returns></returns>
public
static
Operation
Post
(
string
url
,
Operation
operation
,
bool
simulate
)
public
static
Operation
Post
(
string
url
,
Operation
operation
,
out
bool
isTimeOut
)
{
isTimeOut
=
false
;
try
{
//如果Op=0或者Op=5,先拼Ip,不通不发送
//if (operation.op < 0 || operation.op.Equals(5))
//{
// if (PingURLIP(url, 100).Equals(false))
// {
// return null;
{
//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;
// }
//}
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
)
{
LogUtil
.
error
(
"JsonHelper.SerializeObject(operation) 出错【operation.op="
+
operation
.
op
+
"】"
+
ex
);
}
else
string
result
=
Post
(
url
,
json
,
Encoding
.
UTF8
,
out
isTimeOut
);
if
(!
string
.
IsNullOrEmpty
(
result
))
{
string
json
=
""
;
try
{
json
=
JsonHelper
.
SerializeObject
(
operation
);
return
JsonHelper
.
DeserializeJsonToObject
<
Operation
>(
result
);
}
catch
(
Exception
ex
)
{
LogUtil
.
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
)
{
LogUtil
.
error
(
"JsonHelper.DeserializeJsonToObject 出错【result="
+
result
+
"】"
+
ex
);
}
LogUtil
.
error
(
"JsonHelper.DeserializeJsonToObject 出错【result="
+
result
+
"】"
+
ex
);
}
}
//}
}
catch
(
Exception
ex
)
{
...
...
@@ -110,12 +73,9 @@ namespace OnlineStore.Common
return
null
;
}
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
public
static
string
Post
(
string
url
,
string
paramData
,
Encoding
encoding
)
public
static
string
Post
(
string
url
,
string
paramData
,
Encoding
encoding
,
out
bool
IsTimeOut
)
{
//if (PingURLIP(url, 100).Equals(false))
//{
// return null;
//}
IsTimeOut
=
false
;
if
(
isLog
==
1
)
{
LOGGER
.
Info
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
...
...
@@ -134,7 +94,7 @@ namespace OnlineStore.Common
try
{
var
wc
=
new
MyWebClient
(
10
000
);
var
wc
=
new
MyWebClient
(
3
000
);
if
(
string
.
IsNullOrEmpty
(
wc
.
Headers
[
"Content-Type"
]))
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
wc
.
Encoding
=
encoding
;
...
...
@@ -142,6 +102,11 @@ namespace OnlineStore.Common
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
//LogUtil.info(result);
}
catch
(
WebException
ex
)
{
IsTimeOut
=
true
;
LogUtil
.
error
(
LOGGER
,
"POST WebException :"
+
ex
.
ToString
(),
101
);
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
LOGGER
,
"POST ERROR:"
+
e
.
ToString
(),
1
);
...
...
@@ -157,30 +122,30 @@ namespace OnlineStore.Common
return
result
;
}
public
static
string
Get
(
string
url
)
{
return
Get
(
url
,
Encoding
.
UTF8
);
}
//
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
(
LOGGER
,
"HTTP GET ERROR:"
+
e
.
Message
,
2
);
}
return
""
;
}
//
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(LOGGER, "HTTP GET ERROR:" + e.Message, 2);
//
}
//
return "";
//
}
}
}
\ No newline at end of file
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
查看文件 @
a917179
...
...
@@ -1252,31 +1252,39 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil
.
info
(
LOGGER
,
logName
+
" 设备未启动,验证失败"
);
return
false
;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil
.
debug
(
LOGGER
,
logName
+
"发送给服务器验证入库PosID"
);
}
//发送扫码内容到服务器进行入库操作
Operation
operation
=
getLineBoxStatus
();
operation
.
op
=
1
;
operation
.
data
=
new
Dictionary
<
string
,
string
>()
{
{
"code"
,
message
},
{
"boxId"
,
StoreID
.
ToString
()
},
{
"rfid"
,
rfid
}
};
operation
.
data
.
Add
(
"inPos"
,
posId
);
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
operation
,
false
);
if
(
resultOperation
==
null
)
{
// CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogUtil
.
info
(
LOGGER
,
logName
+
" 没有收到服务器反馈 "
);
}
else
if
(!
string
.
IsNullOrEmpty
(
resultOperation
.
msg
))
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
//如果有提示消息,直接显示提示
LogUtil
.
info
(
LOGGER
,
logName
+
"服务器反馈 :"
+
resultOperation
.
msg
);
bool
timeOut
=
false
;
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
operation
,
out
timeOut
);
if
(
timeOut
)
{
LogUtil
.
info
(
LOGGER
,
logName
+
" 第"
+
i
+
"次发送超时 "
);
continue
;
}
if
(
resultOperation
==
null
)
{
// CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogUtil
.
info
(
LOGGER
,
logName
+
" 没有收到服务器反馈 "
);
}
else
if
(!
string
.
IsNullOrEmpty
(
resultOperation
.
msg
))
{
//如果有提示消息,直接显示提示
LogUtil
.
info
(
LOGGER
,
logName
+
"服务器反馈 :"
+
resultOperation
.
msg
);
}
else
if
(
resultOperation
.
op
.
Equals
(
1
))
{
LogUtil
.
info
(
LOGGER
,
logName
+
" 成功"
);
return
true
;
}
else
if
(
resultOperation
.
op
.
Equals
(
1
))
{
LogUtil
.
info
(
LOGGER
,
logName
+
" 成功"
);
return
true
;
}
break
;
}
}
catch
(
Exception
ex
)
...
...
@@ -1621,7 +1629,8 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
info
(
LOGGER
,
StoreName
+
"没有湿度预警范围,需要从服务器获取,发送OP="
+
lineOperation
.
op
);
}
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
false
);
bool
isTimeout
=
false
;
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
out
isTimeout
);
//发送状态信息到服务器
if
(
resultOperation
==
null
||
(
resultOperation
.
op
<=
0
))
...
...
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
查看文件 @
a917179
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/store/StoreStep.cs
查看文件 @
a917179
...
...
@@ -256,13 +256,17 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
SO_25_InoutToP1
,
/// <summary>
/// 料仓出库,检测料仓门口信号
/// </summary>
SO_26_CheckTray
,
/// <summary>
/// 料仓出库,,升降轴返回,, 轴2至P1( 待机点)
/// </summary>
SO_2
6
_GoBack
,
SO_2
7
_GoBack
,
/// <summary>
/// 等待拿走物品
/// </summary>
SO_2
7
_WaitTake
,
SO_2
8
_WaitTake
,
#
endregion
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论