signals

How to change value of a signal's range in Matlab

帅比萌擦擦* 提交于 2019-12-11 07:59:38
问题 Let's say that I have a signal in Matlab like this x = cos(2*pi*10*t) + cos(2*pi*20*t) + cos(2*pi*50*t); And I want to change the values between 20 and 30 hz into 0. How can I do that? I mean, those values generated from the x formula, I want to change them a little bit. 回答1: You can do it by performing FFT over x and setting to zero those values that are between 20 and 30 Hz then applying the FFT inverse on the previous values and you should get the signal without those frequencies. However,

Dynamic connecting/disconnecting signals and slots

不问归期 提交于 2019-12-11 07:25:49
问题 My program has two states and it can switch between them for some reasons. In these states the program needs to receive different signals, which means it has to connect and disconnect certain signals during the run. How bad is such approach? 回答1: It's a fine approach, I've used it before without issues. Depending on what you're actually doing a QSignalMapper might be of use for you. 来源: https://stackoverflow.com/questions/15274147/dynamic-connecting-disconnecting-signals-and-slots

Qt, QCoreApplication and QFtp

廉价感情. 提交于 2019-12-11 07:17:04
问题 I want to use QFtp for the first time and googled a lot to find out how it should be used. This, among others is a typical example: #include <QCoreApplication> #include <QFtp> #include <QFile> int main(int argc, char ** argv) { QCoreApplication app(argc, argv); QFile *file = new QFile( "C:\\Devel\\THP\\tmp\\test.txt" ); file->open(QIODevice::ReadWrite); QFtp *ftp = new QFtp(); ftp->setTransferMode(QFtp::Active); ftp->connectToHost("ftp.trolltech.com"); ftp->login(); ftp->cd("qt"); ftp->get(

How can I programmatically get the default behavior of sigterm inside a custom signal handler?

情到浓时终转凉″ 提交于 2019-12-11 07:16:00
问题 Based on man -S 7 signal , when a program which has not defined a signal handler receives SIGTERM , the default action is to Term . I am registering a custom signal handler for SIGTERM , but I want the final statement (after specific cleanup is done) in my custom handler to be a function call that achieves the exact same effect as Term . What is the correct function to call here? I have tried exit(0) , but that causes the destructors of statically initialized objects to be called, which does

Why does the signal not trigger?

浪尽此生 提交于 2019-12-11 07:15:46
问题 Sitting over a day on it. Really can't understand why this signal is not triggered when a user is activated, no error log, no exception in the admin on activation. Can anybody help? The following code should result in a log message in the apache error.log when a user, right? import logging from django.dispatch import receiver from registration.signals import user_activated @receiver(user_activated) def registered_callback(sender, **kwargs): logger = logging.getLogger("user-activated") logger

Is it safe to disconnect a slot before it was called?

我的梦境 提交于 2019-12-11 07:01:49
问题 I have several objects which need to be updated. The updating is done in a separate thread and the results will be transferred to the objects via a pyqtSignal . So the updating method loops over all objects like this: The object class: class MyObject(QObject): def __init__(self, id): QObject.__init__(self) self.id = id def catch_result(self, id, res): if id == self.id: # do something with res And the worker class: class Worker(QObject): result = pyqtSignal('QString', 'QString') def __init__

In C, linux, about kill signal and sleep() in loop

青春壹個敷衍的年華 提交于 2019-12-11 05:54:50
问题 I run my C program on Mac OS. Part of my program is as following. This code runs well on sigint signal but can't work on sigkill signal. void sigkill(int sig){ /*some code neglected*/ exit(0); } void sigint(int sig){ flag=1; } void alive(void) { signal(SIGINT, sigint); signal(SIGKILL, sigkill); alarm(10); while(1){ //printf("%d\n",flag); sleep(1); if(flag==1){ printf("no\n"); flag=0; } } } I have four questions: At first I didn't write sleep(1) , It can enter the function sigint(), and change

qt button to emit multiple signals

大兔子大兔子 提交于 2019-12-11 05:39:16
问题 is there a Qt (I use Qt 4.7.1) widget that emit signals (not just one at the first time) while it is pressed and stops when the user releases the mouse? something like mousedown events in standard intervals? or do I have to implement this with a qtimer? thanks 回答1: Check out QAbstractButton::autoRepeat and autoRepeatInterval. It should be exactly what you need and is available for all buttons. 回答2: You have to implement something that fire the event until the user release the mouse. I suggest

sigaction: restore handler or not?

筅森魡賤 提交于 2019-12-11 05:30:02
问题 if i call sigaction at the beginning of my code, sigaction(SIGPIPE, &pipe_act, NULL); if i receive sigpipe, after the execution of pipe_act the handler installed remains pipe_Act, or the default handler is automatically set for sigpipe? 回答1: It depends on whether or not your flags ( pipe_act->sa_flags ) include SA_RESETHAND . If yes, then the signal handler is a "one-shot" and gets removed after having been called (i.e. the handler is reset to the default handler), but if not, then the

Python: prevent signals to propagate to child threads

最后都变了- 提交于 2019-12-11 05:09:29
问题 import threading import time def worker(i): while True: try: print i time.sleep(10) break except Exception, msg: print msg threads = [] for i in range(10): t1 = threading.Thread(target=worker, args=(i,)) threads.append(t1) for t in threads: t.start() print "started all threads... waiting to be finished" for t in threads: t.join() if i press ^C while the threads are running, does the thread gets the SIGINT? if this is true, what can i do from the caller thread to stop it from propagating