Commit 6bec1bd3 LN

灯条库位测试

1 个父辈 c096dc5e
位置编号,对应号码,类型,节点名称,旋转位置,灯列表,设备IP
1_1,1,1,1_1_1,-6720,0,
1_2,2,1,1_1_2,-11940,0,
1_3,3,1,1_1_3,-17160,0,
1_4,4,1,1_1_4,-22380,0,
1_5,5,1,1_1_5,-27600,0,
1_6,6,1,1_1_6,24600,0,
1_7,7,1,1_1_7,19380,0,
1_8,8,1,1_1_8,14160,0,
1_9,9,1,1_1_9,8940,0,
1_10,10,1,1_1_10,3720,0,
2_1,11,1,1_2_1,-6720,0,
2_2,12,1,1_2_2,-11940,0,
2_3,13,1,1_2_3,-17160,0,
2_4,14,1,1_2_4,-22380,0,
2_5,15,1,1_2_5,-27600,0,
2_6,16,1,1_2_6,24600,0,
2_7,17,1,1_2_7,19380,0,
2_8,18,1,1_2_8,14160,0,
2_9,19,1,1_2_9,8940,0,
2_10,20,1,1_2_10,3720,0,
3_1,21,1,1_3_1,-6720,0,
3_2,22,1,1_3_2,-11940,0,
3_3,23,1,1_3_3,-17160,0,
3_4,24,1,1_3_4,-22380,0,
3_5,25,1,1_3_5,-27600,0,
3_6,26,1,1_3_6,24600,0,
3_7,27,1,1_3_7,19380,0,
3_8,28,1,1_3_8,14160,0,
3_9,29,1,1_3_9,8940,0,
3_10,30,1,1_3_10,3720,0,
,,,,,0,
4_1,31,1,1_4_1,-6720,0,
4_2,32,1,1_4_2,-11940,0,
4_3,33,1,1_4_3,-17160,0,
4_4,34,1,1_4_4,-22380,0,
4_5,35,1,1_4_5,-27600,0,
4_6,36,1,1_4_6,24600,0,
4_7,37,1,1_4_7,19380,0,
4_8,38,1,1_4_8,14160,0,
4_9,39,1,1_4_9,8940,0,
4_10,40,1,1_4_10,3720,0,
1_1,1,1,1_1_1,-3700,0,
1_2,2,1,1_1_2,-8920,0,
1_3,3,1,1_1_3,-14140,0,
1_4,4,1,1_1_4,-19360,0,
1_5,5,1,1_1_5,-24580,0,
1_6,6,1,1_1_6,27620,0,
1_7,7,1,1_1_7,22400,0,
1_8,8,1,1_1_8,17180,0,
1_9,9,1,1_1_9,11960,0,
1_10,10,1,1_1_10,6740,0,
,,,,,0,
5_1,41,1,1_5_1,-6720,0,
5_2,42,1,1_5_2,-11940,0,
5_3,43,1,1_5_3,-17160,0,
5_4,44,1,1_5_4,-22380,0,
5_5,45,1,1_5_5,-27600,0,
5_6,46,1,1_5_6,24600,0,
5_7,47,1,1_5_7,19380,0,
5_8,48,1,1_5_8,14160,0,
5_9,49,1,1_5_9,8940,0,
5_10,50,1,1_5_10,3720,0,
2_1,11,1,1_2_1,-3700,0,
2_2,12,2,1_2_2,-8920,0,
2_3,13,3,1_2_3,-14140,0,
2_4,14,4,1_2_4,-19360,0,
2_5,15,5,1_2_5,-24580,0,
2_6,16,6,1_2_6,27620,0,
2_7,17,7,1_2_7,22400,0,
2_8,18,8,1_2_8,17180,0,
2_9,19,9,1_2_9,11960,0,
2_10,20,10,1_2_10,6740,0,
,,,,,0,
6_1,51,1,2_1_1,-6720,0,
6_2,52,1,2_1_2,-11940,0,
6_3,53,1,2_1_3,-17160,0,
6_4,54,1,2_1_4,-22380,0,
6_5,55,1,2_1_5,-27600,0,
6_6,56,1,2_1_6,24600,0,
6_7,57,1,2_1_7,19380,0,
6_8,58,1,2_1_8,14160,0,
6_9,59,1,2_1_9,8940,0,
6_10,60,1,2_1_10,3720,0,
3_1,21,1,1_3_1,-3700,0,
3_2,22,2,1_3_2,-8920,0,
3_3,23,3,1_3_3,-14140,0,
3_4,24,4,1_3_4,-19360,0,
3_5,25,5,1_3_5,-24580,0,
3_6,26,6,1_3_6,27620,0,
3_7,27,7,1_3_7,22400,0,
3_8,28,8,1_3_8,17180,0,
3_9,29,9,1_3_9,11960,0,
3_10,30,10,1_3_10,6740,0,
,,,,,0,
7_1,61,1,2_2_1,-6720,0,
7_2,62,1,2_2_2,-11940,0,
7_3,63,1,2_2_3,-17160,0,
7_4,64,1,2_2_4,-22380,0,
7_5,65,1,2_2_5,-27600,0,
7_6,66,1,2_2_6,24600,0,
7_7,67,1,2_2_7,19380,0,
7_8,68,1,2_2_8,14160,0,
7_9,69,1,2_2_9,8940,0,
7_10,70,1,2_2_10,3720,0,
4_1,31,1,1_4_1,-3700,0,
4_2,32,2,1_4_2,-8920,0,
4_3,33,3,1_4_3,-14140,0,
4_4,34,4,1_4_4,-19360,0,
4_5,35,5,1_4_5,-24580,0,
4_6,36,6,1_4_6,27620,0,
4_7,37,7,1_4_7,22400,0,
4_8,38,8,1_4_8,17180,0,
4_9,39,9,1_4_9,11960,0,
4_10,40,10,1_4_10,6740,0,
,,,,,0,
8_1,71,1,2_3_1,-6720,0,
8_2,72,1,2_3_2,-11940,0,
8_3,73,1,2_3_3,-17160,0,
8_4,74,1,2_3_4,-22380,0,
8_5,75,1,2_3_5,-27600,0,
8_6,76,1,2_3_6,24600,0,
8_7,77,1,2_3_7,19380,0,
8_8,78,1,2_3_8,14160,0,
8_9,79,1,2_3_9,8940,0,
8_10,80,1,2_3_10,3720,0,
,,,,,0,
9_1,81,1,2_4_1,-6720,0,
9_2,82,1,2_4_2,-11940,0,
9_3,83,1,2_4_3,-17160,0,
9_4,84,1,2_4_4,-22380,0,
9_5,85,1,2_4_5,-27600,0,
9_6,86,1,2_4_6,24600,0,
9_7,87,1,2_4_7,19380,0,
9_8,88,1,2_4_8,14160,0,
9_9,89,1,2_4_9,8940,0,
9_10,90,1,2_4_10,3720,0,
,,,,,0,
10_1,91,1,2_5_1,-6720,0,
10_2,92,1,2_5_2,-11940,0,
10_3,93,1,2_5_3,-17160,0,
10_4,94,1,2_5_4,-22380,0,
10_5,95,1,2_5_5,-27600,0,
10_6,96,1,2_5_6,24600,0,
10_7,97,1,2_5_7,19380,0,
10_8,98,1,2_5_8,14160,0,
10_9,99,1,2_5_9,8940,0,
10_10,100,1,2_5_10,3720,0,
5_1,41,1,1_5_1,-3700,0,
5_2,42,2,1_5_2,-8920,0,
5_3,43,3,1_5_3,-14140,0,
5_4,44,4,1_5_4,-19360,0,
5_5,45,5,1_5_5,-24580,0,
5_6,46,6,1_5_6,27620,0,
5_7,47,7,1_5_7,22400,0,
5_8,48,8,1_5_8,17180,0,
5_9,49,9,1_5_9,11960,0,
5_10,50,10,1_5_10,6740,0,
,,,,,,
20_1,101,3,COM3,0,1#2#3#4#5,
20_2,102,3,COM3,1,6#7#8#9#10,
20_3,103,3,COM3,2,1#2#3#4#6,
20_4,104,3,COM3,3,6#7#8#9#11,
20_5,105,3,COM3,4,1#2#3#4#7,
20_6,106,3,COM3,5,6#7#8#9#12,
20_7,107,3,COM3,6,1#2#3#4#8,
20_8,108,3,COM3,7,6#7#8#9#13,
20_9,109,3,COM3,8,1#2#3#4#9,
20_10,110,3,COM3,9,6#7#8#9#14,
20_11,111,3,COM3,10,1#2#3#4#10,
20_12,112,3,COM3,11,6#7#8#9#15,
20_13,113,3,COM3,12,1#2#3#4#11,
20_14,114,3,COM3,13,6#7#8#9#16,
20_15,115,3,COM3,14,1#2#3#4#12,
20_16,116,3,COM3,15,6#7#8#9#17,
6_1,61,3,6,-3700,0,
6_2,62,3,6,-8920,8,
6_3,63,3,6,-14140,16,
7_1,64,3,6,-3700,24,
7_2,65,3,6,-8920,32,
7_3,66,3,6,-14140,40,
8_1,67,3,6,-3700,48,
8_2,68,3,6,-8920,56,
8_3,69,3,6,-14140,64,
......@@ -11,6 +11,7 @@ namespace TSA_V.DeviceLibrary
{
public class RgbLedController
{
private static int posLength = 8;
public static Flyelectronic_485_RGB_Controller rGB_Controller = null;
public static bool Init()
......@@ -31,13 +32,12 @@ namespace TSA_V.DeviceLibrary
return true;
}
private static Color defColor = Color.Green;
private static Color defColor = Color.Green;
public static void OpenPosLed(TSAVPosition position)
{
if (position.IsRgbLed())
{
List<int> leds = position.getLedList();
OpenPosLed(leds);
}
}
......@@ -45,9 +45,17 @@ namespace TSA_V.DeviceLibrary
{
if (rGB_Controller == null)
{
{
return;
}
if (leds.Count == 1)
{
int start = leds[0];
for (int i = start + 1; i < start + posLength; i++)
{
leds.Add(i);
}
}
rGB_Controller.ShowLedColor(defColor, leds);
}
......
......@@ -28,7 +28,7 @@ namespace TSA_V.DeviceLibrary
private Dictionary<string, byte[][]> effactValue = new Dictionary<string, byte[][]>();
public Flyelectronic_485_RGB_Controller(string name, string logname = "RollingLogFileAppender")
public Flyelectronic_485_RGB_Controller(string name, string logname = "defaultAppender")
{
Name = name;
loge = LogManager.GetLogger(logname);
......@@ -66,6 +66,7 @@ namespace TSA_V.DeviceLibrary
_serialPort.Open();
LogUtil.info("氛围灯" + comPortName + "打开成功");
errmsg = "";
for (int i = 1; i < 10; i++)
{
Thread.Sleep(100);
......@@ -124,7 +125,7 @@ namespace TSA_V.DeviceLibrary
//});
}
public bool ShowColor(Color color, ColorFormat colorFormat = ColorFormat.GRB)
public bool ShowColor(Color color, ColorFormat colorFormat = ColorFormat.GBR)
{
var newbyte = CommandByte.SetOneColor;
var colorbyte = ConvertColorToByteArray(color, colorFormat);
......@@ -142,15 +143,15 @@ namespace TSA_V.DeviceLibrary
}
return false;
}
public bool ShowLedColor(Color color, int startIndex, int endIndex)
{
List<int> ledIndex = new List<int>();
for (int i = startIndex; i < endIndex; i++)
{
ledIndex.Add(i);
}
return ShowLedColor(color, ledIndex);
}
//public bool ShowLedColor(Color color, int startIndex, int endIndex)
//{
// List<int> ledIndex = new List<int>();
// for (int i = startIndex; i < endIndex; i++)
// {
// ledIndex.Add(i);
// }
// return ShowLedColor(color, ledIndex);
//}
/// <summary>
/// 指定索引的灯显示指定颜色,其他的灯灭
/// </summary>
......@@ -158,8 +159,9 @@ namespace TSA_V.DeviceLibrary
/// <param name="colorFormat"></param>
/// <param name="ledIndex"></param>
/// <returns></returns>
public bool ShowLedColor(Color color, List<int> ledIndex, int maxledIndex = 100, ColorFormat colorFormat = ColorFormat.GRB)
public bool ShowLedColor(Color color, List<int> ledIndex, int maxledIndex = 0, ColorFormat colorFormat = ColorFormat.GBR)
{
ShowColor(Color.Black);
List<byte> allData = new List<byte>();
byte[] startByte = CommandByte.ledColorStart;
byte[] endByte = CommandByte.ledColorEnd;
......@@ -172,7 +174,7 @@ namespace TSA_V.DeviceLibrary
}
}
int length = maxledIndex * 3;
int length =( maxledIndex+1) * 3;
byte[] lengthByte = IntToByteArr(length);
allData[12] = lengthByte[0];
allData[13] = lengthByte[1];
......@@ -208,12 +210,45 @@ namespace TSA_V.DeviceLibrary
}
return false;
}
private static string IntToStr(int temp)
{
int value = (int)temp;
string tempStr = String.Format("{0:X}", (int)temp);
if (temp < 0)
{
uint v = (uint)(value & 0xFFFF);
tempStr = String.Format("{0:X}", v);
}
return tempStr;
}
/// <summary>
/// 打包方法,可以将十六制字符串转成byte[] ,字符串没有空格
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static byte[] StringToByte(string s)
{
string temps = s;
if (temps.Length % 2 != 0)
{
temps = "0" + temps;
}
byte[] tempb = new byte[50];
int j = 0;
for (int i = 0; i < temps.Length; i = i + 2, j++)
{
tempb[j] = Convert.ToByte(temps.Substring(i, 2), 16);
}
byte[] send = new byte[j];
Array.Copy(tempb, send, j);
return send;
}
private byte[] IntToByteArr(int value)
{
int number = 42; // 要转换的数字
//int number = 42; // 要转换的数字
byte b1 = (byte)(number >> 8); // 取高8位
byte b2 = (byte)(number & 0xFF); // 取低8位
byte b1 = (byte)(value >> 8); // 取高8位
byte b2 = (byte)(value & 0xFF); // 取低8位
byte[] bytes = new byte[] { b1, b2 }; // 存储转换后的byte数组
return bytes;
......@@ -289,13 +324,14 @@ namespace TSA_V.DeviceLibrary
byte[] recv = new byte[512];
try
{
debuglog("sendData:" + byteToHexStr(buff, " "));
_serialPort.Write(buff, 0, buff.Length);
Thread.Sleep(20);
Thread.Sleep(80);
int r = _serialPort.Read(recv, 0, recv.Length);
if (r > 0)
{
var recvdata = Encoding.ASCII.GetString(recv, 0, r);
var recvdata = byteToHexStr(recv, " ");
debuglog("recvdata: " + recvdata);
return recv.Take(r).ToArray();//.Split(',');
}
......@@ -319,6 +355,18 @@ namespace TSA_V.DeviceLibrary
return new byte[0];
}
}
public static string byteToHexStr(byte[] bytes, string spilChar)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < bytes.Length; i++)
{
returnStr += bytes[i].ToString("X2") + spilChar;
}
}
return returnStr;
}
void log(string msg)
{
loge.Info(Name + $"[{comPortName}]" + ":" + msg);
......@@ -331,11 +379,16 @@ namespace TSA_V.DeviceLibrary
}
static class CommandByte
{
//GBR
//DD 55 EE 00 00 00 01 00 99 02 00 00 00 03 00 6F FF 00 00 AA BB
//DD 55 EE 00 00 00 00 00 99 01 00 00 00 03 00 08 50 00 00 AABB
public static byte[] GetDeviceID = ConvertStringToByteArray("DD 55 EE 00 00 00 00 00 8F 01 00 00 00 03 00 01 00 00 00 AA BB");
public static byte[] SetOneColor = ConvertStringToByteArray("DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 C9 FF 00 00 AA BB");
public static byte[] GetDeviceID = ConvertStringToByteArray("DD 55 EE 00 00 00 00 00 8F 02 00 00 00 03 00 01 00 00 00 AA BB");
// DD55EE0000000000990100000003006F500000AABB
public static byte[] SetOneColor = ConvertStringToByteArray("DD 55 EE 00 00 00 01 00 99 02 00 00 00 03 00 6F FF 00 00 AA BB");
//12,13 为数据数量
public static byte[] ledColorStart = ConvertStringToByteArray("DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 01 ");
public static byte[] ledColorStart = ConvertStringToByteArray("DD 55 EE 00 00 00 00 00 99 01 00 00 00 03 00 01 ");
public static byte[] ledColorEnd = ConvertStringToByteArray("AA BB");
// DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 C9 F0 F0 F0 AA BB
//DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 C9 F0 F0 F0 AA BB
......
......@@ -138,6 +138,7 @@ namespace TSA_V.DeviceLibrary
serverCommunication = new ServerCommunication();
serverCommunication.StartConnectServer();
RgbLedController.Init();
HVideoManager.StartRun();
return "";
}
......
......@@ -122,7 +122,7 @@ namespace TSA_V
{
if (e.Data.EndsWith("200"))
{
LogUtil.debug("pyLog: " + e.Data);
//LogUtil.debug("pyLog: " + e.Data);
}
else
{
......
......@@ -243,14 +243,14 @@ namespace TSA_V
this.timerChangeImg.Interval = 1000;
this.timerChangeImg.Tick += new System.EventHandler(this.timerChangeImg_Tick);
//
// FrmAOICheckN
// FrmAOICheck
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(1251, 778);
this.Controls.Add(this.panel1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "FrmAOICheckN";
this.Name = "FrmAOICheck";
this.Text = "AOI检测";
this.Load += new System.EventHandler(this.FrmCamera_Load);
this.Shown += new System.EventHandler(this.FrmCameraAOI_Shown);
......
20240401

20240909
增加RGBLED 库位,库位表配置格式如下:类型=3,灯索引#号分割。
20_16,116,3,COM3,15,6#7#8#9#17,
超级配置中:RGBLed_PortName 配置灯带的端口号。
20240401
新分支,修改离线编程。
增加手势识别功能。
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!