Commit beb326b5 LN

RGB颜色顺序增加配置

1 个父辈 e618cd30
...@@ -35,5 +35,10 @@ namespace SmartShelf.Common ...@@ -35,5 +35,10 @@ namespace SmartShelf.Common
/// 状态灯区域ID /// 状态灯区域ID
/// </summary> /// </summary>
public static string StatusLedDmx = "StatusLedDmx"; public static string StatusLedDmx = "StatusLedDmx";
/// <summary>
/// 颜色规则配置
/// </summary>
public static string ColorRuleConfig = "ColorRuleConfig";
} }
} }
...@@ -14,6 +14,9 @@ namespace SmartShelf.DeviceLibrary ...@@ -14,6 +14,9 @@ namespace SmartShelf.DeviceLibrary
public static byte DefaultLight = 100; public static byte DefaultLight = 100;
public static int DeviceLedType = ConfigAppSettings.GetIntValue(Setting_Init.DeviceLedType); public static int DeviceLedType = ConfigAppSettings.GetIntValue(Setting_Init.DeviceLedType);
public static string ColorRule = ConfigAppSettings.GetValue(Setting_Init.ColorRuleConfig).ToUpper();
public static string DefaultIP = ConfigAppSettings.GetValue(Setting_Init.DefaultDeviceIP); public static string DefaultIP = ConfigAppSettings.GetValue(Setting_Init.DefaultDeviceIP);
public static LEDBaseModule GetLedModule(string ip) public static LEDBaseModule GetLedModule(string ip)
...@@ -30,6 +33,20 @@ namespace SmartShelf.DeviceLibrary ...@@ -30,6 +33,20 @@ namespace SmartShelf.DeviceLibrary
} }
return led; return led;
} }
public static void Init()
{
ColorRule = ConfigAppSettings.GetValue(Setting_Init.ColorRuleConfig).ToUpper();
if (ColorRule.Length == 3 && ColorRule.Contains("R") && ColorRule.Contains("G") && ColorRule.Contains("B"))
{
}
else
{
LEDManager.ColorRule = "RGB";
ConfigAppSettings.SaveValue(Setting_Init.ColorRuleConfig, LEDManager.ColorRule);
}
LoadStatusDMX();
}
public static void LoadStatusDMX() public static void LoadStatusDMX()
{ {
StatusLedDmx = new List<int>(); StatusLedDmx = new List<int>();
......
...@@ -82,10 +82,19 @@ namespace SmartShelf.DeviceLibrary ...@@ -82,10 +82,19 @@ namespace SmartShelf.DeviceLibrary
} }
byte[] data = dmxDatas[ldmx]; byte[] data = dmxDatas[ldmx];
int redIndex = LEDManager.ColorRule.IndexOf('R');
int greedIndex = LEDManager.ColorRule.IndexOf('G');
int blueIndex = LEDManager.ColorRule.IndexOf('B');
//SPI第二通道为蓝色,DMX第二通道为绿色 //SPI第二通道为蓝色,DMX第二通道为绿色
data[lIndex * 3] = red; data[lIndex * 3+redIndex] = red;
data[lIndex * 3 + 1] = green; data[lIndex * 3 + greedIndex] = green;
data[lIndex * 3 + 2] = blue; data[lIndex * 3 + blueIndex] = blue;
////SPI第二通道为蓝色,DMX第二通道为绿色
//data[lIndex * 3] = red;
//data[lIndex * 3 + 1] = green;
//data[lIndex * 3 + 2] = blue;
} }
public override void AllLightOff(int dmx = -1) public override void AllLightOff(int dmx = -1)
{ {
......
using System; using SmartShelf.Common;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
......
...@@ -71,7 +71,7 @@ namespace SmartShelf.DeviceLibrary ...@@ -71,7 +71,7 @@ namespace SmartShelf.DeviceLibrary
{ {
return false; return false;
} }
LEDManager.LoadStatusDMX(); LEDManager.Init();
LEDManager.deviceMap = new Dictionary<string, LEDBaseModule>(); LEDManager.deviceMap = new Dictionary<string, LEDBaseModule>();
StatusColorMap = new Dictionary<string, string>(); StatusColorMap = new Dictionary<string, string>();
foreach (BoxPosition box in PositionMap.Values) foreach (BoxPosition box in PositionMap.Values)
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
<add key ="DefaultDeviceIP" value ="192.168.201.191"/> <add key ="DefaultDeviceIP" value ="192.168.201.191"/>
<!--状态灯地址,;分割--> <!--状态灯地址,;分割-->
<add key ="StatusLedDmx" value ="0"/> <add key ="StatusLedDmx" value ="0"/>
<!--灯条颜色规则配置-->
<add key ="ColorRuleConfig" value ="RGB"/>
</appSettings> </appSettings>
<log4net> <log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
...@@ -35,14 +35,17 @@ ...@@ -35,14 +35,17 @@
this.txtIP = new System.Windows.Forms.TextBox(); this.txtIP = new System.Windows.Forms.TextBox();
this.txtStaDmxId = new System.Windows.Forms.TextBox(); this.txtStaDmxId = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.comBoxColor = new System.Windows.Forms.ComboBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(12, 34); this.label1.Location = new System.Drawing.Point(72, 71);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(356, 20); this.label1.Size = new System.Drawing.Size(148, 20);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "第一块控制器模块IP:"; this.label1.Text = "第一块控制器模块IP:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
...@@ -52,7 +55,7 @@ ...@@ -52,7 +55,7 @@
this.btnSave.Anchor = System.Windows.Forms.AnchorStyles.Top; this.btnSave.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSave.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnSave.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSave.Location = new System.Drawing.Point(192, 231); this.btnSave.Location = new System.Drawing.Point(226, 256);
this.btnSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnSave.Name = "btnSave"; this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(103, 36); this.btnSave.Size = new System.Drawing.Size(103, 36);
...@@ -66,7 +69,7 @@ ...@@ -66,7 +69,7 @@
this.btnBack.Anchor = System.Windows.Forms.AnchorStyles.Top; this.btnBack.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnBack.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnBack.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBack.Location = new System.Drawing.Point(84, 231); this.btnBack.Location = new System.Drawing.Point(118, 256);
this.btnBack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnBack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnBack.Name = "btnBack"; this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(103, 36); this.btnBack.Size = new System.Drawing.Size(103, 36);
...@@ -78,37 +81,68 @@ ...@@ -78,37 +81,68 @@
// txtIP // txtIP
// //
this.txtIP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtIP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtIP.Location = new System.Drawing.Point(84, 68); this.txtIP.Location = new System.Drawing.Point(226, 67);
this.txtIP.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.txtIP.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtIP.Name = "txtIP"; this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(211, 29); this.txtIP.Size = new System.Drawing.Size(142, 29);
this.txtIP.TabIndex = 276; this.txtIP.TabIndex = 276;
this.txtIP.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown); this.txtIP.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown);
// //
// txtStaDmxId // txtStaDmxId
// //
this.txtStaDmxId.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtStaDmxId.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtStaDmxId.Location = new System.Drawing.Point(84, 157); this.txtStaDmxId.Location = new System.Drawing.Point(226, 121);
this.txtStaDmxId.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.txtStaDmxId.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.txtStaDmxId.Name = "txtStaDmxId"; this.txtStaDmxId.Name = "txtStaDmxId";
this.txtStaDmxId.Size = new System.Drawing.Size(211, 29); this.txtStaDmxId.Size = new System.Drawing.Size(142, 29);
this.txtStaDmxId.TabIndex = 278; this.txtStaDmxId.TabIndex = 278;
// //
// label2 // label2
// //
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(12, 123); this.label2.Location = new System.Drawing.Point(44, 125);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(356, 20); this.label2.Size = new System.Drawing.Size(176, 20);
this.label2.TabIndex = 277; this.label2.TabIndex = 277;
this.label2.Text = "状态灯区域地址(用;分隔):"; this.label2.Text = "状态灯区域地址(用;分隔):";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(113, 185);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(107, 20);
this.label3.TabIndex = 279;
this.label3.Text = "灯条颜色顺序:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// comBoxColor
//
this.comBoxColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comBoxColor.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comBoxColor.FormattingEnabled = true;
this.comBoxColor.Items.AddRange(new object[] {
"RGB=红绿蓝",
"RBG=红蓝绿",
"GRB=绿红蓝",
"GBR=绿蓝红",
"BRG=蓝红绿",
"BGR=蓝绿红"});
this.comBoxColor.Location = new System.Drawing.Point(226, 182);
this.comBoxColor.Name = "comBoxColor";
this.comBoxColor.Size = new System.Drawing.Size(142, 28);
this.comBoxColor.TabIndex = 280;
//
// FrmConfig // FrmConfig
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(380, 308); this.ClientSize = new System.Drawing.Size(459, 339);
this.Controls.Add(this.comBoxColor);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtStaDmxId); this.Controls.Add(this.txtStaDmxId);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.txtIP); this.Controls.Add(this.txtIP);
...@@ -136,5 +170,7 @@ ...@@ -136,5 +170,7 @@
private System.Windows.Forms.TextBox txtIP; private System.Windows.Forms.TextBox txtIP;
private System.Windows.Forms.TextBox txtStaDmxId; private System.Windows.Forms.TextBox txtStaDmxId;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comBoxColor;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -19,11 +19,34 @@ namespace SmartShelf ...@@ -19,11 +19,34 @@ namespace SmartShelf
{ {
InitializeComponent(); InitializeComponent();
} }
private List<string> ColorList = new List<string>();
private void FrmPwd_Load(object sender, EventArgs e) private void FrmPwd_Load(object sender, EventArgs e)
{ {
txtIP.Text = LEDManager.DefaultIP; txtIP.Text = LEDManager.DefaultIP;
txtStaDmxId.Text = ConfigAppSettings.GetValue(Setting_Init.StatusLedDmx); txtStaDmxId.Text = ConfigAppSettings.GetValue(Setting_Init.StatusLedDmx);
ColorList = new List<string>(){
"RGB=红绿蓝",
"RBG=红蓝绿",
"GRB=绿红蓝",
"GBR=绿蓝红",
"BRG=蓝红绿",
"BGR=蓝绿红"};
comBoxColor.Items.Clear();
int index = 0;
int i = 0;
foreach (string s in ColorList)
{
comBoxColor.Items.Add(s);
if (s.Contains(LEDManager.ColorRule))
{
index = i;
}
i++;
}
comBoxColor.SelectedIndex = index;
} }
private void btnNext_Click(object sender, EventArgs e) private void btnNext_Click(object sender, EventArgs e)
...@@ -37,6 +60,15 @@ namespace SmartShelf ...@@ -37,6 +60,15 @@ namespace SmartShelf
ConfigAppSettings.SaveValue(Setting_Init.StatusLedDmx, dmxIds); ConfigAppSettings.SaveValue(Setting_Init.StatusLedDmx, dmxIds);
LEDManager.LoadStatusDMX(); LEDManager.LoadStatusDMX();
string colorText = comBoxColor.Text;
if (colorText.Length >= 7)
{
string result = colorText.Substring(0, 3);
ConfigAppSettings.SaveValue(Setting_Init.ColorRuleConfig, result);
LEDManager.ColorRule = result;
LogUtil.info("保存灯条颜色配置:" + Setting_Init.ColorRuleConfig +"="+ result);
}
MessageBox.Show("保存成功,重启软件后生效"); MessageBox.Show("保存成功,重启软件后生效");
this.Close(); this.Close();
} }
......
...@@ -19,4 +19,9 @@ linePositions.csv文件里面: ...@@ -19,4 +19,9 @@ linePositions.csv文件里面:
增加配置,表示状态灯区域地址。 增加配置,表示状态灯区域地址。
<!--状态灯地址,;分割--> <!--状态灯地址,;分割-->
<add key ="StatusLedDmx" value ="0"/>
\ No newline at end of file \ No newline at end of file
<add key ="StatusLedDmx" value ="0"/>
20200603
RGB颜色顺序增加配置。
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!