mirror of
https://github.com/jwetzell/q-sys-plugin-kramer-3000.git
synced 2026-09-02 04:38:59 +00:00
ROUTE command working
Route command working with information collection on initial connection
This commit is contained in:
+93
-82
@@ -28,8 +28,10 @@ local Colors = {
|
|||||||
LCD = { 0x02, 0x33, 0xb2 }
|
LCD = { 0x02, 0x33, 0xb2 }
|
||||||
}
|
}
|
||||||
|
|
||||||
input_count = 8
|
input_count = 6
|
||||||
output_count = 4
|
output_count = 2
|
||||||
|
ip_address = '192.168.1.39'
|
||||||
|
|
||||||
-- We can let users determine some of the plugin properties by exposing them here
|
-- We can let users determine some of the plugin properties by exposing them here
|
||||||
-- While this function can be very useful, it is completely optional and not always needed.
|
-- While this function can be very useful, it is completely optional and not always needed.
|
||||||
-- If no Properties are set here, only the position and fill properties of your plugin will show in the Properties pane
|
-- If no Properties are set here, only the position and fill properties of your plugin will show in the Properties pane
|
||||||
@@ -38,21 +40,21 @@ function GetProperties()
|
|||||||
{
|
{
|
||||||
Name = "IP Address",
|
Name = "IP Address",
|
||||||
Type = "string",
|
Type = "string",
|
||||||
Value = "127.0.0.1"
|
Value = "192.168.1.39"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = 'Input Count',
|
Name = 'Input Count',
|
||||||
Type = 'integer',
|
Type = 'integer',
|
||||||
Min = 2,
|
Min = 2,
|
||||||
Max = 127,
|
Max = 127,
|
||||||
Value = 8
|
Value = 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = 'Output Count',
|
Name = 'Output Count',
|
||||||
Type = 'integer',
|
Type = 'integer',
|
||||||
Min = 1,
|
Min = 1,
|
||||||
Max = 127,
|
Max = 127,
|
||||||
Value = 4
|
Value = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return props
|
return props
|
||||||
@@ -70,6 +72,7 @@ function GetControls(props)
|
|||||||
|
|
||||||
input_count = props['Input Count'].Value
|
input_count = props['Input Count'].Value
|
||||||
output_count = props['Output Count'].Value
|
output_count = props['Output Count'].Value
|
||||||
|
ip_address = props['IP Address'].Value
|
||||||
|
|
||||||
local controls = {
|
local controls = {
|
||||||
{
|
{
|
||||||
@@ -82,7 +85,7 @@ function GetControls(props)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i = 0, output_count do
|
for i = 0, output_count do
|
||||||
for s = 0, input_count do
|
for s = 1, input_count do
|
||||||
table.insert(
|
table.insert(
|
||||||
controls,
|
controls,
|
||||||
{
|
{
|
||||||
@@ -153,36 +156,20 @@ function GetControlLayout(props)
|
|||||||
}
|
}
|
||||||
|
|
||||||
elseif(page == 'Video Matrix') then
|
elseif(page == 'Video Matrix') then
|
||||||
for i = 0, input_count do
|
for i = 1, input_count do
|
||||||
if (i == 0) then
|
table.insert(
|
||||||
table.insert(
|
graphics,
|
||||||
graphics,
|
{
|
||||||
{
|
Type = "Text",
|
||||||
Type = "Text",
|
Text = "In " .. i,
|
||||||
Text = "No In",
|
Color = Colors.Black,
|
||||||
Color = Colors.Black,
|
Position = {
|
||||||
Position = {
|
(0 + 0),
|
||||||
(0 + 0),
|
(0 + (1.5 * 24)) + (i * 24)
|
||||||
(0 + (1.5 * 24)) + (i * 24)
|
},
|
||||||
},
|
Size = {32,24}
|
||||||
Size = {32,24}
|
}
|
||||||
}
|
)
|
||||||
)
|
|
||||||
else
|
|
||||||
table.insert(
|
|
||||||
graphics,
|
|
||||||
{
|
|
||||||
Type = "Text",
|
|
||||||
Text = "In " .. i,
|
|
||||||
Color = Colors.Black,
|
|
||||||
Position = {
|
|
||||||
(0 + 0),
|
|
||||||
(0 + (1.5 * 24)) + (i * 24)
|
|
||||||
},
|
|
||||||
Size = {32,24}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 0, output_count do
|
for i = 0, output_count do
|
||||||
@@ -231,6 +218,12 @@ function GetControlLayout(props)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (Controls) then
|
if (Controls) then
|
||||||
|
|
||||||
|
input_count = Properties['Input Count'].Value
|
||||||
|
output_count = Properties['Output Count'].Value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local Kramer = {
|
local Kramer = {
|
||||||
socket = TcpSocket.New(),
|
socket = TcpSocket.New(),
|
||||||
setStatus = function (value, msg)
|
setStatus = function (value, msg)
|
||||||
@@ -253,12 +246,12 @@ if (Controls) then
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetCmdString(bytes)
|
function Split(s, delimiter)
|
||||||
local cmd = ""
|
local result = {};
|
||||||
for k,v in pairs(bytes) do
|
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
|
||||||
cmd = cmd .. string.pack("B", v)
|
table.insert(result, match);
|
||||||
end
|
end
|
||||||
return cmd
|
return result;
|
||||||
end
|
end
|
||||||
|
|
||||||
function SendCommand(cmd)
|
function SendCommand(cmd)
|
||||||
@@ -267,31 +260,59 @@ if (Controls) then
|
|||||||
else
|
else
|
||||||
print("Following would have been sent if Kramer was connected")
|
print("Following would have been sent if Kramer was connected")
|
||||||
end;
|
end;
|
||||||
print(hex_dump(GetCmdString(cmd)))
|
print('Sent: ' .. cmd)
|
||||||
if Kramer.socket.IsConnected then
|
if Kramer.socket.IsConnected then
|
||||||
Kramer.socket:Write(GetCmdString(cmd))
|
Kramer.socket:Write(cmd..'\x0d')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Instruction ROUTE
|
--Instruction ROUTE
|
||||||
|
|
||||||
local function ROUTE_GET(layer, dest)
|
local function ROUTE_GET(layer, dest)
|
||||||
local command = "#ROUTE? " .. layer .. dest
|
local command = "#ROUTE? " .. layer ..','..dest
|
||||||
SendCommand(command)
|
SendCommand(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ROUTE_SET(layer, dest, src, state)
|
local function ROUTE_SET(layer, dest, src, state)
|
||||||
if(state == 0) then
|
if(state == 0) then
|
||||||
src = "x"
|
dest = "x"
|
||||||
print("Disconnecting layer" .. layer .. " src from dest " .. dest)
|
print("Disconnecting layer " .. layer .. " src from dest " .. dest)
|
||||||
else
|
else
|
||||||
print("Send layer " .. layer .. "from src " .. src .. " to dest " .. dest)
|
print("Send layer " .. layer .. " from src " .. src .. " to dest " .. dest)
|
||||||
end
|
end
|
||||||
|
|
||||||
local command = "#ROUTE " .. layer .. dest .. src
|
if dest == 0 then
|
||||||
|
dest = '*'
|
||||||
|
end
|
||||||
|
|
||||||
|
local command = "#ROUTE " .. layer ..','.. dest ..','.. src
|
||||||
SendCommand(command)
|
SendCommand(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function ROUTE_PARSE(msg)
|
||||||
|
if string.find(msg,'ERR') then
|
||||||
|
print('ROUTE message has returned an ERR: ' .. msg)
|
||||||
|
else
|
||||||
|
local msg_parts = Split(msg,' ')
|
||||||
|
local route_info = Split(msg_parts[2],',')
|
||||||
|
local layer = route_info[1]
|
||||||
|
local dest = route_info[2]
|
||||||
|
local src = tonumber(route_info[3])
|
||||||
|
|
||||||
|
if layer == '1' then
|
||||||
|
for input = 1, input_count do
|
||||||
|
if (input ~= src) then
|
||||||
|
-- unselect every other source
|
||||||
|
Controls["vid-input_" .. input .. "-output_" .. dest].Value = 0
|
||||||
|
else
|
||||||
|
-- select the patched source
|
||||||
|
Controls["vid-input_" .. input .. "-output_" .. dest].Value = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function hex_dump (str)
|
function hex_dump (str)
|
||||||
local len = string.len( str )
|
local len = string.len( str )
|
||||||
local dump = ""
|
local dump = ""
|
||||||
@@ -327,12 +348,13 @@ if (Controls) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
Kramer.socket.Data = function ()
|
Kramer.socket.Data = function ()
|
||||||
print("Reading " .. Kramer.socket.BufferLength .. " Bytes")
|
|
||||||
local data = Kramer.socket:Read(Kramer.socket.BufferLength);
|
local data = Kramer.socket:Read(Kramer.socket.BufferLength);
|
||||||
print("Raw")
|
if string.find(data, 'ROUTE') then
|
||||||
print(data)
|
print('Received ROUTE response: ' .. data)
|
||||||
print("Hex")
|
ROUTE_PARSE(data)
|
||||||
print(hex_dump(data))
|
else
|
||||||
|
print('Unhandled Response: ' .. data)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Kramer.socket.Closed = function()
|
Kramer.socket.Closed = function()
|
||||||
@@ -348,37 +370,26 @@ if (Controls) then
|
|||||||
Kramer.setStatus(2,"Timeout in connection to Kramer")
|
Kramer.setStatus(2,"Timeout in connection to Kramer")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for o = 0, output_count do
|
if(output_count > 0 and input_count > 0) then
|
||||||
for i = 0, input_count do
|
|
||||||
Controls["vid-input_" .. i .. "-output_" .. o].EventHandler = function()
|
|
||||||
if(o == 0) then
|
|
||||||
for output = 1, output_count do
|
|
||||||
Controls["vid-input_"..i.."-output_"..output].Value = 0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Controls["vid-input_"..i.."-output_0"].Value = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
for input = 0, input_count do
|
|
||||||
if (input ~= i) then
|
|
||||||
Controls["vid-input_"..input.."-output_"..o].Value = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ROUTE_SET(Kramer.Layers.Video,i,o,Controls["vid-input_" .. i .. "-output_" .. o].Value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if(Properties['IP Address'].Value ~= '') then
|
|
||||||
Kramer.setStatus(5, 'Connecting to Kramer');
|
|
||||||
Kramer.socket:Connect(Properties['IP Address'].Value, 5000);
|
|
||||||
else
|
|
||||||
-- disable all video matrix inputs
|
|
||||||
for o = 0, output_count do
|
for o = 0, output_count do
|
||||||
for i = 0, input_count do
|
for i = 1, input_count do
|
||||||
Controls["vid-input_" .. i .. "-output_" .. o].IsDisabled = true;
|
Controls["vid-input_" .. i .. "-output_" .. o].EventHandler = function()
|
||||||
|
ROUTE_SET(Kramer.Layers.Video,o,i,Controls["vid-input_" .. i .. "-output_" .. o].Value)
|
||||||
|
if(o == 0) then
|
||||||
|
-- let the individual output buttons track state
|
||||||
|
Controls["vid-input_" .. i .. "-output_" .. o].Value = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
if(Properties["IP Address"].Value ~= '') then
|
||||||
|
ip_address = Properties["IP Address"].Value
|
||||||
|
Kramer.setStatus(5, 'Connecting to Kramer @ ' .. ip_address);
|
||||||
|
Kramer.socket:Connect(ip_address, 5000);
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user