JamesGlanville / GF2

0 stars 0 forks source link

Printing to GUI display #16

Closed AndyHolt closed 11 years ago

AndyHolt commented 11 years ago

In order to print to the gui terminal display rather than the actual terminal logsim is running in, we need to add the code:

wxStreamToTextRedirector redirect(text);

before cout-ing. I think once per scope will be enough, but new functions etc all seem to need it.

Please could you update parser errors to print out here?

JamesGlanville commented 11 years ago

also you have to extern wxsomething* text; at the top (like in logsim.cc)

On 30 May 2013 11:16, adh635 notifications@github.com wrote:

In order to print to the gui terminal display rather than the actual terminal logsim is running in, we need to add the code:

wxStreamToTextRedirector redirect(text);

before cout-ing. I think once per scope will be enough, but new functions etc all seem to need it.

Please could you update parser errors to print out here?

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16 .

AndyHolt commented 11 years ago

the wxsomething is wxTextCtrl, so the required definition is:

extern wxTextCtrl* text;

You may also need to:

#include <wx/wx.h>

in the header wherever we want to do it.

ghost commented 11 years ago

Is it sufficient to have it once per class?

On 30 May 2013 11:23, adh635 notifications@github.com wrote:

the wxsomething is wxTextCtrl, so the required definition is:

extern wxTextCtrl* text;

You may also need to:

include <wx/wx.h>

in the header wherever we want to do it.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18672272 .

AndyHolt commented 11 years ago

I think that each method requires it, but try it and see :)

ghost commented 11 years ago

How can we test whether we've done it correctly?

On 30 May 2013 11:58, adh635 notifications@github.com wrote:

I think that each method requires it, but try it and see :)

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18673581 .

AndyHolt commented 11 years ago

make it and run ./logsim with a file to give whatever output you want (ie with the correct error). If its correct, it will print out to the terminal box at the bottom of the GUI, otherwise it will print to your standard terminal.

ghost commented 11 years ago

It's not appearing on either... I clicked load data, but I don't really know if anything is happening.

On 30 May 2013 14:54, adh635 notifications@github.com wrote:

make it and run ./logsim with a file to give whatever output you want (ie with the correct error). If its correct, it will print out to the terminal box at the bottom of the GUI, otherwise it will print to your standard terminal.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18681394 .

AndyHolt commented 11 years ago

I've added a message, printed when the data is loaded.

If its successful, there will be a list of the available switches and monitors in the dropdown menus.

ghost commented 11 years ago

I can't get it to print to the GUI or terminal when running through logsim. Loading a file with errors just causes it to hang.

On 30 May 2013 15:06, adh635 notifications@github.com wrote:

I've added a message, printed when the data is loaded.

If its successful, there will be a list of the available switches and monitors in the dropdown menus.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18682174 .

ghost commented 11 years ago

James have you got any of your scanner code printing to the terminal?

On 30 May 2013 16:23, George Ayris georgeayris@gmail.com wrote:

I can't get it to print to the GUI or terminal when running through logsim. Loading a file with errors just causes it to hang.

On 30 May 2013 15:06, adh635 notifications@github.com wrote:

I've added a message, printed when the data is loaded.

If its successful, there will be a list of the available switches and monitors in the dropdown menus.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18682174 .

AndyHolt commented 11 years ago

Interesting. Are you in namespace std? (But I think if you needed std::cout it would tell you)

