Follow/Highlight signal path after Simulation (Matlab Simulink) - path

I have a model which looks like this :
In Equipement2 block for example :
In ETAFON1 block for example :
In this example i have only put 2 variable "true" (to make equipement2 red) and i would like to know if it's possible to follow/highlight the path of the signals which started from "true" variable or to know why an equipement is red by following the signal in reverse direction at the end of the Simulation like a recap of the signal ?

Related

Segfault when using `lgi.Pango.AttrList.change` in AwesomeWM

Some context:
I am writing a font-previewing application, and one of the things I have to do very often is change the size of the text. As you can see in the image, someone drags the "Size" slider, and the application has to change the size of all of those pieces of text.
NOTE:
keep in mind I am not using beautiful.load_font and these examples are happening in my own text element I wrote, NOT in "wibox/widget/textbox.lua". So no caching happens from there, and I don't do any caching of fonts myself currently.
Initially, I tried to write something like:
-- in my "draw" function which would be called every time someone would move
-- the "Size" slider:
local tf = self.family .. ' ' .. self.weight .. ' ' .. self.size
local new_desc = lgi.Pango.FontDescription.from_string(tf)
text_layout:set_font_description(new_desc)
cr:update_layout(self._text_layout)
cr:show_layout(self._text_layout)
Using this was very slow, down to about 10 - 30 fps as I moved my mouse on the "Size" slider. To try to make this faster, I thought about NOT setting the font description on the text_layout every time, but only set it once when the text element was created, and try to only change the size every time I had to redraw.
So I read the Pango docs, and tried this:
when the text element is created:
local ctx = lgi.PangoCairo.font_map_get_default():create_context()
local text_layout = lgi.Pango.Layout.new(ctx)
local typeface_description = font_family .. " " .. font_weight
local desc = lgi.Pango.FontDescription.from_string(typeface_description)
text_layout:set_font_description(desc)
local pango_attrs = lgi.Pango.AttrList.new()
local pango_size = lgi.Pango.AttrSize.new(font_size * lgi.Pango.SCALE)
lgi.Pango.AttrList.insert(pango_attrs, pango_size)
text_layout:set_attributes(pango_attrs)
self.pango_attrs = pango_attrs
In my "draw" function:
local pango_size = lgi.Pango.AttrSize.new(self.size * lgi.Pango.SCALE)
lgi.Pango.AttrList.change(self.pango_attrs, pango_size)
And when I do this, and use "Xephyr" for testing, The application works well until I start moving the "Size" knob. Then, as I move it, the application still works well for 1-3 seconds. Then, I get a blank screen, and I get this in my terminal:
kill: not enough arguments
kill: not enough arguments
Calling callback function on subscribed signal 'TimeChanged' failed: ./wonderful/bar.lua:148: Pango.Attribute: no `format'
Calling callback function on subscribed signal 'TimeChanged' failed: ./apps/RibbonPanel/LateForLunch/layout.lua:49: Pango.Attribute: no `format'
2022-11-20 09:06:50 E: awesome: signal_fatal:497: signal 11, dumping backtrace
awesome(backtrace_get+0x5f) [0x563e0a3984f2]
awesome(+0x1343e) [0x563e0a38243e]
/usr/lib/libc.so.6(+0x38a00) [0x7fbfdcaa3a00]
/usr/lib/libpango-1.0.so.0(pango_attribute_destroy+0xc) [0x7fbfdb10c36c]
/usr/lib/lua/5.1/lgi/corelgilua51.so(+0x12dc2) [0x7fbfdb386dc2]
/usr/lib/lua/5.1/lgi/corelgilua51.so(+0x132a8) [0x7fbfdb3872a8]
/usr/lib/libluajit-5.1.so.2(+0x9ef6) [0x7fbfdccb9ef6]
/usr/lib/libluajit-5.1.so.2(+0xfcd6) [0x7fbfdccbfcd6]
/usr/lib/libluajit-5.1.so.2(+0x16eac) [0x7fbfdccc6eac]
/usr/lib/libluajit-5.1.so.2(+0x174cd) [0x7fbfdccc74cd]
/usr/lib/libluajit-5.1.so.2(lua_pushstring+0x95) [0x7fbfdccd1955]
awesome(+0x1cc21) [0x563e0a38bc21]
/usr/lib/libluajit-5.1.so.2(+0x9ef6) [0x7fbfdccb9ef6]
/usr/lib/libluajit-5.1.so.2(lua_getfield+0xb1) [0x7fbfdccd7d51]
/usr/lib/lua/5.1/lgi/corelgilua51.so(lgi_marshal_access+0x2c) [0x7fbfdb38585c]
/usr/lib/libluajit-5.1.so.2(+0x9ef6) [0x7fbfdccb9ef6]
/usr/lib/libluajit-5.1.so.2(lua_pcall+0xb3) [0x7fbfdcccc873]
/usr/lib/lua/5.1/lgi/corelgilua51.so(+0x82ee) [0x7fbfdb37c2ee]
/usr/lib/libffi.so.8(+0x70d2) [0x7fbfdc7320d2]
/usr/lib/libffi.so.8(+0x7718) [0x7fbfdc732718]
/usr/lib/libglib-2.0.so.0(+0x560a2) [0x7fbfdd1bd0a2]
/usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x19b) [0x7fbfdd1bc87b]
/usr/lib/libglib-2.0.so.0(+0xac279) [0x7fbfdd213279]
/usr/lib/libglib-2.0.so.0(g_main_loop_run+0x6f) [0x7fbfdd1bbddf]
awesome(main+0x166c) [0x563e0a383eb0]
/usr/lib/libc.so.6(+0x23290) [0x7fbfdca8e290]
/usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7fbfdca8e34a]
awesome(_start+0x25) [0x563e0a382045]
I decided to ask this because it seems to me like the error has something to do with pango_attribute_destroy. I know awesome is using "lgi", which also includes Pango, so my question is: Am I doing something wrong? Or is this a bug in another library like "lgi"?

