Commit f0dd7bd2 LN

art-net修改

1 个父辈 9f260e79
...@@ -174,7 +174,6 @@ namespace SmartShelf.DeviceLibrary ...@@ -174,7 +174,6 @@ namespace SmartShelf.DeviceLibrary
public abstract class LEDBaseModule public abstract class LEDBaseModule
{ {
//DMX端口为6454, SPI端口为6858
protected IPEndPoint iep = null; protected IPEndPoint iep = null;
public string ModuleIP = ""; public string ModuleIP = "";
public static LEDBaseModule GetModule(string ip) public static LEDBaseModule GetModule(string ip)
...@@ -199,8 +198,8 @@ namespace SmartShelf.DeviceLibrary ...@@ -199,8 +198,8 @@ namespace SmartShelf.DeviceLibrary
internal LEDBaseModule(string ip) internal LEDBaseModule(string ip)
{ {
ModuleIP = ip; ModuleIP = ip;
iep = new IPEndPoint(IPAddress.Parse(ip), 6858); // iep = new IPEndPoint(IPAddress.Parse(ip), 6858);
AllLightOff(); // AllLightOff();
} }
......
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;
...@@ -16,27 +17,51 @@ namespace SmartShelf.DeviceLibrary ...@@ -16,27 +17,51 @@ namespace SmartShelf.DeviceLibrary
public class LEDColorArtNet : LEDBaseModule public class LEDColorArtNet : LEDBaseModule
{ {
private const ushort MAX_RGBDMX_UNI = 8;//定义8个RGB灯的DMX域缓存 private const ushort Max_DMX = 16;//定义8个RGB灯的DMX域缓存
//每个DMX域的灯数量 //每个DMX域的灯数量
private const int LIGHT_COUNT_PER_DMX = 170; private int Max_Light = 170;
private int datalength = 512;
//byte[][] dmxData = new byte[MAX_RGBDMX_UNI][]; //byte[][] dmxData = new byte[MAX_RGBDMX_UNI][];
private List<byte[]> dmxDatas = new List<byte[]>(MAX_RGBDMX_UNI); private List<byte[]> dmxDatas = new List<byte[]>(Max_DMX);
internal LEDColorArtNet(string ip) : base(ip) internal LEDColorArtNet(string ip) : base(ip)
{ {
datalength = 512;
Max_Light = datalength / 3;
iep = new IPEndPoint(IPAddress.Parse(ip), 6454); iep = new IPEndPoint(IPAddress.Parse(ip), 6454);
AllLightOff(); AllLightOff();
} }
private void InitDatas() private void InitDatas()
{ {
dmxDatas = new List<byte[]>(MAX_RGBDMX_UNI);
for (int i = 0; i < MAX_RGBDMX_UNI; i++) dmxDatas = new List<byte[]>(Max_DMX);
for (int i = 0; i < Max_DMX; i++)
{
dmxDatas.Add(new byte[datalength]);
}
}
private void UpdateLightData(int dmx,int index,byte red=0, byte green =0, byte blue =0)
{
int ldmx = dmx;
int lIndex = index;
if (index >= Max_Light)
{ {
dmxDatas.Add(new byte[1024]); ldmx = index / Max_Light;
lIndex = index % Max_Light;
} }
if (ldmx >= dmxDatas.Count)
{
LogUtil.error(" UpdateLightData error: dmx [" + ldmx + "] MAX_UNI[" + Max_DMX + "]");
return ;
} }
byte[] data = dmxDatas[ldmx];
//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)
{ {
InitDatas(); InitDatas();
...@@ -50,15 +75,12 @@ namespace SmartShelf.DeviceLibrary ...@@ -50,15 +75,12 @@ namespace SmartShelf.DeviceLibrary
public override void AllLightOn(Light light) public override void AllLightOn(Light light)
{ {
for (int i = 0; i < MAX_RGBDMX_UNI; i++) for (int i = 0; i < Max_DMX; i++)
{ {
byte[] data = dmxDatas[i]; byte[] data = dmxDatas[i];
for (int lightIndex = 0; lightIndex < LIGHT_COUNT_PER_DMX; lightIndex++) for (int index = 0; index < Max_Light; index++)
{ {
data[lightIndex * 3] = light.Red; UpdateLightData(i, index, light.Red, light.Green, light.Blue);
data[lightIndex * 3 + 1] = light.Blue;
data[lightIndex * 3 + 2] = light.Green;
//dmxDatas[i] = data;
} }
} }
PushToDevice(); PushToDevice();
...@@ -82,17 +104,8 @@ namespace SmartShelf.DeviceLibrary ...@@ -82,17 +104,8 @@ namespace SmartShelf.DeviceLibrary
{ {
foreach (Light light in lights) foreach (Light light in lights)
{ {
int dmxIndex = light.index / LIGHT_COUNT_PER_DMX; UpdateLightData(light.dmx, light.index, light.Red, light.Green, light.Blue);
int lightIndex = light.index % LIGHT_COUNT_PER_DMX;
byte[] data = dmxDatas[dmxIndex];
//SPI第二通道为蓝色,DMX第二通道为绿色
data[lightIndex * 3] = light.Red;
data[lightIndex * 3 + 1] = light.Blue;
data[lightIndex * 3 + 2] = light.Green;
//data[lightIndex * 3] = 255;
//data[lightIndex * 3 + 1] = 255;
//data[lightIndex * 3 + 2] = 255;
} }
PushToDevice(); PushToDevice();
} }
...@@ -101,14 +114,8 @@ namespace SmartShelf.DeviceLibrary ...@@ -101,14 +114,8 @@ namespace SmartShelf.DeviceLibrary
{ {
foreach (int lightId in lightIndexs) foreach (int lightId in lightIndexs)
{ {
int dmxIndex = lightId / LIGHT_COUNT_PER_DMX; UpdateLightData(dmx, lightId, 0, 0, 0);
int lightIndex = lightId % LIGHT_COUNT_PER_DMX;
byte[] data = dmxDatas[dmxIndex];
//SPI第二通道为蓝色,DMX第二通道为绿色
data[lightIndex * 3] = 0;
data[lightIndex * 3 + 1] = 0;
data[lightIndex * 3 + 2] = 0;
} }
PushToDevice(); PushToDevice();
...@@ -117,15 +124,8 @@ namespace SmartShelf.DeviceLibrary ...@@ -117,15 +124,8 @@ namespace SmartShelf.DeviceLibrary
{ {
foreach (Light light in lights) foreach (Light light in lights)
{ {
int lightId = light.index; UpdateLightData(light.dmx, light.index, 0, 0, 0);
int dmxIndex = lightId / LIGHT_COUNT_PER_DMX;
int lightIndex = lightId % LIGHT_COUNT_PER_DMX;
byte[] data = dmxDatas[dmxIndex];
//SPI第二通道为蓝色,DMX第二通道为绿色
data[lightIndex * 3] = 0;
data[lightIndex * 3 + 1] = 0;
data[lightIndex * 3 + 2] = 0;
} }
PushToDevice(); PushToDevice();
...@@ -144,7 +144,6 @@ namespace SmartShelf.DeviceLibrary ...@@ -144,7 +144,6 @@ namespace SmartShelf.DeviceLibrary
{ {
byte[] toSend = ToSPIData(i, dmxDatas[i]); byte[] toSend = ToSPIData(i, dmxDatas[i]);
myUdpClient.Send(toSend, toSend.Length, iep); myUdpClient.Send(toSend, toSend.Length, iep);
break;
} }
} }
catch (Exception err) catch (Exception err)
...@@ -185,9 +184,14 @@ namespace SmartShelf.DeviceLibrary ...@@ -185,9 +184,14 @@ namespace SmartShelf.DeviceLibrary
string ProVer = "000e"; string ProVer = "000e";
string seq = "00"; string seq = "00";
string phy = "00"; string phy = "00";
string SubUni = "00";//更新标准:0=写到缓存,未输出到dmxData;1=无缓存,立即输出到dmxData string SubUni = "00";
SubUni= String.Format("{0:X}", dmxIndex).PadLeft(2, '0');
string Net = "00"; string Net = "00";
int len = dmxData.Length;
string str = String.Format("{0:X}", dmxData.Length).PadLeft(4,'0');
string length = "0200"; string length = "0200";
length = str;
//string Broadcast = "0";//0=没有广播,只控制指定域;1=对设备的所有端口广播;2=对某个子网内的所有域广播;3,对网络下的所有子网广播;0xff=对所有网络设备的所有口广播 //string Broadcast = "0";//0=没有广播,只控制指定域;1=对设备的所有端口广播;2=对某个子网内的所有域广播;3,对网络下的所有子网广播;0xff=对所有网络设备的所有口广播
//string SubUni = "00";// IP灯光子网地址:0~255;子网又可分,字节的高4位为子网,字节的低4位为dmxData域,;子网:0~15,DMX域:0~15; //string SubUni = "00";// IP灯光子网地址:0~255;子网又可分,字节的高4位为子网,字节的低4位为dmxData域,;子网:0~15,DMX域:0~15;
//string net = "" + dmxIndex + "00"; //IP灯光网络地址:0~127 //string net = "" + dmxIndex + "00"; //IP灯光网络地址:0~127
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<!--服务器地址--> <!--服务器地址-->
<add key="http.server" value="http://192.168.200.22:8080/" /> <add key="http.server" value="http://192.168.200.22:8080/" />
<!--料架灯类型,0=单色灯料架,1=三色灯料架--> <!--料架灯类型,0=单色灯料架,1=三色灯料架,2=art-net-->
<add key="DeviceLedType" value="1" /> <add key="DeviceLedType" value="2" />
<!--一下为一个料仓的默认配置 开始--> <!--一下为一个料仓的默认配置 开始-->
<add key="Store_Position_Config" value="\Config\GW\linePositions.csv"/> <add key="Store_Position_Config" value="\Config\GW\linePositions.csv"/>
<add key="Store_ConfigPath" value="\Config\StoreConfig.csv" /> <add key="Store_ConfigPath" value="\Config\StoreConfig.csv" />
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSMStore)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSMStore));
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button5 = new System.Windows.Forms.Button();
this.btnCloseSLed = new System.Windows.Forms.Button(); this.btnCloseSLed = new System.Windows.Forms.Button();
this.btnOpenSLed = new System.Windows.Forms.Button(); this.btnOpenSLed = new System.Windows.Forms.Button();
this.cmbNum = new System.Windows.Forms.ComboBox(); this.cmbNum = new System.Windows.Forms.ComboBox();
...@@ -57,10 +58,13 @@ ...@@ -57,10 +58,13 @@
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.lblLedInfo = new System.Windows.Forms.Label(); this.lblLedInfo = new System.Windows.Forms.Label();
this.button5 = new System.Windows.Forms.Button(); this.numYu = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numYu)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// timer1 // timer1
...@@ -73,6 +77,9 @@ ...@@ -73,6 +77,9 @@
// //
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left))); | System.Windows.Forms.AnchorStyles.Left)));
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.numYu);
this.groupBox2.Controls.Add(this.button5); this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Controls.Add(this.btnCloseSLed); this.groupBox2.Controls.Add(this.btnCloseSLed);
this.groupBox2.Controls.Add(this.btnOpenSLed); this.groupBox2.Controls.Add(this.btnOpenSLed);
...@@ -102,6 +109,17 @@ ...@@ -102,6 +109,17 @@
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "门锁操作测试"; this.groupBox2.Text = "门锁操作测试";
// //
// button5
//
this.button5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button5.Location = new System.Drawing.Point(106, 421);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(95, 35);
this.button5.TabIndex = 112;
this.button5.Text = "亮黄灯";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// btnCloseSLed // btnCloseSLed
// //
this.btnCloseSLed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnCloseSLed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
...@@ -167,7 +185,7 @@ ...@@ -167,7 +185,7 @@
// btnCloseLed // btnCloseLed
// //
this.btnCloseLed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnCloseLed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCloseLed.Location = new System.Drawing.Point(155, 369); this.btnCloseLed.Location = new System.Drawing.Point(170, 366);
this.btnCloseLed.Name = "btnCloseLed"; this.btnCloseLed.Name = "btnCloseLed";
this.btnCloseLed.Size = new System.Drawing.Size(115, 35); this.btnCloseLed.Size = new System.Drawing.Size(115, 35);
this.btnCloseLed.TabIndex = 36; this.btnCloseLed.TabIndex = 36;
...@@ -178,16 +196,16 @@ ...@@ -178,16 +196,16 @@
// txtLedIndex // txtLedIndex
// //
this.txtLedIndex.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtLedIndex.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtLedIndex.Location = new System.Drawing.Point(34, 337); this.txtLedIndex.Location = new System.Drawing.Point(75, 370);
this.txtLedIndex.Name = "txtLedIndex"; this.txtLedIndex.Name = "txtLedIndex";
this.txtLedIndex.Size = new System.Drawing.Size(115, 26); this.txtLedIndex.Size = new System.Drawing.Size(89, 26);
this.txtLedIndex.TabIndex = 35; this.txtLedIndex.TabIndex = 35;
this.txtLedIndex.Text = "0"; this.txtLedIndex.Text = "0";
// //
// button4 // button4
// //
this.button4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button4.Location = new System.Drawing.Point(155, 328); this.button4.Location = new System.Drawing.Point(170, 327);
this.button4.Name = "button4"; this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(115, 35); this.button4.Size = new System.Drawing.Size(115, 35);
this.button4.TabIndex = 34; this.button4.TabIndex = 34;
...@@ -364,16 +382,37 @@ ...@@ -364,16 +382,37 @@
this.lblLedInfo.TabIndex = 0; this.lblLedInfo.TabIndex = 0;
this.lblLedInfo.Text = "label3"; this.lblLedInfo.Text = "label3";
// //
// button5 // numYu
// //
this.button5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.numYu.Location = new System.Drawing.Point(75, 333);
this.button5.Location = new System.Drawing.Point(106, 421); this.numYu.Maximum = new decimal(new int[] {
this.button5.Name = "button5"; 15,
this.button5.Size = new System.Drawing.Size(95, 35); 0,
this.button5.TabIndex = 112; 0,
this.button5.Text = "亮黄灯"; 0});
this.button5.UseVisualStyleBackColor = true; this.numYu.Name = "numYu";
this.button5.Click += new System.EventHandler(this.button5_Click); this.numYu.Size = new System.Drawing.Size(89, 23);
this.numYu.TabIndex = 113;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 336);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(57, 17);
this.label3.TabIndex = 115;
this.label3.Text = "区域ID:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 375);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 17);
this.label4.TabIndex = 114;
this.label4.Text = "灯地址:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
// //
// FrmSMStore // FrmSMStore
// //
...@@ -397,6 +436,7 @@ ...@@ -397,6 +436,7 @@
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.panel1.PerformLayout(); this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numYu)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
...@@ -430,5 +470,8 @@ ...@@ -430,5 +470,8 @@
private System.Windows.Forms.Button btnCloseSLed; private System.Windows.Forms.Button btnCloseSLed;
private System.Windows.Forms.Button btnOpenSLed; private System.Windows.Forms.Button btnOpenSLed;
private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button5;
private System.Windows.Forms.NumericUpDown numYu;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -181,7 +181,7 @@ namespace SmartShelf ...@@ -181,7 +181,7 @@ namespace SmartShelf
{ {
string ip = txtAddr.Text; string ip = txtAddr.Text;
int index = FormUtil.GetIntValue(txtLedIndex); int index = FormUtil.GetIntValue(txtLedIndex);
int dmxId = FormUtil.GetIntValue(txtDmxId); int dmxId =(int) numYu.Value;
LEDManager.GetLedModule(ip).LightOn(Light.DefaultLight(dmxId, index)); LEDManager.GetLedModule(ip).LightOn(Light.DefaultLight(dmxId, index));
} }
...@@ -189,7 +189,7 @@ namespace SmartShelf ...@@ -189,7 +189,7 @@ namespace SmartShelf
{ {
string ip = txtAddr.Text; string ip = txtAddr.Text;
int index = FormUtil.GetIntValue(txtLedIndex); int index = FormUtil.GetIntValue(txtLedIndex);
int dmxId = FormUtil.GetIntValue(txtDmxId); int dmxId = (int)numYu.Value;
LEDManager.GetLedModule(ip).LightOff( dmxId, index); LEDManager.GetLedModule(ip).LightOff( dmxId, index);
} }
public int preIndex = 0; public int preIndex = 0;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!