Can you try couting from different objects (eg when the method namelookup is run and see if you can find which classes will and which don't?

AndyHolt commented 11 years ago

Any advance on this?

ghost commented 11 years ago

Sorry about the delay. I've inserted a cout at the start of the main aprser.cc function (just pushed to git). Which should just output when the file is read, what am I doing wrong?

On 30 May 2013 16:56, adh635 notifications@github.com wrote:

Interesting. Are you in namespace std? (But I think if you needed std::cout it would tell you)

Can you try couting from different objects (eg when the method namelookup is run and see if you can find which classes will and which don't?

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18689760 .

JamesGlanville commented 11 years ago

Sorry about taking so long, I can't get it to work now, when it was before :s I can only assume it's because the text pointer isn't valid at the point that wxstreamtotextredirector is called, but i'm getting stuck working out why.

On 30 May 2013 17:45, GeorgeAyris notifications@github.com wrote:

Sorry about the delay. I've inserted a cout at the start of the main aprser.cc function (just pushed to git). Which should just output when the file is read, what am I doing wrong?

On 30 May 2013 16:56, adh635 notifications@github.com wrote:

Interesting. Are you in namespace std? (But I think if you needed std::cout it would tell you)

Can you try couting from different objects (eg when the method namelookup is run and see if you can find which classes will and which don't?

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18689760> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18692953 .

JamesGlanville commented 11 years ago

could it be that reusing the name "text" is causing the problems? I'm seeing it in a few other places in gui.cc

AndyHolt commented 11 years ago

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

ghost commented 11 years ago

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834 .

JamesGlanville commented 11 years ago

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157 .

JamesGlanville commented 11 years ago

now I get a load of output to the window terminal thing. I'm just cooking, so even if this works correctly could you take a look at the diff and check i haven't screwed anything up?

On 30 May 2013 18:05, James Glanville james.n.glanville@gmail.com wrote:

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157 .

ghost commented 11 years ago

Yes! And all the couts now magically work :)

On 30 May 2013 18:05, James Glanville notifications@github.com wrote:

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834> .

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694374 .

ghost commented 11 years ago

Yeah that's correct, if you want to get rid of them then comment out the

define verbose in parser.h

On 30 May 2013 18:06, James Glanville notifications@github.com wrote:

now I get a load of output to the window terminal thing. I'm just cooking, so even if this works correctly could you take a look at the diff and check i haven't screwed anything up?

On 30 May 2013 18:05, James Glanville james.n.glanville@gmail.com wrote:

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834> .

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694443 .

ghost commented 11 years ago

Just pushed code that removed unnecessary couts now it is working and commented out #define verbose

On 30 May 2013 18:08, George Ayris georgeayris@gmail.com wrote:

Yeah that's correct, if you want to get rid of them then comment out the

define verbose in parser.h

On 30 May 2013 18:06, James Glanville notifications@github.com wrote:

now I get a load of output to the window terminal thing. I'm just cooking, so even if this works correctly could you take a look at the diff and check i haven't screwed anything up?

On 30 May 2013 18:05, James Glanville james.n.glanville@gmail.com wrote:

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834>

.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694443 .

ghost commented 11 years ago

Just tried it with alternate test file and it just hung and now with testgates.def it's seg faulting on load data.

On 30 May 2013 18:12, George Ayris georgeayris@gmail.com wrote:

Just pushed code that removed unnecessary couts now it is working and commented out #define verbose

On 30 May 2013 18:08, George Ayris georgeayris@gmail.com wrote:

Yeah that's correct, if you want to get rid of them then comment out the

define verbose in parser.h

On 30 May 2013 18:06, James Glanville notifications@github.com wrote:

now I get a load of output to the window terminal thing. I'm just cooking, so even if this works correctly could you take a look at the diff and check i haven't screwed anything up?

On 30 May 2013 18:05, James Glanville james.n.glanville@gmail.com wrote:

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834>

.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694443 .

ghost commented 11 years ago

Sorry for all this spam. It now appears to be working again, however it occasionally fails to bring up the gui when it is run, but then cancelling and re-running causes the gui to appear. Bizarre

On 30 May 2013 18:16, George Ayris georgeayris@gmail.com wrote:

Just tried it with alternate test file and it just hung and now with testgates.def it's seg faulting on load data.

On 30 May 2013 18:12, George Ayris georgeayris@gmail.com wrote:

Just pushed code that removed unnecessary couts now it is working and commented out #define verbose

On 30 May 2013 18:08, George Ayris georgeayris@gmail.com wrote:

Yeah that's correct, if you want to get rid of them then comment out the

define verbose in parser.h

On 30 May 2013 18:06, James Glanville notifications@github.com wrote:

now I get a load of output to the window terminal thing. I'm just cooking, so even if this works correctly could you take a look at the diff and check i haven't screwed anything up?

On 30 May 2013 18:05, James Glanville james.n.glanville@gmail.com wrote:

has that fixed it?

On 30 May 2013 18:02, GeorgeAyris notifications@github.com wrote:

If I change the variable name then I get an undefined reference error...

On 30 May 2013 17:58, adh635 notifications@github.com wrote:

I don't think I'm using text directly for anything else, but probably worth trying a name change to see what happens.

— Reply to this email directly or view it on GitHub<

https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18693834>

.

— Reply to this email directly or view it on GitHub< https://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694157> .

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18694443 .

AndyHolt commented 11 years ago

Yeah, James and I have both had issues with the gui not appearing occasionally. Its always been fine when I just run it again though. Not sure what its doing.

ghost commented 11 years ago

Ok fair enough. How close to being done are you? Because we still need to be able to write user guides.

On 30 May 2013 19:05, adh635 notifications@github.com wrote:

Yeah, James and I have both had issues with the gui not appearing occasionally. Its always been fine when I just run it again though. Not sure what its doing.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18697315 .

AndyHolt commented 11 years ago

I think my last commit is pretty much it done. I'm going to try to tackle a couple of small bugs and improvements but shouldn't take long.

The main thing not yet done is loading a file from the file picker, do you think you could handle that? (very similar code to in datalogger.cpp but using a load rather than save.

I'm not sure how easy it is to get the file from the gui at start-up then pass it to the scanner/parser, but it should be possible from the gui side of things and would be quite a nice feature.

AndyHolt commented 11 years ago

(BTW datalogger.cpp is in JamesGlanville/datalogger/gui directory, I can email a the relevant code if you don't have access, or James could do it if you'd rather not)

JamesGlanville commented 11 years ago

I can do it tonight, but not easily for a few hours. I don't mind staying up for ages to get it done though.

On 30 May 2013 21:20, adh635 notifications@github.com wrote:

(BTW datalogger.cpp is in JamesGlanville/datalogger/gui directory, I can email a the relevant code if you don't have access, or James could do it if you'd rather not)

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18705530 .

AndyHolt commented 11 years ago

I'll do what I can with the bits I want to fix and if neither of you have started it/its not too late then I'll hack it. Can you post here if either of you do start it?

ghost commented 11 years ago

I get a seg fault if I keep clicking continue just so you are aware, but looks good!

On 30 May 2013 21:25, adh635 notifications@github.com wrote:

I'll do what I can with the bits I want to fix and if neither of you have started it/its not too late then I'll hack it. Can you post here if either of you do start it?

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18705879 .

AndyHolt commented 11 years ago

Hmm, I got a seg fault after about 350 clock cycles, is there a maximum in the code anywhere? I couldn't find any set constraints on how many cycles must be simulated, so maybe we could just set a limit?

JamesGlanville commented 11 years ago

I've looked through the code and can't see a limit anywhere, but setting a limit seems like a good idea. awesome job on the gui btw.

ghost commented 11 years ago

I'm looking at writing the file open stuff, do I want to be taking my inspiration from onCSVwrite?

On 30 May 2013 21:55, James Glanville notifications@github.com wrote:

I've looked through the code and can't see a limit anywhere, but setting a limit seems like a good idea. awesome job on the gui btw.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18707747 .

AndyHolt commented 11 years ago

Yeah, here's a link to the doc page for wxFileDialog:

http://docs.wxwidgets.org/stable/wx_wxfiledialog.html

As you've probably guessed, we want wxFD_OPEN rather than save...

AndyHolt commented 11 years ago

And we want the code in the callback MyFrame::OnFileButton - sorry if this isn't very clear/is really obvious.

ghost commented 11 years ago

You mentioned in the other issue that you were starting on this now. Is it easier if I leave it for you or would you like me ot keep going?

On 30 May 2013 22:12, adh635 notifications@github.com wrote:

And we want the code in the callback MyFrame::OnFileButton - sorry if this isn't very clear/is really obvious.

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18708815 .

AndyHolt commented 11 years ago

Haha, I wrote that just before seeing your comments here. I'm happy to do it if you don't want me to but I'm very happy for you to do it.

I probably know more about the gui side of things, but you probably have more experience with the backend stuff like loading the file and passing that to the parser, so probably neither of us is at an advantage...

ghost commented 11 years ago

I think you'll be better at it without breaking gui stuff, but feel free to give me a call etc. about parser stuff

On 30 May 2013 22:18, adh635 notifications@github.com wrote:

Haha, I wrote that just before seeing your comments here. I'm happy to do it if you don't want me to but I'm very happy for you to do it.

I probably know more about the gui side of things, but you probably have more experience with the backend stuff like loading the file and passing that to the parser, so probably neither of us is at an advantage...

— Reply to this email directly or view it on GitHubhttps://github.com/JamesGlanville/GF2/issues/16#issuecomment-18709127 .

AndyHolt commented 11 years ago

As far as I can tell, the printing to gui is working well. If so, lets close this and have file dialog chat in the gui still-to-be-done chat or a new one...