Object value is changed before setting it in Unreal Engine 4.27.2 - unreal-engine4

I'm verifying the value of a Text object in Unreal then setting the value after the branch node. However the value is changed before. I managed to isolate the issue and reproduce the bug in that small blueprint (The execution before is just the BeginPlay event attaching the debug interface then leading up here):
The results in the Direction Trace output (Small function that displays the value requested) is always "Up" and the Actual Content shows "New Value".
However, Direction will be "Down" and Actual Content will show the correct original value ("Hazard 3") if I remove the last node that sets "Short Difficulty Name".
Furthermore, if I compare the original value with a random integer like so:
Direction will show "Down" while "Actual Content" still shows "New Value"
I really don't get it, tried copying the value of the Text instead in case it was a pointer issue, reading online if the Branch node or pure functions had a delay, comparing Text instead of String..

I ended up fixing the issue by adding a 0.0001s delay after reading variable and before writing anything, then the values were correct.

Related

Cimplicity Screen - one object/button that is dependent on hundreds of points

So I have created a huge screen that essentially just shows the robot status for every robot in this factory (individually)… At the very end of the project, they decided they want one object on the screen that blinks if any of the 300 robots fault. I am trying to think of a way to make this work. Maybe a global script of some kind? Problem is, I do not do much scripting in Cimplicity, so any help is appreciated.
All the points that are currently used on this screen (to indicate a fault) have very similar names… as in, the beginning is the same… so I was thinking of a script that could maybe recognize if a bit is high based on PART of it's string name characteristic. The end will change a little each time, but I am sure there is a way to only look for part of a string and negate the rest. If the end has to be hard coded, that's fine.
You can use a Python script in Cimplicity.
I will not go into detail on the use of python in Cimplicity, which is well described in the documentation indicated above.
Here's an example of what can be done... note that I don't have a way to test it and, of course, this will work if the name of your robots in the declaration follows the format Robot_1, Robot_2, Robot_3 ... Robot_10 ... Robot_300 and it also depends on the Name and the Type of the fault variable... as you didn't define it, I imagine it can be an integer, with ZERO indicating no error. But if you use something other than that, you can easily change it.
import cimplicity
(...)
OneRobotWithFault = False
# Here you get the values and check for fault
for i in range(0, 300):
pointName = f'MyFactory.Robot_{i}.FaultCode'
robotFaultCode = cimplicity.point_get(pointName)
if robotFaultCode > 0:
OneRobotWithFault = True
break
# Set the status to the variable "WeHaveRobotWithFault"
cimplicity.point_set("WeHaveRobotWithFault", OneRobotWithFault)

Trying to use dynamic and action parameters

