Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
SmartShelf
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 8ebdcd5d
由
LN
编写于
2020-08-14 09:13:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
三色灯有亮灯时增加黄灯闪烁功能。
1 个父辈
11f9fdc6
全部展开
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
143 行增加
和
34 行删除
DeviceLibrary/Config/linePositions.csv
DeviceLibrary/DeviceLibrary/led/BaseLEDManager.cs
DeviceLibrary/manager/BOXManager.cs
DeviceLibrary/manager/BOXManager_Partial.cs
LoadCVSLibrary/CSVAttribute.cs
LoadCVSLibrary/CSVReaderBase.cs
LoadCVSLibrary/position/BoxPosition.cs
LoadCVSLibrary/position/CSVPositionReader.cs
SmartShelf/FrmStore.cs
DeviceLibrary/Config/linePositions.csv
查看文件 @
8ebdcd5
此文件的差异被折叠,
点击展开。
DeviceLibrary/DeviceLibrary/led/BaseLEDManager.cs
查看文件 @
8ebdcd5
...
...
@@ -77,20 +77,24 @@ namespace SmartShelf.DeviceLibrary
/// </summary>
public
static
int
CurrLedStatus
=
-
1
;
p
rivate
static
List
<
int
>
StatusLedDmx
=
new
List
<
int
>();
p
ublic
static
List
<
int
>
StatusLedDmx
=
new
List
<
int
>();
/// <summary>
/// 打开状态灯
/// </summary>
public
static
void
OpenStatusLights
(
string
color
=
"green"
)
public
static
void
UpdateStatusLights
(
Dictionary
<
string
,
string
>
dataMap
)
{
CloseStatusLights
(
""
);
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
Dictionary
<
string
,
List
<
Light
>>
lightsMap
=
new
Dictionary
<
string
,
List
<
Light
>>();
List
<
string
>
ipDmx
=
new
List
<
string
>(
dataMap
.
Keys
);
foreach
(
string
key
in
ipDmx
)
{
List
<
Light
>
sLed
=
new
List
<
Light
>(
);
foreach
(
int
dmx
in
StatusLedDmx
)
string
color
=
dataMap
[
key
];
string
[]
array
=
key
.
Split
(
'_'
);
if
(
array
.
Length
==
2
)
{
string
ip
=
array
[
0
];
int
dmx
=
Convert
.
ToInt32
(
array
[
1
]);
LEDBaseModule
module
=
GetLedModule
(
ip
);
List
<
Light
>
sLed
=
new
List
<
Light
>();
for
(
int
index
=
0
;
index
<
module
.
Max_Light
;
index
++)
{
if
(
"green"
.
Equals
(
color
))
...
...
@@ -101,28 +105,56 @@ namespace SmartShelf.DeviceLibrary
else
if
(
"yellow"
.
Equals
(
color
))
{
CurrLedStatus
=
2
;
sLed
.
Add
(
Light
.
BlueLight
(
dmx
,
index
));
sLed
.
Add
(
Light
.
YellowLight
(
dmx
,
index
));
}
else
if
(
"red"
.
Equals
(
color
))
{
CurrLedStatus
=
2
;
sLed
.
Add
(
Light
.
RedLight
(
dmx
,
index
));
}
else
{
CurrLedStatus
=
0
;
sLed
.
Add
(
Light
.
CloseLight
(
dmx
,
index
));
}
}
SaveLightToMap
(
lightsMap
,
ip
,
sLed
.
ToArray
());
}
module
.
LightOn
(
sLed
.
ToArray
());
Thread
.
Sleep
(
100
);
}
UpdateLightMap
(
lightsMap
);
}
public
static
void
UpdateLightMap
(
Dictionary
<
string
,
List
<
Light
>>
lightsMap
)
{
foreach
(
string
dip
in
lightsMap
.
Keys
)
{
List
<
Light
>
lights
=
lightsMap
[
dip
];
if
(
lights
.
Count
>
0
)
{
LEDManager
.
GetLedModule
(
dip
).
LightOff
(
lights
.
ToArray
());
Thread
.
Sleep
(
50
);
}
}
}
/// <summary>
/// 关闭状态灯
/// </summary>
/// <param name="color"></param>
public
static
void
CloseStatusLights
(
string
color
=
""
)
public
static
void
SaveLightToMap
(
Dictionary
<
string
,
List
<
Light
>>
lightsMap
,
string
ip
,
Light
[]
lightArray
)
{
CurrLedStatus
=
0
;
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
if
(
lightArray
!=
null
&&
lightArray
.
Length
>
0
)
{
foreach
(
int
dmx
in
StatusLedDmx
)
List
<
Light
>
lights
=
new
List
<
Light
>();
if
(
lightsMap
.
ContainsKey
(
ip
))
{
lights
=
lightsMap
[
ip
];
}
lights
.
AddRange
(
lightArray
);
if
(
lightsMap
.
ContainsKey
(
ip
))
{
lightsMap
[
ip
]
=
lights
;
}
else
{
module
.
AllLightOff
(
dmx
);
lightsMap
.
Add
(
ip
,
lights
);
}
}
}
...
...
@@ -205,6 +237,10 @@ namespace SmartShelf.DeviceLibrary
public
static
byte
defaultR
=
0
;
public
static
byte
defaultG
=
50
;
public
static
byte
defaultB
=
0
;
public
static
Light
CloseLight
(
int
dmxId
,
int
index
)
{
return
new
Light
(
dmxId
,
index
,
0
,
0
,
0
,
0
);
}
public
static
Light
DefaultLight
(
int
dmxId
,
int
index
)
{
return
new
Light
(
dmxId
,
index
,
defaultR
,
defaultG
,
defaultB
,
200
);
...
...
DeviceLibrary/manager/BOXManager.cs
查看文件 @
8ebdcd5
此文件的差异被折叠,
点击展开。
DeviceLibrary/manager/BOXManager_Partial.cs
查看文件 @
8ebdcd5
...
...
@@ -71,9 +71,9 @@ namespace SmartShelf.DeviceLibrary
Operation
lineOperation
=
GetLineBoxStatus
();
//获取亮灯的库位
string
posId
=
""
;
foreach
(
string
key
in
Status
ColorMap
.
Keys
)
foreach
(
string
key
in
PosId
ColorMap
.
Keys
)
{
if
(!
String
.
IsNullOrEmpty
(
Status
ColorMap
[
key
]))
if
(!
String
.
IsNullOrEmpty
(
PosId
ColorMap
[
key
]))
{
posId
=
posId
+
key
+
"|"
;
}
...
...
LoadCVSLibrary/CSVAttribute.cs
查看文件 @
8ebdcd5
...
...
@@ -13,6 +13,12 @@ namespace SmartShelf.LoadCSVLibrary
public
CSVAttribute
(
string
fieldName
)
{
FieldName
=
fieldName
;
IsMust
=
true
;
}
public
CSVAttribute
(
string
fieldName
,
bool
ismust
)
{
FieldName
=
fieldName
;
IsMust
=
ismust
;
}
private
string
fieldName
;
...
...
@@ -21,7 +27,9 @@ namespace SmartShelf.LoadCSVLibrary
get
{
return
fieldName
;
}
set
{
fieldName
=
value
;
}
}
/// <summary>
/// 是否必须的
/// </summary>
public
bool
IsMust
{
get
;
set
;
}
}
}
LoadCVSLibrary/CSVReaderBase.cs
查看文件 @
8ebdcd5
...
...
@@ -32,6 +32,21 @@ namespace SmartShelf.LoadCSVLibrary
return
proCsvMap
;
}
public
static
Dictionary
<
string
,
CSVAttribute
>
getAttributeMap
(
Type
type
)
{
Dictionary
<
string
,
CSVAttribute
>
proCsvMap
=
new
Dictionary
<
string
,
CSVAttribute
>();
PropertyInfo
[]
props
=
type
.
GetProperties
();
foreach
(
PropertyInfo
prop
in
props
)
{
CSVAttribute
att
=
(
CSVAttribute
)
prop
.
GetCustomAttribute
(
typeof
(
CSVAttribute
),
false
);
if
(
att
!=
null
)
{
proCsvMap
.
Add
(
att
.
FieldName
,
att
);
}
}
return
proCsvMap
;
}
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
...
...
@@ -124,7 +139,7 @@ namespace SmartShelf.LoadCSVLibrary
}
return
titleIndex
;
}
protected
static
Dictionary
<
string
,
int
>
GetTitleIndex
(
string
lineValue
,
List
<
string
>
cvsTitleList
)
protected
static
Dictionary
<
string
,
int
>
GetTitleIndex
(
string
lineValue
,
List
<
string
>
cvsTitleList
,
Dictionary
<
string
,
CSVAttribute
>
csvAttMap
)
{
Dictionary
<
string
,
int
>
titleIndex
=
new
Dictionary
<
string
,
int
>();
var
array
=
lineValue
.
Split
(
','
);
...
...
@@ -143,11 +158,18 @@ namespace SmartShelf.LoadCSVLibrary
{
if
(!
titleIndex
.
ContainsKey
(
str
))
{
if
(
csvAttMap
.
ContainsKey
(
str
))
{
if
(
csvAttMap
[
str
].
IsMust
)
{
LOGGER
.
Error
(
"未找到必须列:"
+
str
+
",加载数据失败!"
);
throw
new
CVSFieldNotMatchingExection
(
"未找到必须列:"
+
str
+
",加载数据失败!"
);
}
}
}
}
}
return
titleIndex
;
}
}
...
...
LoadCVSLibrary/position/BoxPosition.cs
查看文件 @
8ebdcd5
...
...
@@ -25,6 +25,33 @@ namespace SmartShelf.LoadCSVLibrary
[
CSVAttribute
(
"设备IP"
)]
public
string
DeviceIp
{
get
;
set
;
}
[
CSVAttribute
(
"指示灯区域ID"
,
false
)]
public
string
StatusLedDmxId
{
get
;
set
;
}
private
int
sledDmxId
=
-
2
;
public
int
GetStatusLedDmxId
()
{
if
(
sledDmxId
<
-
1
)
{
if
(
String
.
IsNullOrEmpty
(
StatusLedDmxId
))
{
sledDmxId
=
-
1
;
}
else
{
try
{
sledDmxId
=
Convert
.
ToInt32
(
StatusLedDmxId
);
}
catch
(
Exception
ex
)
{
}
}
}
return
sledDmxId
;
}
private
List
<
int
>
LedList
=
null
;
public
List
<
int
>
GetLedList
()
...
...
LoadCVSLibrary/position/CSVPositionReader.cs
查看文件 @
8ebdcd5
...
...
@@ -56,6 +56,7 @@ namespace SmartShelf.LoadCSVLibrary
Type
type
=
typeof
(
T
);
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
Dictionary
<
string
,
CSVAttribute
>
csvAttMap
=
getAttributeMap
(
typeof
(
T
));
if
(
proTitleMap
.
Count
<=
4
)
{
LOGGER
.
Error
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
...
...
@@ -73,7 +74,7 @@ namespace SmartShelf.LoadCSVLibrary
var
array
=
line
.
Split
(
Spilt_Char
);
if
(
index
==
0
)
{
titleIndex
=
GetTitleIndex
(
line
,
cvsTitleList
);
titleIndex
=
GetTitleIndex
(
line
,
cvsTitleList
,
csvAttMap
);
}
else
{
...
...
@@ -93,10 +94,12 @@ namespace SmartShelf.LoadCSVLibrary
string
PositionNum
=
""
;
foreach
(
string
key
in
cvsTitleList
)
{
int
titIndex
=
titleIndex
[
key
];
string
value
=
array
[
titIndex
];
string
proName
=
propertyList
[
listIndex
];
PropertyInfo
prop
=
props
.
First
(
c
=>
c
.
Name
==
proName
);
//获取同名属性
if
(
titleIndex
.
ContainsKey
(
key
))
{
int
titIndex
=
titleIndex
[
key
];
string
value
=
array
[
titIndex
];
if
(
prop
!=
null
&&
value
!=
""
)
{
//如果属性存在
prop
.
SetValue
(
bllIns
,
Convert
.
ChangeType
(
value
,
prop
.
PropertyType
),
null
);
//赋值****在这里需要考虑类型问题
...
...
@@ -105,6 +108,18 @@ namespace SmartShelf.LoadCSVLibrary
{
PositionNum
=
value
;
}
}
else
{
if
(
prop
.
PropertyType
.
Equals
(
typeof
(
int
)))
{
prop
.
SetValue
(
bllIns
,
Convert
.
ChangeType
(
0
,
prop
.
PropertyType
),
null
);
//赋值****在这里需要考虑类型问题
}
else
{
prop
.
SetValue
(
bllIns
,
Convert
.
ChangeType
(
""
,
prop
.
PropertyType
),
null
);
//赋值****在这里需要考虑类型问题
}
}
listIndex
++;
}
result
.
Add
(
PositionNum
,
(
T
)
bllIns
);
...
...
@@ -155,6 +170,7 @@ namespace SmartShelf.LoadCSVLibrary
Type
type
=
typeof
(
T
);
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
Dictionary
<
string
,
CSVAttribute
>
csvAttMap
=
getAttributeMap
(
typeof
(
T
));
if
(
proTitleMap
.
Count
<=
4
)
{
LOGGER
.
Error
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
...
...
@@ -172,7 +188,7 @@ namespace SmartShelf.LoadCSVLibrary
var
array
=
line
.
Split
(
','
);
if
(
index
==
0
)
{
titleIndex
=
GetTitleIndex
(
line
,
cvsTitleList
);
titleIndex
=
GetTitleIndex
(
line
,
cvsTitleList
,
csvAttMap
);
}
else
{
...
...
SmartShelf/FrmStore.cs
查看文件 @
8ebdcd5
...
...
@@ -227,17 +227,17 @@ namespace SmartShelf
private
void
btnOpenSLed_Click
(
object
sender
,
EventArgs
e
)
{
LED
Manager
.
OpenStatusLights
(
"green"
);
BOX
Manager
.
OpenStatusLights
(
"green"
);
}
private
void
btnCloseSLed_Click
(
object
sender
,
EventArgs
e
)
{
LED
Manager
.
CloseStatusLights
();
BOX
Manager
.
CloseStatusLights
();
}
private
void
button5_Click
(
object
sender
,
EventArgs
e
)
{
LED
Manager
.
OpenStatusLights
(
"yellow"
);
BOX
Manager
.
OpenStatusLights
(
"yellow"
);
}
private
void
btOAll_Click
(
object
sender
,
EventArgs
e
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论