Commit 8ebdcd5d LN

三色灯有亮灯时增加黄灯闪烁功能。

1 个父辈 11f9fdc6
...@@ -77,20 +77,24 @@ namespace SmartShelf.DeviceLibrary ...@@ -77,20 +77,24 @@ namespace SmartShelf.DeviceLibrary
/// </summary> /// </summary>
public static int CurrLedStatus = -1; public static int CurrLedStatus = -1;
private static List<int> StatusLedDmx = new List<int>(); public static List<int> StatusLedDmx = new List<int>();
/// <summary>
/// 打开状态灯 public static void UpdateStatusLights(Dictionary<string,string> dataMap)
/// </summary>
public static void OpenStatusLights(string color = "green")
{ {
CloseStatusLights(""); Dictionary<string, List<Light>> lightsMap = new Dictionary<string, List<Light>>();
foreach (LEDBaseModule module in deviceMap.Values) List<string> ipDmx = new List<string>(dataMap.Keys);
foreach (string key in ipDmx)
{ {
string color = dataMap[key];
List<Light> sLed = new List<Light>(); string[] array = key.Split('_');
foreach (int dmx in StatusLedDmx) 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++) for (int index = 0; index < module.Max_Light; index++)
{ {
if ("green".Equals(color)) if ("green".Equals(color))
...@@ -101,28 +105,56 @@ namespace SmartShelf.DeviceLibrary ...@@ -101,28 +105,56 @@ namespace SmartShelf.DeviceLibrary
else if ("yellow".Equals(color)) else if ("yellow".Equals(color))
{ {
CurrLedStatus = 2; 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> public static void SaveLightToMap(Dictionary<string, List<Light>> lightsMap, string ip, Light[] lightArray)
/// 关闭状态灯
/// </summary>
/// <param name="color"></param>
public static void CloseStatusLights(string color = "")
{ {
CurrLedStatus = 0; if (lightArray != null && lightArray.Length > 0)
foreach (LEDBaseModule module in deviceMap.Values)
{ {
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 ...@@ -205,6 +237,10 @@ namespace SmartShelf.DeviceLibrary
public static byte defaultR = 0; public static byte defaultR = 0;
public static byte defaultG = 50; public static byte defaultG = 50;
public static byte defaultB = 0; 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) public static Light DefaultLight(int dmxId, int index)
{ {
return new Light(dmxId, index, defaultR, defaultG, defaultB, 200); return new Light(dmxId, index, defaultR, defaultG, defaultB, 200);
......
...@@ -71,9 +71,9 @@ namespace SmartShelf.DeviceLibrary ...@@ -71,9 +71,9 @@ namespace SmartShelf.DeviceLibrary
Operation lineOperation = GetLineBoxStatus(); Operation lineOperation = GetLineBoxStatus();
//获取亮灯的库位 //获取亮灯的库位
string posId = ""; string posId = "";
foreach (string key in StatusColorMap.Keys) foreach (string key in PosIdColorMap.Keys)
{ {
if (!String.IsNullOrEmpty(StatusColorMap[key])) if (!String.IsNullOrEmpty(PosIdColorMap[key]))
{ {
posId = posId + key + "|"; posId = posId + key + "|";
} }
......
...@@ -13,6 +13,12 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -13,6 +13,12 @@ namespace SmartShelf.LoadCSVLibrary
public CSVAttribute(string fieldName) public CSVAttribute(string fieldName)
{ {
FieldName = fieldName; FieldName = fieldName;
IsMust = true;
}
public CSVAttribute(string fieldName, bool ismust)
{
FieldName = fieldName;
IsMust = ismust;
} }
private string fieldName; private string fieldName;
...@@ -21,7 +27,9 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -21,7 +27,9 @@ namespace SmartShelf.LoadCSVLibrary
get { return fieldName; } get { return fieldName; }
set { fieldName = value; } set { fieldName = value; }
} }
/// <summary>
/// 是否必须的
/// </summary>
public bool IsMust { get; set; }
} }
} }
...@@ -32,6 +32,21 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -32,6 +32,21 @@ namespace SmartShelf.LoadCSVLibrary
return proCsvMap; 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> /// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合 /// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary> /// </summary>
...@@ -124,7 +139,7 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -124,7 +139,7 @@ namespace SmartShelf.LoadCSVLibrary
} }
return titleIndex; 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>(); Dictionary<string, int> titleIndex = new Dictionary<string, int>();
var array = lineValue.Split(','); var array = lineValue.Split(',');
...@@ -143,11 +158,18 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -143,11 +158,18 @@ namespace SmartShelf.LoadCSVLibrary
{ {
if (!titleIndex.ContainsKey(str)) if (!titleIndex.ContainsKey(str))
{ {
if (csvAttMap.ContainsKey(str))
{
if (csvAttMap[str].IsMust)
{
LOGGER.Error("未找到必须列:" + str + ",加载数据失败!"); LOGGER.Error("未找到必须列:" + str + ",加载数据失败!");
throw new CVSFieldNotMatchingExection("未找到必须列:" + str + ",加载数据失败!"); throw new CVSFieldNotMatchingExection("未找到必须列:" + str + ",加载数据失败!");
} }
} }
} }
}
}
return titleIndex; return titleIndex;
} }
} }
......
...@@ -25,6 +25,33 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -25,6 +25,33 @@ namespace SmartShelf.LoadCSVLibrary
[CSVAttribute("设备IP")] [CSVAttribute("设备IP")]
public string DeviceIp { get; set; } 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; private List<int> LedList = null;
public List<int> GetLedList() public List<int> GetLedList()
......
...@@ -56,6 +56,7 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -56,6 +56,7 @@ namespace SmartShelf.LoadCSVLibrary
Type type = typeof(T); Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T)); Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
Dictionary<string, CSVAttribute> csvAttMap = getAttributeMap(typeof(T));
if (proTitleMap.Count <= 4) if (proTitleMap.Count <= 4)
{ {
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性"); LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
...@@ -73,7 +74,7 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -73,7 +74,7 @@ namespace SmartShelf.LoadCSVLibrary
var array = line.Split(Spilt_Char); var array = line.Split(Spilt_Char);
if (index == 0) if (index == 0)
{ {
titleIndex = GetTitleIndex(line, cvsTitleList); titleIndex = GetTitleIndex(line, cvsTitleList, csvAttMap);
} }
else else
{ {
...@@ -93,10 +94,12 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -93,10 +94,12 @@ namespace SmartShelf.LoadCSVLibrary
string PositionNum = ""; string PositionNum = "";
foreach (string key in cvsTitleList) foreach (string key in cvsTitleList)
{ {
int titIndex = titleIndex[key];
string value = array[titIndex];
string proName = propertyList[listIndex]; string proName = propertyList[listIndex];
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性 PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (titleIndex.ContainsKey(key))
{
int titIndex = titleIndex[key];
string value = array[titIndex];
if (prop != null && value != "") if (prop != null && value != "")
{//如果属性存在 {//如果属性存在
prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题 prop.SetValue(bllIns, Convert.ChangeType(value, prop.PropertyType), null);//赋值****在这里需要考虑类型问题
...@@ -105,6 +108,18 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -105,6 +108,18 @@ namespace SmartShelf.LoadCSVLibrary
{ {
PositionNum = value; 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++; listIndex++;
} }
result.Add(PositionNum, (T)bllIns); result.Add(PositionNum, (T)bllIns);
...@@ -155,6 +170,7 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -155,6 +170,7 @@ namespace SmartShelf.LoadCSVLibrary
Type type = typeof(T); Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T)); Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
Dictionary<string, CSVAttribute> csvAttMap = getAttributeMap(typeof(T));
if (proTitleMap.Count <= 4) if (proTitleMap.Count <= 4)
{ {
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性"); LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
...@@ -172,7 +188,7 @@ namespace SmartShelf.LoadCSVLibrary ...@@ -172,7 +188,7 @@ namespace SmartShelf.LoadCSVLibrary
var array = line.Split(','); var array = line.Split(',');
if (index == 0) if (index == 0)
{ {
titleIndex = GetTitleIndex(line, cvsTitleList); titleIndex = GetTitleIndex(line, cvsTitleList, csvAttMap);
} }
else else
{ {
......
...@@ -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.OpenStatusLights("green"); BOXManager.OpenStatusLights("green");
} }
private void btnCloseSLed_Click(object sender, EventArgs e) private void btnCloseSLed_Click(object sender, EventArgs e)
{ {
LEDManager.CloseStatusLights(); BOXManager.CloseStatusLights();
} }
private void button5_Click(object sender, EventArgs e) private void button5_Click(object sender, EventArgs e)
{ {
LEDManager.OpenStatusLights("yellow"); BOXManager.OpenStatusLights("yellow");
} }
private void btOAll_Click(object sender, EventArgs e) private void btOAll_Click(object sender, EventArgs e)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!