recently I stumbled upon one of the videos of Benjamin Schumann titled: What are dynamic and action parameters and when should you use them in your AnyLogic model.
I tried to further adjust the functions of dynamic and action based parameters for a problem of mine. Just to give a heads up, I am fairly new to Anylogic (only worked through that one book, and some minor projects and tutorials) and been decent in Java (been a few years since I've been actively working in Java but currentlystarting to get back in [still rusty]).
Regarding my actual problem, in the video Mr. Schumann has an agent with three parameters. One static, one dynamic and one action. In addition to that he has a variable (double) all set in his agent. On his main is a button to increment the value of the variable with the help of the parameters and to trace the lines in the console (= giving out a string if a certain threshold of the variable is passed).
I created a similar setting, however I happen to run into a lot of variable errors during time to time while compiling.
Here some example code snippets:
dynamic parameter p_Station of the type String
v_myFahrt < 222 ? "Wiesbaden Hbf" :
v_myFahrt < 442 ? "Wiesbaden-Biebrich Bahnhof Wiesbaden Ost" :
v_myFahrt < 663 ? "Wiesbaden-Mainz-Kastel Bahnhof" :
"Hochheim (Main) Bahnhof"
therefore my variable is called v_myFahrt, a double with the initial value of 0
action parameter p_durchFahrt with the default action:
v_myFahrt = v_myFahrt + 220;
and my Button on the main:
myAgent.p_durchFahrt();
traceln(myAgent.p_Station());
So basically it is a somewhat similar code as in the reference. I tried to than add another instance of the agent with a different set of "code" for the dynamic parameter (different Strings and values) as well as a different "code" for the action parameter (e.g. + 208 instead of + 220). To then wanting to trace the lines in the console with the button again.
I tried to add
myAgent1.p_durchFahrt(); traceln(myAgent1.p_Station());
to it.
But before I coul even run it, I keep getting the error "v_myFahrt cannot be resolved to a variable" for myAgent1. Inspecting the error it keeps referring to myAgent1 with the newly added code for p_Station and I can't seem to find a way around it.
What am I doing majorly wrong here?
it looks like you have created v_myFahrt in main, right? (that would explain your symptoms).
If yes, you should create it in MyAgent instead.

Trouble with VB6 form location (top,left) and value type (i.e., integer)

VB6 will REPORT a LEFT location greater than max integer when the form is in an auxiliary screen. However, I cannot assign that value as a LEFT specification.
I manually drag frmSecondary to the secondary monitor (located to the right of my primary monitor).
I click a button within frmSecondary in order to write the value of frmSeconday.Left to a file. It writes 49950.
I close the program, then re-open.
I read the value from the file (and the value IS 49950).
I try to programmatically assign that value to frmSecondary.Left
Failure (works OK if the value is less than "largest integer").
Expected result: I should be able to assign the value that was written to file. Better yet, any ideas of how to programmatically place frmSecondary at it's "proper" location on the secondary monitor?
I simply read the value from file:
Input #fnum, frmSecondary.left
I've tried, without success:
Dim lft as variant
Input #fnum, lft
frmSecondary.left = lft
I have confirmed that the value being read from file is, in fact, 49950. I do this confirmation two ways...one is by looking at the file; the second is by putting a "stop" in the program and showing the value of lft.
TOTAL NONSENSE
Ignore this entire post. I just discovered my error -- it's so embarrassing, I don't even want to describe it. Nothing quite like spending an entire afternoon (to say nothing of YOUR time) chasing garbage.

Grafana: No value to text mapping

Like you can see in the following screenshot I am trying to map "no value" to text. What I want to achieve is that in the case of "no value" the text "offline" gets displayed. My guess is that "no value" is not the right parameter to map with, but I have no idea whats the right one. I also tryed NaN which doesnt work to.
I would be really happy if someone can point me to the right value here!
Try null instead of no value.
Also, for your 2nd mapping, you could use range to text. You could use range to text for both your mappings actually..
null - null => offline
1 - 1000 => online
You might need to save dashboard and refresh it to see changes. It did not update for me without a refresh (using an older version though).

Requesting member of node_element results in "undefined"

I'm using Opa for a school project in which there has to be some synchronization of a textfield between several users. The easy way to solve this, is to transmit the complete field whenever there is a change performed by one of the users. The better way is of course to only transmit the changes.
My idea was to use the caret position in the textfield. As a user types, one can get the last typed character based on the caret position (simply the character before the caret). A DOM element has an easy-to-use field for this called selectionStart. I have this small Javascript for this:
document.getElementById('content').selectionStart
which correctly returns 5 if the caret stands at the fifth character in the field. In Opa, I cannot use selectionStart on either a DOM or a dom_element so I thought I'd write a small plugin. The result is this:
##extern-type dom_element
##register jsGetCaretPosition: dom_element -> int
##args(node)
{
return node.selectionStart;
}
This compiles with the opp-builder without any problem and when I put this small line of code in my Opa script:
#pos = %%caret.jsGetCaretPosition%%(Dom.of_selection(Dom.select_id("content")));
that also compiles without problems. However, when I run the script, it always returns "undefined" and I have no idea what I'm doing wrong. I've looked in the API and Dom.of_selection(Dom.select_id("content")) looked like the correct way to get the corresponding dom_element typed data to give to the plugin. The fact that the plugin returns "undefined" seems to suggest that the selected element does not know the member "selectionStart" eventhough my testcode in Javascript suggest otherwise. Anyone can help?
In Opa dom_element are the results of jQuery selection (i.e. an array of dom nodes). So if I well understood your program you should write something like node[0].selectionStart instead of node.selectionStart.
Moreover you should take care of empty selection and selection which doesn't contains textarea node (without selectionStart property). Perhaps the right code is tmp == undefined ? -1 : tmp = node[0].selectionStart == undefined ? -1 : tmp