Why does the 'turtle star' in docs.python.org not work?

I want to learn turtle from https://docs.python.org/3/library/turtle.html, but I find something different from the example there.
Here is the example image:
example
and the code:
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
I run the code above in my machine, but I get this:
my result.
I want to know why I can't get the example's result, and how to draw the same image.

Webots - BoundingObject of Robot becomes null after world reload (how to prevent that?)

I've a Robot node with children = [SolidCylinderJoint]. SolidCylinderJoint is a proto that I created, which defines a DEF node as a field, i.e.,
field SFNode geometry DEF BODY Cylinder {
height 0.1
radius 0.05
}
Now I USE the BODY DEF node as the boundingObject of the robot, like this:
Now, this works great, but as soon as I hit "Reload World" or restart webots, the boundingObject becomes NULL again. I think this is happening because the robot node is loaded before the Proto, and at the time it's trying to set the boundingObject to BODY, it doesn't find that definition and hence defaults to NULL.
World file: https://pastecode.xyz/view/fab1533d
Proto file: https://pastecode.xyz/view/f558d13c
First, there is an issue in your PROTO, you are not allowed to make an IS in the default argument of the fields (i.e. baseColor IS baseColor):
field SFVec3f baseColor 0.985946 0 0.0481575
field SFNode appearance PBRAppearance { baseColor IS baseColor metalness 0.3 }
About the issue with the DEF-USE, this is indeed a bug, it seems default argument of the PROTO are created after the root node and therefore not found at the creation of the root node.
I have reported this here and hopefully it will be fixed in the next version of Webots:
https://github.com/cyberbotics/webots/issues/1231

How can I reset ESP8266 MicroPython after main.py crashes?

