Controlling a UDR-N50A w/WidgetDesigner

Christie Widget Designer Version 6 - Q&A

Moderator: Moderator Group

Forum rules
When asking make sure to include the operating system and the revision of Widget Designer you are using.

Controlling a UDR-N50A w/WidgetDesigner

Postby madmod42 » Tue Sep 21, 2021 7:10 am

Hello!

So recently I have been asked to install Widget Designer into a large hall and will be controlling a UDR-N50A player and a Barco S3 as well as some lighting that would be in there.
Now with the S3 and the lighting it isn't that big of an issue and I have worked with some of them before. The issue now is with the player as the commands for it are not listed online, I through a means of WireShark and another program was able to monitor what commands they are currently using to run the player.
Now I am trying to figure out what would be the best way to bring this into Widget Designer.

The program currently is set up as follows:
-----------------------------------
using System;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;

namespace LEDControl.Properties
{
internal class UDR50AController
{
private string _selectedContent;
private string _host = "192.168.11.20";
private int _port = 65000;
private TcpClient _tcp;
private NetworkStream _stream;
private string controllCommandSingleUDRN50A = "UDRN50A 6 :open 1";
private string controllCommandMultiUDRN50A = "UDRN50A 7 :open 15";

public UDR50AController(string selectedContent)
{
string str = selectedContent;
if (!(str == "1"))
{
if (!(str == "2"))
{
if (!(str == "3"))
{
if (!(str == "4"))
{
if (str == "END")
this._selectedContent = "4";
}
else
this._selectedContent = "3";
}
else
this._selectedContent = "2";
}
else
this._selectedContent = "1";
}
else
this._selectedContent = "0";
this._tcp = new TcpClient(this._host, this._port);
this._stream = this._tcp.GetStream();
}

public bool ChangeContent()
{
this.sendRequestToUDR50A(this.controllCommandMultiUDRN50A);
this.sendRequestToUDR50A("UDRN50A 4 :STOP");
Thread.Sleep(300);
this.sendRequestToUDR50A("UDRN50A 10 :FCLOSE ALL");
return this.openFolder();
}

private bool openFolder()
{
byte[] bytes = Encoding.UTF8.GetBytes("UDRN50A 9 :FOPEN 0 " + this._selectedContent);
this._stream.Write(bytes, 0, bytes.Length);
MemoryStream memoryStream = new MemoryStream();
byte[] buffer = new byte[256];
do
{
int count = this._stream.Read(buffer, 0, buffer.Length);
if (count != 0)
memoryStream.Write(buffer, 0, count);
else
break;
}
while (this._stream.DataAvailable);
string str = Encoding.UTF8.GetString(memoryStream.GetBuffer(), 0, (int) memoryStream.Length);
memoryStream.Close();
if (!str.Contains("NG"))
return true;
int num = (int) MessageBox.Show("選択されたにボタンにコンテンツがありません。" + Environment.NewLine + "別のボタンを選択してください。");
return false;
}

public void playContent()
{
string str = "play 0 " + (int.Parse(this.getContentFrame()) - 1).ToString() + " L";
switch (str.Length.ToString().Length)
{
case 1:
this.sendRequestToUDR50A("UDRN50A " + str.Length.ToString() + " :" + str);
break;
case 2:
this.sendRequestToUDR50A("UDRN50A " + str.Length.ToString() + " :" + str);
break;
case 3:
this.sendRequestToUDR50A("UDRN50A " + str.Length.ToString() + " :" + str);
break;
case 4:
this.sendRequestToUDR50A("UDRN50A " + str.Length.ToString() + " :" + str);
break;
case 5:
this.sendRequestToUDR50A("UDRN50A " + str.Length.ToString() + " :" + str);
break;
default:
this.sendRequestToUDR50A("UDRN50A 4 :play");
break;
}
}

private string getContentFrame()
{
byte[] bytes = Encoding.UTF8.GetBytes("UDRN50A 5 :frame");
this._stream.Write(bytes, 0, bytes.Length);
MemoryStream memoryStream = new MemoryStream();
byte[] buffer = new byte[256];
do
{
int count = this._stream.Read(buffer, 0, buffer.Length);
if (count != 0)
memoryStream.Write(buffer, 0, count);
else
break;
}
while (this._stream.DataAvailable);
string input = Encoding.UTF8.GetString(memoryStream.GetBuffer(), 0, (int) memoryStream.Length);
memoryStream.Close();
return Regex.Split(input, "\\s+")[8];
}

private void sendRequestToUDR50A(string sendingMessage)
{
byte[] bytes = Encoding.UTF8.GetBytes(sendingMessage);
this._stream.Write(bytes, 0, bytes.Length);
MemoryStream memoryStream = new MemoryStream();
byte[] buffer = new byte[256];
do
{
int count = this._stream.Read(buffer, 0, buffer.Length);
if (count != 0)
memoryStream.Write(buffer, 0, count);
else
break;
}
while (this._stream.DataAvailable);
Encoding.UTF8.GetString(memoryStream.GetBuffer(), 0, (int) memoryStream.Length);
memoryStream.Close();
}

public void closeStream()
{
this._stream.Close();
this._tcp.Close();
}
}
}
--------------------------------------
So I am wondering what would be the best way of representing this into Widget Designer?
1) Pop all this info into a macro and break everything up into variables?
2) Just focus on the commands and put them into each individual button while making variables for specific portions of it?

More than anything I am looking for advice so that once the installation is complete I am not going to and from it to fix an issue from my program that may arise so any advice people can give me is very much appreciated!

Best,
Dakota
madmod42
 
Posts: 12
Joined: Thu Mar 12, 2020 4:40 am
Location: Tokyo, Japan

Return to Widget Designer V6

Who is online

Users browsing this forum: No registered users and 13 guests

cron