Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
SmartShelf
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 5c320d1a
由
LN
编写于
2019-10-22 10:27:02 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
代码整合
1 个父辈
6d14c4fc
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
279 行增加
和
115 行删除
Common/Setting_Init.cs
DeviceLibrary/Box/BOXManager.cs
DeviceLibrary/DeviceLibrary/led/BaseLEDManager.cs
DeviceLibrary/DeviceLibrary/led/LEDColorModule.cs
SmartShelf/App.config
SmartShelf/FrmStore.cs
Common/Setting_Init.cs
查看文件 @
5c320d1
...
@@ -33,6 +33,11 @@ namespace SmartShelf.Common
...
@@ -33,6 +33,11 @@ namespace SmartShelf.Common
/// <summary>
/// <summary>
/// 料架灯类型,0=单色灯料架,1=三色灯料架
/// 料架灯类型,0=单色灯料架,1=三色灯料架
/// </summary>
/// </summary>
public
static
string
DeviceLedType
=
"DeviceLedType"
;
public
static
string
DeviceLedType
=
"DeviceLedType"
;
public
static
string
Status_Green_Lights
=
"Status_Green_Lights"
;
public
static
string
Status_Red_Lights
=
"Status_Red_Lights"
;
public
static
string
Status_Yellow_Lights
=
"Status_Yellow_Lights"
;
}
}
}
}
DeviceLibrary/Box/BOXManager.cs
查看文件 @
5c320d1
...
@@ -21,10 +21,10 @@ namespace SmartShelf.DeviceLibrary
...
@@ -21,10 +21,10 @@ namespace SmartShelf.DeviceLibrary
public
class
BOXManager
public
class
BOXManager
{
{
private
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
private
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
static
string
BoxName
=
"单色灯料架"
;
public
static
BOX_Config
Config
=
null
;
public
static
BOX_Config
Config
=
null
;
public
static
string
CID
=
""
;
public
static
string
CID
=
""
;
public
static
string
BoxName
=
""
;
private
static
System
.
Timers
.
Timer
timersTimer
;
private
static
System
.
Timers
.
Timer
timersTimer
;
private
static
System
.
Timers
.
Timer
serverConTimer
=
new
System
.
Timers
.
Timer
();
private
static
System
.
Timers
.
Timer
serverConTimer
=
new
System
.
Timers
.
Timer
();
private
static
bool
isInit
=
false
;
private
static
bool
isInit
=
false
;
...
@@ -36,11 +36,15 @@ namespace SmartShelf.DeviceLibrary
...
@@ -36,11 +36,15 @@ namespace SmartShelf.DeviceLibrary
/// </summary>
/// </summary>
public
static
Dictionary
<
string
,
int
>
StatusMap
=
new
Dictionary
<
string
,
int
>();
public
static
Dictionary
<
string
,
int
>
StatusMap
=
new
Dictionary
<
string
,
int
>();
public
static
bool
IsRun
=
false
;
public
static
bool
IsRun
=
false
;
/// <summary>
/// 灯闪烁列表,库位号 value为颜色
/// </summary>
public
static
Dictionary
<
string
,
string
>
TwinkleMap
=
new
Dictionary
<
string
,
string
>();
public
static
bool
StartInit
()
public
static
bool
StartInit
()
{
{
try
try
{
{
BoxCount
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
BoxCount
);
BoxCount
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
BoxCount
);
string
appPath
=
Application
.
StartupPath
;
string
appPath
=
Application
.
StartupPath
;
//加载位置
//加载位置
...
@@ -66,6 +70,7 @@ namespace SmartShelf.DeviceLibrary
...
@@ -66,6 +70,7 @@ namespace SmartShelf.DeviceLibrary
}
}
LEDManager
.
deviceMap
=
new
Dictionary
<
string
,
LEDBaseModule
>();
LEDManager
.
deviceMap
=
new
Dictionary
<
string
,
LEDBaseModule
>();
StatusMap
=
new
Dictionary
<
string
,
int
>();
StatusMap
=
new
Dictionary
<
string
,
int
>();
TwinkleMap
=
new
Dictionary
<
string
,
string
>();
foreach
(
BoxPosition
box
in
PositionMap
.
Values
)
foreach
(
BoxPosition
box
in
PositionMap
.
Values
)
{
{
if
(!
LEDManager
.
deviceMap
.
ContainsKey
(
box
.
DeviceIp
))
if
(!
LEDManager
.
deviceMap
.
ContainsKey
(
box
.
DeviceIp
))
...
@@ -77,10 +82,15 @@ namespace SmartShelf.DeviceLibrary
...
@@ -77,10 +82,15 @@ namespace SmartShelf.DeviceLibrary
}
}
StatusMap
.
Add
(
box
.
PositionNum
,
-
1
);
StatusMap
.
Add
(
box
.
PositionNum
,
-
1
);
TwinkleMap
.
Add
(
box
.
PositionNum
,
""
);
}
}
CID
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
CID
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
BoxName
=
(
" 料架_"
+
CID
+
" "
).
ToUpper
();
BoxName
=
(
" 单色灯料架_"
+
CID
+
" "
).
ToUpper
();
if
(
LEDManager
.
DeviceLedType
.
Equals
(
1
))
{
BoxName
=
(
" 三色灯料架_"
+
CID
+
" "
).
ToUpper
();
}
string
filePath
=
appPath
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_ConfigPath
);
string
filePath
=
appPath
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_ConfigPath
);
Config
=
(
BOX_Config
)
CSVConfigReader
.
LoadConfig
(
1
,
CID
,
StoreType
.
RC_PLC_SM
,
filePath
);
Config
=
(
BOX_Config
)
CSVConfigReader
.
LoadConfig
(
1
,
CID
,
StoreType
.
RC_PLC_SM
,
filePath
);
if
(
Config
==
null
)
if
(
Config
==
null
)
...
@@ -88,13 +98,13 @@ namespace SmartShelf.DeviceLibrary
...
@@ -88,13 +98,13 @@ namespace SmartShelf.DeviceLibrary
return
false
;
return
false
;
}
}
LogUtil
.
info
(
LOGGER
,
"加载料架
完成!"
);
LogUtil
.
info
(
BoxName
+
"加载
完成!"
);
Init
();
Init
();
return
true
;
return
true
;
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
"加载料架
配置出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
BoxName
+
"加载
配置出错:"
+
ex
.
ToString
());
}
return
false
;
}
return
false
;
}
}
...
@@ -107,16 +117,16 @@ namespace SmartShelf.DeviceLibrary
...
@@ -107,16 +117,16 @@ namespace SmartShelf.DeviceLibrary
{
{
serverConTimer
=
new
System
.
Timers
.
Timer
();
serverConTimer
=
new
System
.
Timers
.
Timer
();
serverConTimer
.
Enabled
=
false
;
serverConTimer
.
Enabled
=
false
;
serverConTimer
.
Interval
=
6
00
;
serverConTimer
.
Interval
=
3
00
;
serverConTimer
.
Elapsed
+=
server_connect_timer_Tick
;
serverConTimer
.
Elapsed
+=
server_connect_timer_Tick
;
serverConTimer
.
AutoReset
=
true
;
serverConTimer
.
AutoReset
=
true
;
timersTimer
=
new
System
.
Timers
.
Timer
();
timersTimer
=
new
System
.
Timers
.
Timer
();
timersTimer
.
Enabled
=
false
;
timersTimer
.
Enabled
=
false
;
timersTimer
.
Interval
=
6
00
;
timersTimer
.
Interval
=
2
00
;
timersTimer
.
Elapsed
+=
timersTimer_Elapsed
;
timersTimer
.
Elapsed
+=
timersTimer_Elapsed
;
timersTimer
.
AutoReset
=
true
;
timersTimer
.
AutoReset
=
true
;
isInit
=
true
;
isInit
=
true
;
}
}
}
}
...
@@ -126,7 +136,7 @@ namespace SmartShelf.DeviceLibrary
...
@@ -126,7 +136,7 @@ namespace SmartShelf.DeviceLibrary
timersTimer
.
Enabled
=
true
;
timersTimer
.
Enabled
=
true
;
serverConTimer
.
Enabled
=
true
;
serverConTimer
.
Enabled
=
true
;
IsRun
=
true
;
IsRun
=
true
;
LEDManager
.
OpenS
GreenLed
(
);
LEDManager
.
OpenS
tatusLights
(
"green"
);
return
true
;
return
true
;
}
}
...
@@ -147,7 +157,7 @@ namespace SmartShelf.DeviceLibrary
...
@@ -147,7 +157,7 @@ namespace SmartShelf.DeviceLibrary
{
{
led
.
AllLightOff
();
led
.
AllLightOff
();
}
}
LEDManager
.
CloseS
Led
();
LEDManager
.
CloseS
tatusLights
();
IsRun
=
false
;
IsRun
=
false
;
LogUtil
.
info
(
LOGGER
,
BoxName
+
"停止运行,时间"
+
DateTime
.
Now
.
ToShortTimeString
()
+
"!"
);
LogUtil
.
info
(
LOGGER
,
BoxName
+
"停止运行,时间"
+
DateTime
.
Now
.
ToShortTimeString
()
+
"!"
);
}
}
...
@@ -169,16 +179,18 @@ namespace SmartShelf.DeviceLibrary
...
@@ -169,16 +179,18 @@ namespace SmartShelf.DeviceLibrary
{
{
if
(!
LEDManager
.
CurrLedStatus
.
Equals
(
2
))
if
(!
LEDManager
.
CurrLedStatus
.
Equals
(
2
))
{
{
LEDManager
.
OpenS
YellowLed
(
);
LEDManager
.
OpenS
tatusLights
(
"green"
);
}
}
}
}
else
else
{
{
if
(!
LEDManager
.
CurrLedStatus
.
Equals
(
1
))
if
(!
LEDManager
.
CurrLedStatus
.
Equals
(
1
))
{
{
LEDManager
.
OpenS
GreenLed
(
);
LEDManager
.
OpenS
tatusLights
(
"yellow"
);
}
}
}
}
TwinkLight
();
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -205,8 +217,7 @@ namespace SmartShelf.DeviceLibrary
...
@@ -205,8 +217,7 @@ namespace SmartShelf.DeviceLibrary
LogUtil
.
error
(
"server_connect_timer_Tick 出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"server_connect_timer_Tick 出错:"
+
ex
.
ToString
());
}
}
isInProcess
=
false
;
isInProcess
=
false
;
}
}
private
static
string
LastCardResult
=
""
;
private
static
string
LastCardValue
=
""
;
private
static
string
LastCardValue
=
""
;
public
static
string
StrMsg
=
""
;
public
static
string
StrMsg
=
""
;
...
@@ -227,8 +238,7 @@ namespace SmartShelf.DeviceLibrary
...
@@ -227,8 +238,7 @@ namespace SmartShelf.DeviceLibrary
}
}
if
(
String
.
IsNullOrEmpty
(
posId
).
Equals
(
false
))
if
(
String
.
IsNullOrEmpty
(
posId
).
Equals
(
false
))
{
{
lineOperation
.
data
.
Add
(
ParamDefine
.
posOpened
,
posId
);
lineOperation
.
data
.
Add
(
ParamDefine
.
posOpened
,
posId
);
LastCardResult
=
""
;
}
}
foreach
(
string
str
in
lineOperation
.
data
.
Keys
)
foreach
(
string
str
in
lineOperation
.
data
.
Keys
)
...
@@ -315,30 +325,121 @@ namespace SmartShelf.DeviceLibrary
...
@@ -315,30 +325,121 @@ namespace SmartShelf.DeviceLibrary
}
}
}
}
}
}
public
static
void
ProcessOpenDoor
(
string
posids
,
string
proMsg
=
"Revice "
)
public
static
void
ProcessOpenDoor
(
string
posids
,
string
proMsg
=
"Revice "
)
{
{
LogUtil
.
info
(
BoxName
+
proMsg
+
" open命令:"
+
posids
);
LogUtil
.
info
(
BoxName
+
proMsg
+
" open命令:"
+
posids
);
string
[]
posArray
=
posids
.
Split
(
'|'
);
string
[]
posArray
=
posids
.
Split
(
'|'
);
foreach
(
string
posid
in
posArray
)
foreach
(
string
posStr
in
posArray
)
{
{
string
posName
=
posid
;
//是否需要闪烁
if
(
posid
.
Contains
(
"="
))
bool
needTwinkle
=
false
;
string
posid
=
posStr
;
string
color
=
"Green"
;
if
(
posStr
.
Contains
(
"="
))
{
{
posName
=
posid
.
Split
(
'='
)[
0
];
string
[]
posInfos
=
posStr
.
Split
(
'='
);
posid
=
posInfos
[
0
];
color
=
posInfos
[
1
];
if
(
posInfos
.
Length
>
2
&&
LEDManager
.
DeviceLedType
.
Equals
(
2
))
{
LogUtil
.
info
(
"库位【"
+
posid
+
"】需要开启闪烁"
+
color
);
needTwinkle
=
true
;
}
}
}
if
(
PositionMap
.
ContainsKey
(
posName
))
color
=
color
.
ToLower
();
if
(
PositionMap
.
ContainsKey
(
posid
))
{
{
BoxPosition
position
=
PositionMap
[
posName
];
LEDManager
.
GetLedModule
(
position
.
DeviceIp
).
LightOn
(
Light
.
GetLights
(
position
.
DmxId
,
position
.
GetLedList
()));
StatusMap
[
posName
]
=
1
;
BoxPosition
position
=
PositionMap
[
posid
];
Light
[]
lights
=
Light
.
GetLights
(
position
.
DmxId
,
color
,
position
.
GetLedList
().
ToArray
());
LEDManager
.
GetLedModule
(
position
.
DeviceIp
).
LightOn
(
lights
);
StatusMap
[
posid
]
=
1
;
if
(
needTwinkle
)
{
//需要闪烁
TwinkleMap
[
posid
]
=
color
;
}
else
{
TwinkleMap
[
posid
]
=
""
;
}
}
}
else
else
{
{
LogUtil
.
error
(
BoxName
+
"打开门锁失败,未找到库位号:"
+
posName
);
if
(
posid
.
ToLower
().
Equals
(
"statuslight"
))
{
LogUtil
.
info
(
"状态灯指令:"
+
posid
+
"="
+
color
);
}
else
{
LogUtil
.
error
(
BoxName
+
"打开门锁失败,未找到库位号:"
+
posid
);
}
}
}
}
}
}
}
private
static
bool
TwinkleLightOpen
=
false
;
public
static
void
TwinkLight
()
{
if
(!
LEDManager
.
DeviceLedType
.
Equals
(
1
))
{
return
;
}
//只有三色灯才有闪烁功能
TwinkleLightOpen
=
!
TwinkleLightOpen
;
bool
hasTwinkleLight
=
false
;
var
keys
=
TwinkleMap
.
Keys
.
ToList
();
foreach
(
string
posid
in
keys
)
{
string
color
=
TwinkleMap
[
posid
];
if
(
color
!=
null
&&
!
color
.
Equals
(
""
))
{
if
(
PositionMap
.
ContainsKey
(
posid
))
{
BoxPosition
position
=
PositionMap
[
posid
];
if
(
StatusMap
[
posid
]
==
0
)
{
LogUtil
.
info
(
"库位【"
+
posid
+
"】灯已灭,停止闪烁"
+
color
);
TwinkleMap
[
posid
]
=
""
;
LEDManager
.
GetLedModule
(
position
.
DeviceIp
).
LightOff
(
position
.
DmxId
,
position
.
GetLedList
().
ToArray
());
}
else
{
hasTwinkleLight
=
true
;
if
(
TwinkleLightOpen
)
{
Light
[]
lights
=
Light
.
GetLights
(
position
.
DmxId
,
color
,
position
.
GetLedList
().
ToArray
());
//LogUtil.info("库位【" + posid + "】闪烁开灯" + color);
LEDManager
.
GetLedModule
(
position
.
DeviceIp
).
LightOn
(
lights
);
}
else
{
//LogUtil.info("库位【" + posid + "】闪烁灭灯" + color);
LEDManager
.
GetLedModule
(
position
.
DeviceIp
).
LightOff
(
position
.
DmxId
,
position
.
GetLedList
().
ToArray
());
}
}
}
else
{
LogUtil
.
info
(
"库位【"
+
posid
+
"】未找到,停止闪烁"
);
TwinkleMap
[
posid
]
=
""
;
}
}
}
if
(
hasTwinkleLight
)
{
LEDManager
.
OpenStatusLights
(
"red"
);
}
else
{
LEDManager
.
OpenStatusLights
(
"red"
);
}
}
public
static
void
ProcessCloseDoor
(
string
posids
,
string
proMsg
=
"Revice "
)
public
static
void
ProcessCloseDoor
(
string
posids
,
string
proMsg
=
"Revice "
)
{
{
LogUtil
.
info
(
BoxName
+
proMsg
+
" close命令:"
+
posids
);
LogUtil
.
info
(
BoxName
+
proMsg
+
" close命令:"
+
posids
);
...
@@ -368,6 +469,8 @@ namespace SmartShelf.DeviceLibrary
...
@@ -368,6 +469,8 @@ namespace SmartShelf.DeviceLibrary
#
endregion
#
endregion
}
}
}
}
DeviceLibrary/DeviceLibrary/led/BaseLEDManager.cs
查看文件 @
5c320d1
...
@@ -30,77 +30,146 @@ namespace SmartShelf.DeviceLibrary
...
@@ -30,77 +30,146 @@ namespace SmartShelf.DeviceLibrary
}
}
return
led
;
return
led
;
}
}
/// <summary>
/// 1=绿灯,2=黄灯
/// </summary>
public
static
int
CurrLedStatus
=
-
1
;
public
static
int
CurrLedStatus
=
-
1
;
private
static
int
StatusLedDmx
=
3
;
private
static
int
StatusLedDmx
=
3
;
public
static
void
OpenSGreenLed
()
/// <summary>
/// 打开状态灯
/// </summary>
public
static
void
OpenStatusLights
(
string
color
=
"green"
)
{
{
if
(
"green"
==
color
)
{
CurrLedStatus
=
1
;
}
else
if
(
"yellow"
==
color
)
{
CurrLedStatus
=
2
;
}
if
(
DeviceLedType
.
Equals
(
1
))
if
(
DeviceLedType
.
Equals
(
1
))
{
{
if
(
string
.
IsNullOrEmpty
(
color
))
{
return
;
}
var
lights
=
GetStatusLights
(
color
,
out
string
ip
);
if
(!
string
.
IsNullOrEmpty
(
ip
))
{
GetLedModule
(
ip
).
LightOn
(
lights
.
ToArray
());
}
}
}
else
else
{
{
CloseS
Led
(
);
CloseS
tatusLights
(
""
);
CurrLedStatus
=
1
;
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
{
{
if
(
module
is
LEDSingleModule
)
if
(
module
is
LEDSingleModule
)
{
{
List
<
int
>
list
=
new
List
<
int
>();
List
<
int
>
list
=
new
List
<
int
>();
for
(
int
i
=
2
;
i
<
LEDSingleModule
.
LIGHT_COUNT_PER_DMX
;
i
+=
3
)
if
(
"green"
==
color
)
{
{
list
.
Add
(
i
);
for
(
int
i
=
2
;
i
<
LEDSingleModule
.
LIGHT_COUNT_PER_DMX
;
i
+=
3
)
{
list
.
Add
(
i
);
}
}
else
if
(
"yellow"
==
color
)
{
for
(
int
i
=
2
;
i
<
LEDSingleModule
.
LIGHT_COUNT_PER_DMX
;
i
+=
3
)
{
list
.
Add
(
i
-
2
);
list
.
Add
(
i
);
}
}
}
module
.
OnlyLightOn
(
Light
.
GetLights
(
StatusLedDmx
,
list
,
200
));
module
.
OnlyLightOn
(
Light
.
GetLights
(
StatusLedDmx
,
list
,
200
));
}
}
}
}
}
}
}
}
public
static
void
OpenSYellowLed
()
/// <summary>
/// 关闭状态灯
/// </summary>
/// <param name="color"></param>
public
static
void
CloseStatusLights
(
string
color
=
""
)
{
{
if
(
DeviceLedType
.
Equals
(
1
))
if
(
DeviceLedType
.
Equals
(
1
))
{
{
if
(
string
.
IsNullOrEmpty
(
color
))
{
return
;
}
var
lights
=
GetStatusLights
(
color
,
out
string
ip
);
var
indexArr
=
from
o
in
lights
select
o
.
index
;
if
(!
string
.
IsNullOrEmpty
(
ip
))
{
LEDManager
.
GetLedModule
(
ip
).
LightOff
(-
1
,
indexArr
.
ToArray
());
}
}
}
else
else
{
{
CloseSLed
();
CurrLedStatus
=
0
;
CurrLedStatus
=
2
;
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
{
{
if
(
module
is
LEDSingleModule
)
if
(
module
is
LEDSingleModule
)
{
{
List
<
int
>
list
=
new
List
<
int
>();
module
.
AllLightOff
(
StatusLedDmx
);
for
(
int
i
=
2
;
i
<
LEDSingleModule
.
LIGHT_COUNT_PER_DMX
;
i
+=
3
)
{
list
.
Add
(
i
-
2
);
list
.
Add
(
i
);
}
module
.
OnlyLightOn
(
Light
.
GetLights
(
StatusLedDmx
,
list
,
200
));
}
}
}
}
}
}
}
}
public
static
void
CloseSLed
()
/// <summary>
/// 获取状态灯配置(192.168.100.100:1,3,23)
/// </summary>
/// <param name="color"></param>
/// <param name="ip"></param>
/// <returns></returns>
private
static
List
<
Light
>
GetStatusLights
(
string
color
,
out
string
ip
)
{
{
if
(
DeviceLedType
.
Equals
(
1
))
List
<
Light
>
lights
=
new
List
<
Light
>();
string
lightStrs
=
""
;
color
=
color
.
ToLower
();
if
(
"green"
==
color
)
{
{
lightStrs
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Status_Green_Lights
);
}
}
else
else
if
(
"yellow"
==
color
)
{
{
CurrLedStatus
=
0
;
lightStrs
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Status_Yellow_Lights
);
foreach
(
LEDBaseModule
module
in
deviceMap
.
Values
)
}
else
if
(
"red"
==
color
)
{
lightStrs
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Status_Red_Lights
);
}
else
if
(
String
.
IsNullOrEmpty
(
color
))
{
lightStrs
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Status_Green_Lights
)+
","
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Status_Yellow_Lights
)
+
","
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Status_Red_Lights
)
;
}
ip
=
""
;
if
(!
String
.
IsNullOrEmpty
(
lightStrs
))
{
string
[]
infos
=
lightStrs
.
Split
(
':'
);
ip
=
infos
[
0
];
string
[]
lightArr
=
infos
[
1
].
Split
(
','
);
foreach
(
var
indexStr
in
lightArr
)
{
{
if
(
module
is
LEDSingleModule
)
int
.
TryParse
(
indexStr
,
out
int
index
);
{
Light
light
=
Light
.
GetLight
(-
1
,
index
,
color
,
255
);
module
.
AllLightOff
(
StatusLedDmx
);
lights
.
Add
(
light
);
}
}
}
}
}
return
lights
;
}
}
}
}
public
abstract
class
LEDBaseModule
public
abstract
class
LEDBaseModule
...
@@ -172,107 +241,91 @@ namespace SmartShelf.DeviceLibrary
...
@@ -172,107 +241,91 @@ namespace SmartShelf.DeviceLibrary
public
class
Light
public
class
Light
{
{
public
static
Light
StoreLight
(
int
index
)
public
static
Light
DefaultLight
(
int
dmxId
,
int
index
)
{
{
return
new
Light
(
index
,
50
,
0
,
0
);
return
new
Light
(
dmxId
,
index
,
50
,
0
,
0
,
20
0
);
}
}
public
static
Light
GetLight
(
int
index
,
string
color
)
public
static
Light
GetLight
(
int
dmxId
,
int
index
,
string
color
=
"green"
)
{
{
return
GetLight
(
index
,
color
,
50
);
return
GetLight
(
dmxId
,
index
,
color
,
50
);
}
}
public
static
Light
[]
GetLights
(
string
color
,
params
int
[]
indexes
)
public
static
Light
[]
GetLights
(
int
dmxId
,
string
color
,
params
int
[]
indexes
)
{
{
List
<
Light
>
lights
=
new
List
<
Light
>();
List
<
Light
>
lights
=
new
List
<
Light
>();
foreach
(
int
index
in
indexes
)
foreach
(
int
index
in
indexes
)
{
{
lights
.
Add
(
GetLight
(
index
,
color
));
lights
.
Add
(
GetLight
(
dmxId
,
index
,
color
));
}
}
return
lights
.
ToArray
();
return
lights
.
ToArray
();
}
}
public
static
Light
GetLight
(
int
index
,
string
color
,
byte
bright
)
public
static
Light
GetLight
(
int
dmxId
,
int
index
,
string
color
,
byte
bright
)
{
{
color
=
color
.
ToLower
();
color
=
color
.
ToLower
();
switch
(
color
)
switch
(
color
)
{
{
case
"green"
:
case
"green"
:
return
GreenLight
(
index
,
bright
);
return
GreenLight
(
dmxId
,
index
,
bright
);
case
"red"
:
case
"red"
:
return
RedLight
(
index
,
bright
);
return
RedLight
(
dmxId
,
index
,
bright
);
case
"yellow"
:
case
"yellow"
:
return
YellowLight
(
index
,
bright
);
return
YellowLight
(
dmxId
,
index
,
bright
);
case
"blue"
:
case
"blue"
:
return
BlueLight
(
index
,
bright
);
return
BlueLight
(
dmxId
,
index
,
bright
);
}
}
return
StoreLight
(
index
);
return
DefaultLight
(
dmxId
,
index
);
}
public
static
Light
RedLight
(
int
index
,
byte
bright
)
{
return
new
Light
(
index
,
bright
,
0
,
0
);
}
public
static
Light
RedLight
(
int
index
)
{
return
RedLight
(
index
,
50
);
}
public
static
Light
YellowLight
(
int
index
)
{
return
YellowLight
(
index
,
50
);
}
}
public
static
Light
YellowLight
(
int
index
,
byte
bright
)
public
static
Light
RedLight
(
int
dmxId
,
int
index
,
byte
bright
=
50
)
{
{
return
new
Light
(
index
,
bright
,
bright
,
0
);
return
new
Light
(
dmxId
,
index
,
bright
,
0
,
0
);
}
}
public
static
Light
BlueLight
(
int
index
)
public
static
Light
YellowLight
(
int
dmxId
,
int
index
,
byte
bright
=
50
)
{
return
BlueLight
(
index
,
50
);
}
public
static
Light
BlueLight
(
int
index
,
byte
bright
)
{
{
return
new
Light
(
index
,
0
,
0
,
bright
);
return
new
Light
(
dmxId
,
index
,
bright
,
bright
,
0
);
}
}
public
static
Light
GreenLight
(
int
index
)
public
static
Light
BlueLight
(
int
dmxId
,
int
index
,
byte
bright
=
50
)
{
{
return
new
Light
(
index
,
0
,
50
,
0
);
return
new
Light
(
dmxId
,
index
,
0
,
0
,
bright
);
}
}
public
static
Light
GreenLight
(
int
index
,
byte
bright
)
public
static
Light
GreenLight
(
int
dmxId
,
int
index
,
byte
bright
=
50
)
{
{
return
new
Light
(
index
,
0
,
bright
,
0
);
return
new
Light
(
dmxId
,
index
,
0
,
bright
,
0
);
}
}
public
static
Light
CyanLight
(
int
index
)
public
static
Light
CyanLight
(
int
dmxId
,
int
index
)
{
{
return
new
Light
(
index
,
0
,
255
,
255
);
return
new
Light
(
dmxId
,
index
,
0
,
255
,
255
);
}
}
public
static
Light
ChocolateLight
(
int
index
)
public
static
Light
ChocolateLight
(
int
dmxId
,
int
index
)
{
{
return
new
Light
(
index
,
210
,
105
,
30
);
return
new
Light
(
dmxId
,
index
,
210
,
105
,
30
);
}
}
public
Light
(
int
index
,
byte
Red
,
byte
Green
,
byte
Blue
)
public
Light
(
int
dmxId
,
int
index
,
byte
Red
,
byte
Green
,
byte
Blue
,
byte
lightValue
=
200
)
{
{
this
.
dmx
=
dmxId
;
this
.
index
=
index
;
this
.
index
=
index
;
this
.
Red
=
Red
;
this
.
Red
=
Red
;
this
.
Green
=
Green
;
this
.
Green
=
Green
;
this
.
Blue
=
Blue
;
this
.
Blue
=
Blue
;
this
.
lightValue
=
lightValue
;
}
}
public
int
index
{
get
;
set
;
}
public
int
index
{
get
;
set
;
}
public
byte
Red
{
get
;
set
;
}
public
byte
Red
{
get
;
set
;
}
public
byte
Green
{
get
;
set
;
}
public
byte
Green
{
get
;
set
;
}
public
byte
Blue
{
get
;
set
;
}
public
byte
Blue
{
get
;
set
;
}
/// <summary>
///
//
<summary>
/// 单色灯
///
//
单色灯
/// </summary>
///
//
</summary>
public
static
Light
DefaultLight
(
int
dmx
,
int
index
)
//
public static Light DefaultLight(int dmx, int index)
{
//
{
return
new
Light
(
dmx
,
index
,
LEDManager
.
DefaultLight
);
//
return new Light(dmx, index, LEDManager.DefaultLight);
}
//
}
/// <summary>
/// <summary>
/// 单色灯
/// 单色灯
/// </summary>
/// </summary>
...
@@ -298,8 +351,8 @@ namespace SmartShelf.DeviceLibrary
...
@@ -298,8 +351,8 @@ namespace SmartShelf.DeviceLibrary
this
.
index
=
index
;
this
.
index
=
index
;
this
.
dmx
=
dmx
;
this
.
dmx
=
dmx
;
this
.
lightValue
=
lightValue
;
this
.
lightValue
=
lightValue
;
}
}
public
int
dmx
{
get
;
set
;
}
public
int
dmx
=
-
1
;
public
byte
lightValue
{
get
;
set
;
}
public
byte
lightValue
=
LEDManager
.
DefaultLight
;
}
}
}
}
DeviceLibrary/DeviceLibrary/led/LEDColorModule.cs
查看文件 @
5c320d1
...
@@ -45,7 +45,7 @@ namespace SmartShelf.DeviceLibrary
...
@@ -45,7 +45,7 @@ namespace SmartShelf.DeviceLibrary
public
override
void
AllLightOn
(
int
dmx
=
-
1
)
public
override
void
AllLightOn
(
int
dmx
=
-
1
)
{
{
AllLightOn
(
Light
.
StoreLight
(
1
));
AllLightOn
(
Light
.
DefaultLight
(
dmx
,
1
));
}
}
public
override
void
AllLightOn
(
Light
light
)
public
override
void
AllLightOn
(
Light
light
)
...
...
SmartShelf/App.config
查看文件 @
5c320d1
...
@@ -21,6 +21,9 @@
...
@@ -21,6 +21,9 @@
<
add
key
=
"DIMS"
value
=
"300"
/>
<
add
key
=
"DIMS"
value
=
"300"
/>
<
add
key
=
"DOMS"
value
=
"300"
/>
<
add
key
=
"DOMS"
value
=
"300"
/>
<
add
key
=
"BoxCount"
value
=
"2"
/>
<
add
key
=
"BoxCount"
value
=
"2"
/>
<
add
key
=
"Status_Green_Lights"
value
=
"192.168.1.151:129,130,131,132,133,134,135,136,137,138"
/>
<
add
key
=
"Status_Yellow_Lights"
value
=
"192.168.1.151:140,141,142,143,144,145,146,147,148,149"
/>
<
add
key
=
"Status_Red_Lights"
value
=
"192.168.1.151:150,151,152,153,154,155,156,157,158,159,160"
/>
</
appSettings
>
</
appSettings
>
<
log4net
>
<
log4net
>
<
appender
name
=
"RollingLogFileAppender"
type
=
"log4net.Appender.RollingFileAppender"
>
<
appender
name
=
"RollingLogFileAppender"
type
=
"log4net.Appender.RollingFileAppender"
>
...
...
SmartShelf/FrmStore.cs
查看文件 @
5c320d1
...
@@ -227,17 +227,17 @@ namespace SmartShelf
...
@@ -227,17 +227,17 @@ namespace SmartShelf
private
void
btnOpenSLed_Click
(
object
sender
,
EventArgs
e
)
private
void
btnOpenSLed_Click
(
object
sender
,
EventArgs
e
)
{
{
LEDManager
.
OpenS
GreenLed
(
);
LEDManager
.
OpenS
tatusLights
(
"green"
);
}
}
private
void
btnCloseSLed_Click
(
object
sender
,
EventArgs
e
)
private
void
btnCloseSLed_Click
(
object
sender
,
EventArgs
e
)
{
{
LEDManager
.
CloseS
Led
();
LEDManager
.
CloseS
tatusLights
();
}
}
private
void
button5_Click
(
object
sender
,
EventArgs
e
)
private
void
button5_Click
(
object
sender
,
EventArgs
e
)
{
{
LEDManager
.
OpenS
YellowLed
(
);
LEDManager
.
OpenS
tatusLights
(
"yellow"
);
}
}
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论