I have a NodeMCU ESP8266 board running MicroPython. I'm running a web server on my ESP8266. This is my first IoT project based on one of these boards.
The below is a snippet of the code.
This is being executed within main.py. Every now and then, something causes the code to crash (perhaps timing and request based). When main.py exits, for whatever reason, I'm dropped back at the python CLI.
I'd like for the board to reset when this happens (if there isn't a better way).
What is the best method of restarting/reseting the ESP8266?
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(5)
print('listening on', addr)
while True:
cl, addr = s.accept()
print('client connected from', addr)
cl_file = cl.makefile('rwb', 0)
print("Request:")
while True:
line = cl_file.readline()
print("Line:" , line)
if not line or line == b'\r\n':
print("breaking")
break
if line == b'GET /active HTTP/1.1\r\n':
MicroPython has machine.reset() function to reset a board.
Python (not just MicroPython) uses exception handling to handle errors.
Combining the two, you can easily achieve what you want. For example:
a = 4
b = 2
try:
a / b
except:
machine.reset()
If in the code above you replace value of b with 0, your board will reset. If you think about it for a bit, you probably will find out that it doesn't make much sense - you don't want your board suddenly reset if you just divide by 0 by mistake or otherwise. There're got to be better ways to handle errors! Likewise, you may want to think about your own case and see if resetting the board is really the best choice. If you think that yes, that's fine, just always keep in mind that you programmed your board to suddenly reset. Otherwise, your next question here may be "My board suddenly resets! Why???" ;-)
It may be late for the original question, but the answer I am going to share might help other people. Consider it is not a final solution, but in many scenarios, it may save a day. You can explore your case.
The solution is using the internal scheduling function of MicroPython. since its execution is guaranteed, then its behavior can be used as a tool to mimic a functional watchdog.
Following code will run with given timers and threshold which can be customized in your case, and if the timer reaches its threshold, and the value of wd_buffer is not updated for that time, then the function might be called, and we repeat the process again.
So in order to prevent the ESP getting restarted in this case after 12 sec, you have to in someplace in your code, periodically (shorter than 12 sec or adjust the timer and threshold according to your need) update the value of the Global wd_buffer variable. Hope it helps.
# Simple WD - Global Variable
wd_feeder = 0
wd_buffer = 0
wd_counter = 0
wd_threshold = 4
def wd_checker(calledvalue):
print('watchdog is checking... feeder= {} buffer= {}'.format(wd_feeder, wd_buffer))
global wd_counter
global wd_buffer
global wd_feeder
if wd_feeder == wd_buffer:
print('state is suspicious ... counter is {} incrementing the counter'.format(wd_counter))
wd_counter += 1
else:
wd_counter = 0
wd_feeder = wd_buffer
if wd_counter == wd_threshold:
print('Counter is reached its threshold, following function will be called')
wd_feeder = wd_buffer = wd_counter = 0
machine.reset()
if __name__ == '__main__':
scheduler_wd = machine.Timer(-1)
scheduler_wd.init(period=3000, mode=machine.Timer.PERIODIC, callback=wd_checker)
you could add a while loop checking for the Flash Button (GPIO pin 0) like this:
import machine
pin = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)
while pin.value():
print('Put your code here...')
print('..this will looping until the Flash button is pressed...')
print('...and then it continues here.')
You could execute your code (which should be outside of the main.py -> other file) from the boot or the main.py. if it drops out it should execute the following code, which could trigger a reset.
You may have to catch the error first.
I hope I helped

wxMaxima: how to get decimal number results?

This should be easy but I am struggling on that.
I googled already but nothing seems to work.
(I am using wxMaxima 15.08.1 on Windows)
My example code looks like this:
kill (all);
numer:true;
sigma_z: 1000.0$ /*[N/mm²]*/
sigma_b_zul : simga_z*0.7;
sigma_b_zul : simga_z*0.7, numer;
sigma_b_zul : simga_z*0.7, numer:true;
float(sigma_b_zul);
the output is every time:
0.7 simga_z
the next cell looks like:
d_d: 1000$ /*dfd*/
sigma_g_f_d: d_d * 0.7;
the result is:
7.0E+2
I am completely clueless why maxima behaves like this. Can anyone help?
The variable you define is
sigma_z: 1000.0$ /*[N/mm²]*/
but then you call
simga_z*0.7;
Please, notice the difference between sigma_z and simga_z.

Resources