private void SendArtPoll() { ArtPollPacket packet = new ArtPollPacket(); packet.TalkToMe = 6; socket.Send(packet); }
// We send RGB values (1 byte/channel) via Art-Net. private static void SendArtNet(Object source, ElapsedEventArgs e) { ArtNetDmxPacket toSend = new ArtNetDmxPacket(); Random rnd = new Random(); toSend.DmxData = new byte[SENDER_LENGTH]; for (uint universe = 0; universe < SENDER_UNIVERSES; universe++) { toSend.Universe = (short)universe; for (uint i = 0; i < SENDER_LENGTH; i++) { if (i % 2 == 0) { var phase = 2 * Math.PI * i / SENDER_LENGTH; // radians uint redValue = (uint)(Math.Cos(DateTime.Now.Millisecond + phase) * 255.0); // add phase based on i index toSend.DmxData[i] = (byte)redValue; //(byte)rnd.Next(0, 255); } else { toSend.DmxData[i] = 0; } } s_artnet.Send(toSend); Console.WriteLine("Sending [" + toSend.DmxData.Length + "] Art-Net values data on universe [" + toSend.Universe + "]"); } }
public void SendArtNetToJinx() { var packet = new ArtNetDmxPacket(); packet.Universe = 10; packet.DmxData = _dmxData; artnet.Send(packet, jinxIP); }
private void OnReceivePollPacket(object sender, NewPacketEventArgs <ArtNetPacket> e) { newPacket = true; if (e.Packet.OpCode == ArtNet.Enums.ArtNetOpCodes.Poll) { artnet.Send(pollReplayPacket); Debug.Log("Received --- Poll Command: " + e.Source.ToString()); } }
public void SendFrame() { var packet = new ArtNetDmxPacket(); packet.Universe = 0; byte[] _dmxData = new byte[510]; packet.DmxData = _dmxData; int x = 0, y = 0; // First packet goes from 0 to 509 (for now) for (var i = 0; i < 509; i += 3) { packet.DmxData[i] = (byte)(((int)baseFloor[x, y].R * (int)(255 - floorAlpha[x, y]) / 256) + ((int)floor[x, y].R * (int)floorAlpha[x, y] / 256)); packet.DmxData[i + 1] = (byte)(((int)baseFloor[x, y].G * (int)(255 - floorAlpha[x, y]) / 256) + ((int)floor[x, y].G * (int)floorAlpha[x, y] / 256)); packet.DmxData[i + 2] = (byte)(((int)baseFloor[x, y].B * (int)(255 - floorAlpha[x, y]) / 256) + ((int)floor[x, y].B * (int)floorAlpha[x, y] / 256)); //packet.DmxData[i] = floor[x, y].R; //packet.DmxData[i + 1] = floor[x, y].G; //packet.DmxData[i + 2] = floor[x, y].B; x++; if (x > 15) { x = 0; y++; } } ; artnet.Send(packet, floorIP); //Thread.Sleep(100); packet = new ArtNetDmxPacket(); packet.Universe = 1; _dmxData = new byte[258]; packet.DmxData = _dmxData; // Second packet, starts where first one left off. for (var i = 0; i < 257; i += 3) { packet.DmxData[i] = (byte)(((int)baseFloor[x, y].R * (int)(255 - floorAlpha[x, y]) / 256) + ((int)floor[x, y].R * (int)floorAlpha[x, y] / 256)); packet.DmxData[i + 1] = (byte)(((int)baseFloor[x, y].G * (int)(255 - floorAlpha[x, y]) / 256) + ((int)floor[x, y].G * (int)floorAlpha[x, y] / 256)); packet.DmxData[i + 2] = (byte)(((int)baseFloor[x, y].B * (int)(255 - floorAlpha[x, y]) / 256) + ((int)floor[x, y].B * (int)floorAlpha[x, y] / 256)); x++; if (x > 15) { x = 0; y++; } if (y > 15) { break; } } ; artnet.Send(packet, floorIP); }
public void Send() { if (useBroadcast && isServer) { artnet.Send(dmxToSend); } else { artnet.Send(dmxToSend, remote); } }
void Start() { // 初始化 ArtNet socket artnet = new ArtNetSocket(); dmxDataMap = new Dictionary <int, Dictionary <int, byte[]> >(); dmxToSend.DmxData = new byte[512]; // 为事件绑定函数 artnet.NewPacket += OnReceiveDmxPacket; artnet.NewPacket += OnReceivePollPacket; // 如果该 Controller 为 Server 端,那么看是监听接受数据 if (isServer) { // 如果设定了子网掩码,就可以指定给哪个网段发送数据 //artnet.Open(GetLocalIP(), new IPAddress(new byte[] { 255, 0, 0, 0 })); artnet.Open(GetLocalIP(), null); } // 如果不使用广播模式发送 或者 该 Controller 不接受数据 if (!useBroadcast || !isServer) { remote = new IPEndPoint(FindFromHostName(remoteIP), ArtNetSocket.Port); } artnet.Send(pollReplayPacket); }
public void OnChange() { for (int i = 0; i < 8; i++) { var dmxPacket = new ArtDmx { ProtVerHi = 6, ProtVerLo = 9, Sequence = 0x00, Physical = 0, SubUni = 0, Net = 0, LengthHi = 0, LengthLo = 0, Data = new byte[512] }; dmxPacket.Length = 512; dmxPacket.Universe = i; for (int j = 0; j < 58; j++) { dmxPacket.Data[j * 4] = (byte)Color.R; dmxPacket.Data[j * 4 + 1] = (byte)Color.G; dmxPacket.Data[j * 4 + 2] = (byte)Color.B; dmxPacket.Data[j * 4 + 3] = (byte)Color.W; } socket.Send(dmxPacket); } }
public void Send() { if (remote == null) { return; } foreach (ArtNetDmxPacket myPacket in myPackets) { if (useBroadcast && isServer) { artnet.Send(myPacket); } else { artnet.Send(myPacket, remote); } } }
public override void Send(byte[] dmxData) { if (m_Sender != null && m_Sender.PortOpen) { var artNetPacket = new ArtNetDmxPacket { Universe = ArtNetUniverse, DmxData = dmxData }; m_Sender.Send(artNetPacket, IPAddress.Parse(RemoteIP)); } }
public static void SendPacketOverArtNet() { if (config.ArtNetEnabled && artNet.IsBound) { for (short i = 0; i < healthBars.Count; i++) { ArtNetDmxPacket packet = new ArtNetDmxPacket(); packet.Universe = (short)i; byte[] stripBytes = healthBars.GetStrip(i).GetAsBytes(); packet.DmxData = new byte[stripBytes.Length]; if (stripBytes.Length > 0) { Buffer.BlockCopy(stripBytes, 0, packet.DmxData, 0, stripBytes.Length); artNet.Send(packet); } } } }