[ANSWERED] Extracting integer from TCP message / TCP In Watcher - Text / Dataton Watchout getStatus
-
I am using the TCP In Watcher - Text actor to receive a getStatusreply message from Dataton Watchout via TCP/IP control. My goal is to get the current timeline position in milliseconds as an integer, then perform simple arithmetic on that integer in order to scrub through the Watchout timeline using the Streamdeck+ rotary encoders and Bitfocus Companion.
I have successfully received the message using the following Parsing Pattern:msg:string={00-FF}
This is the getStatusreply message I am receiving from Watchout:
Reply "test" false 0 true true false 86398999 true 0 false 21921314
What I want to do is extract "86398999" from the message so that I can manipulate it as an integer. This value represents the current timeline position in milliseconds, which ranges from a single digit (0) up to eight digits (86398999). Do I do this inside the TCP In Watchout - Text actor's Parsing Pattern or a different actor?
I've read the Decoding and Extracting Data Input Streams document, but I'm a bit lost on how to reach my goal.
Here are the parameters of the getStatusreply from Watchout:<string> Filename - 1 to 256 characters
<bool> Busy - 4 or 5 characters
<uint> Health - 1 character
<bool> Full Screen - 4 or 5 characters
<bool> Show Active - 4 or 5 characters
<bool> Online - 4 or 5 characters
<uint> Current Time - 1 to 8 characters
<bool> Show is playing – 4 or 5 characters
[<float>] Timeline rate - 1 character
<bool> Standby - 4 or 5 characters -
assuming the format of the String you receive always has the same number of segments (delimited by spaces), the following Javascript should work nicely for you.
It takes the string, splits it into an array of segments based on the space delimiter, then parses the selected segment into base 10 integer.// iz_input 1 "target [0 based]" // iz_input 2 "watchout reply" // iz_output 1 "targetSegment" function main() { var target = arguments[0]; var segments = arguments[1].split(' '); var targetSegment = parseInt(segments[target], 10); return targetSegment; }
You should be able to paste this into a Javascript actor and feed your text to the second input.
The first input needs to be an INT that targets the correct segment (7 is what works for me with your test string).
NOTE: The Javascript actor has mutable input and outputs, so be sure to mutate them to the correct types. ( like to use Trigger Text, and Trigger Value actors to ensure they are locked to the right types before I connect other actors) -
@dusx This works perfectly! Thank you so much.
Is way to copy text to the system clipboard with Javascript? In Watchout you can copy and paste keyframes/tweens into a text editor and view the following text, edit it, and paste it back into Watchout. I'm hoping to have my common opacity fade times as buttons on the Streamdeck. I've tried a few things in Isadora with this code, but part of my roadblock is what actor to use and how to work with the special characters in the text and what actor to use. Below is an example of the text.Once I have that figured out, I want to add variables to change the keyframes from the actor input rather than editing the text directly each time I need to add a new fade time. I'll end up adapting this to all of the keyframe/tween types in Watchout.
Feel free to just point me in the right direction! I haven't written Javascript from scratch; I always edit things I find online, but would love to change that.UTF8 DATATON_DFC_DATA_590925_620721_AUC069 { "Structure and File Format (C) Copyright Dataton AB" 2022 1 "WATCHMAKER" 6 7 2 0 ObjTransferable ObjTransferable struct extends { TextTransferable struct extends { Transferable struct { } } { } } { mObjData list object true, mClassName string } { { // mObjData TweenPointTrack struct extends { TweenTrack struct extends { TweenParam struct { } } { mExpanded bool, mHeight int } } { mPoints list TweenPoint struct extends { TweenParam } { mTimePos float } true, mExpr reference TweenExpression struct { mExpr Expression struct { mItems list ExprItem struct { } true }, mExprY Expression, mExprZ Expression } false } { true, // mExpanded 0, // mHeight { // mPoints OpacityTweenPoint struct extends { _tween1DValue struct extends { _quadTweenPoint struct extends { TweenPoint } { mSmooth bool } } { mValue float } } { } { 0, false, 0 // mTimePos mSmooth mValue }, OpacityTweenPoint { 5, false, 1 } // mTimePos mSmooth mValue }, #0 // mExpr } }, "TweenParam" // mClassName } }
-
Unfortunately the text format provided by Watchout doesn't seem to be following any open standard. It would be great if it was JSON, is there by chance an option to get the data as JSON?
So there isn't anyway to copy the text to a system clip board with JavaScript in Isadora. The JavaScript actor is very fast using the V8 engine, but it is sandboxed, it can't connect outside of Isadora, and doesn't support any browser specific JavaScript functions, only the core JS specification.
If you can explain exactly what you are trying to accomplish. step by step, as far as data flow, I will think through your possible solutions.
-
@dusx I'm not surprised that it programmed in a bizarre fashion. That's all I got to work with. Here's to hoping Watchout 7 is a lot cleaner.
Makes total sense about the clipboard, it was wishful thinking. I'm also messing around with Vicreo listener and I see I could run a shell script so maybe there's a way still.
Ultimately, it's not that important - I've just been talking with programmers about fun ideas to make things faster and more interesting for us since we're stuck with what we have.