Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-06

Thread based timer vs TTimer

22 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Michael Schnell wrote
But if this is the recommended way to do timers, why does *any *WidgetType (i.e. TApplication) offer TTimer ?

I've done that in fpGUI because not everybody wants to use threads in theire software. So now the developer has a choice.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote
I've done that in fpGUI because not everybody wants to use threads in theire software. So now the developer has a choice.

Great !

IMHO a decent TApplication needs support as well for Timers as for Threads, including Application.QueueAsyncCall.

That is why I did the ActiveNoGUI "interface" unit. It seems to work quite well. Its rather lightweight and no OS or Arch depending code is used, so it should be portable without a hassle

(For Application.QueueAsyncCall) it needs a version of fpc with an rtl that supports TThread.Queue.

I don't know if a "standard" Lazarus installation will already have this. I need to check some day soon. After that it should be no big deal to make it selectable as yet another Widget Type.

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
IMHO a decent TApplication needs support as well for Timers as for Threads, including Application.QueueAsyncCall.

I don't use TCustomApplication anywhere in fpGUI or my applications. I've also never had the need for QueueAsyncCall(), sorry. ;-)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote
I don't use TCustomApplication anywhere in fpGUI or my applications. I've also never had the need for QueueAsyncCall(), sorry. ;-)

My "easy" way to do (embedded) application for headless devices (hence obviously NopGUI) is to do the application first on a (Linux) PC including a GUI for monitoring states and introducing stimulus events, using a set of dedicated units for GUI stuff and another set of dedicated units for the "business logic". In the end, the GUI units can be replaced by noGUI workalikes with stripped-off debugging functionality, leaving the "business logic" units untouched. So if you face any problems with the running task, for debugging you easily can use the GUI enabled application, again.

As such embedded application often need to communicate with multiple partners via TCP/IP, serial interfaces etc, and need to do complex timing, it does make sense to use threads and TTimers.

Of course a complete cross-development with cross compiling and remote debugging (PC -> headless device) would be another decent option here. But I have not been able to make this work. (For C based project I use an Eclipse IDE for cross compiling and remote debugging every day.)

So IMHO, an "activeNoGUI" Widget Type that automates the process of porting would be nice to have.

In fact all this has become less priority during the last few years, as you rather easily at rather low additional cost you can plan your embedded device to be GUI enable (e.g. with a BeagleBone or an Odroid). But I e.g. needed to do software for a NAS device and here, no Graphic was I hope to be able to publish the "activeNoGUI" Widget Type for Lazarus one day soon.

-Michael

Reply by email

Paul Breneman
to Michael Schnell
Michael Schnell wrote 35 lines
On 06/23/2015 04:36 PM, Graeme Geldenhuys wrote: > I don't use TCustomApplication anywhere in fpGUI or my applications. > I've also never had the need for QueueAsyncCall(), sorry. ;-) My "easy" way to do (embedded) application for headless devices (hence obviously NopGUI) is to do the application first on a (Linux) PC including a GUI for monitoring states and introducing stimulus events, using a set of dedicated units for GUI stuff and another set of dedicated units for the "business logic". In the end, the GUI units can be replaced by noGUI workalikes with stripped-off debugging functionality, leaving the "business logic" units untouched. So if you face any problems with the running task, for debugging you easily can use the GUI enabled application, again. As such embedded application often need to communicate with multiple partners via TCP/IP, serial interfaces etc, and need to do complex timing, it does make sense to use threads and TTimers. Of course a complete cross-development with cross compiling and remote debugging (PC -> headless device) would be another decent option here. But I have not been able to make this work. (For C based project I use an Eclipse IDE for cross compiling and remote debugging every day.) So IMHO, an "activeNoGUI" Widget Type that automates the process of porting would be nice to have. In fact all this has become less priority during the last few years, as you rather easily at rather low additional cost you can plan your embedded device to be GUI enable (e.g. with a BeagleBone or an Odroid). But I e.g. needed to do software for a NAS device and here, no Graphic was available at all. Nonetheless I hope to be able to publish the "activeNoGUI" Widget Type for Lazarus one day soon. -Michael

As you know Michael I've been *very* interested for years with what you are doing. I hope to get more going with FPC and Teensy in the next few weeks:
http://forum.lazarus.freepascal.org/index.php/topic,28561.0.html

Then I hope to post more projects in the Wiki and also on this page: http://ControlPascal.com/

I look forward to working together with you and others...

Reply by email

Michael Schnell
to Paul Breneman
Paul Breneman wrote 11 lines
As you know Michael I've been *very* interested for years with what you are doing. I hope to get more going with FPC and Teensy in the next few weeks: http://forum.lazarus.freepascal.org/index.php/topic,28561.0.html Then I hope to post more projects in the Wiki and also on this page: http://ControlPascal.com/ I look forward to working together with you and others...

Great to see you back on this issue ! Thanks a lot.

Unfortunately, for me, right now Lazarus is just a hobby task, as I don't have any real application for it at the moment. But I still am lurking, and eager to finish the work in progress I have been starting, before we (company) decided not to use Lazarus in the way that I have been suggesting. An hence I am very busy with other (ANSI C based embedded) stuff.

If you want to help with "activeNoGUI" the first thing that is needed to be done is verify if a current "standard" distribution of Lazarus will install an fpc version that provides TThread.Queue.

If this is given I will re-test the code I did for the "activeNoGUI" "interface" unit (that provides TApplication etc).

Then I could send you the code to do more testing and provide suggestions.

If we are happy with the results we could investigate how it is possible to have it integrated in the Lazarus IDE as an additional selectable "Widget Type".

Thanks again,
-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
Then I could send you the code to do more testing and provide suggestions.

Why not simply fork the Lazarus repository on Github. Create your own branch and do all your changes in there. Publish your branch to your own Github repository (or some other public location) where others could view and pull from.

  $> git clone https://github.com/graemeg/lazarus.git
  $> cd lazarus
  $> git checkout -b activenogui origin/upstream
  // you will now be in a new 'activenogui' branch based off Laz Trunk

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote
On 2015-06-24 12:03, Michael Schnell wrote: > Then I could send you the code to do more testing and provide suggestions. Why not simply fork the Lazarus repository on Github.

OK that is a much better alternative to transfer the source code.

Create your own branch and do all your changes in there. Publish your branch to your own Github repository (or some other public location) where others could view and pull from.

Due to my bad reputation as a troll here, I don't think I am entitled to write to the primary Lazarus svn, so I did not think about posting there

Thanks for offer to use your git.

Of course I do have a local clone of the lazarus (and fpc) git and I daily keep it updated.

Is same always up to date so that I can use it instead of the primary Lazarus svn ?

$> git clone https://github.com/graemeg/lazarus.git $> cd lazarus

running....

I'll try to create the new 'activenogui' branch when "clone" is done.

Thanks !

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: Why not simply fork the Lazarus repository on Github. Create your own branch and do all…
Graeme Geldenhuys wrote
git checkout -b activenogui origin/upstream

I got:

Branch activenogui set up to track remote branch upstream from origin.
Switched to a new branch 'activenogui'

So this did work nicely.

Thanks again.

I suppose I now can just do "git pull" to receive any updates that the Lazarus svn might provide ?

I suppose I can do "git push" to provide my own code ?

Thanks again,
-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell: OK that is a much better alternative to transfer the source code. Due to my bad…
Michael Schnell wrote
Due to my bad reputation as a troll here, I don't think I am entitled to write to the primary Lazarus svn,

Unlike SVN, Git doesn't require you to have write access to the official repository (the benefits of distributed version control systems). You are cloning the Lazarus mirror (git) repository. You will develop in your own branch, and publish that changes to your own git account on Github. You will not be writing to my Lazarus mirror. But by using Git, you make it easy for others to join in or simply follow your development. It also makes it very easy for an official Lazarus developer to fetch your branch and integrate it into SVN. I know some Lazarus team members already use Git.

My Lazarus git mirror is automatically updated every 15 minutes, and has done so since 2009.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to Michael Schnell: I got: Branch activenogui set up to track remote branch upstream from origin. Switched to…
Michael Schnell wrote
I suppose I now can just do "git pull" to receive any updates that the Lazarus svn might provide ?

Close. My Lazarus mirror doesn't have an 'activenogui' branch, so doing a pull will not fetch anything. To update your repository with the latest SVN Trunk changes, you need to [alternatives exist, but this is easiest to explain] switch to the 'upstream' branch, then to a 'git pull'.

My apologies, your 'activenogui' branch should have been created from 'upstream', not 'origin/upstream'. The difference being, you don't want 'activenogui' to be a tracking branch (see docs for an explanation). To fix this, simply run the following command:

  $ git branch --unset-upstream activenogui

This means you can now fetch the latest Trunk changes, and it will not affect your 'activenogui' branch - no automatic merges/updates will occur. This is what you want. It is best to manually update your branch with the latest Trunk changes, at a time that suites you best.

Now, to update your 'upstream' branch with the latest Trunk changes:

  // currently in 'activenogui' branch
  $ git stash          // to safe-keep any local uncommitted changes
  $ git checkout upstream
  $ git pull
  $ git checkout activenogui
  $ git stash pop     // restore your local uncommitted changes

You can now review the new changes in 'upstream' and periodically (eg: once a week) bring your 'activenogui' up to date with the latest Trunk changes by simply merging 'upstream' into 'activenogui'

  // while in 'activenogui' branch
  $ git merge upstream

TIP:
Never make any commits in the 'upstream' branch! Always make commits in local branches, even if it is simply a one commit bug fix you want to share with the Lazarus team. This will save you from lots of frustration, and eliminate pull conflicts.

I suppose I can do "git push" to provide my own code ?

I'm assuming you are using Github, and I assume you have your own github account. Now if you haven't yet, create a new "Lazarus" repository via the Github web interface. DO NOT let Github initialize the the repository. Once Github has created the repository, it will show you the exact commands and URL information you need to use to link to it. When Github's instructions refer to 'origin', replace that with the name 'github'.

What you will end up with is the following.

* Your lazarus repository on your computer will point to two remote repositories.
- 'origin' which points to my Lazarus mirror. Used for getting the latest SVN Trunk changes.
- 'github' which points to your Lazarus repository in your Github account. This is the one you have read/write access to.
* When you are ready to share any code, you push to the 'github' repository.

  // in 'activenogui' and ready to share changes with the world
  $ git push github activenogui

I believe the last parameter is optional, once you have used it at least once.

TIP:
I never use the name 'origin' to refer to remote repositories. I find it not informative enough. It is just a name after all, and you can rename it whenever you want. I use more descriptive names, so I know exactly where I am pushing or pulling from (eg: 'github', 'sourceforge' etc). So in your case I might rename the remote repository named 'origin' to be 'graemeg'. So when you do a 'git pull graemeg' you know exactly which repository you referring too, and there is no confusion where the data is coming from.

I think all this information is already in the Lazarus Wiki under the Git Mirror page. If not, it might be worth adding.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote
On 2015-06-25 09:04, Michael Schnell wrote: > I suppose I now can just do "git pull" to receive any updates that the > Lazarus svn might provide ? Close.....

Ooops.

I need to try to digest all this information.

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: Close. My Lazarus mirror doesn't have an 'activenogui' branch, so doing a pull will not…
Graeme Geldenhuys wrote
Close. My Lazarus mirror doesn't have an 'activenogui' branch, so doing a pull will not fetch anything.

I just did a test (after doing nothing than what you suggested in you previous mail ).

"git status" said:
# On branch activenogui
....

"git pull" issued:

remote: Counting objects: 44, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 44 (delta 34), reused 33 (delta 23), pack-reused 0 Unpacking objects: 100% (44/44), done.

767177e..ee091fa upstream -> origin/upstream
Updating 767177e..ee091fa
Fast-forward
components/turbopower_ipro/iphtml.pas | 5 +- components/wiki/{chm => css}/wiki.css | 58 ++--- components/wiki/html/wiki.css | 308 --------------------
components/wiki/lazwiki/wiki2chmconvert.pas | 6 + components/wiki/lazwiki/wiki2xhtmlconvert.pas | 11 +- components/wiki/xhtml/wiki.css | 308 --------------------
.../lazdatadesktop/languages/lazdatadesktop.cs.po | 22 +- .../lazdatadesktop/languages/lazdatadesktop.de.po | 24 ++- .../lazdatadesktop/languages/lazdatadesktop.es.po | 24 ++- .../lazdatadesktop/languages/lazdatadesktop.fr.po | 24 ++- .../lazdatadesktop/languages/lazdatadesktop.hu.po | 24 ++- .../lazdatadesktop/languages/lazdatadesktop.it.po | 24 ++- .../lazdatadesktop/languages/lazdatadesktop.lt.po | 24 ++- tools/lazdatadesktop/languages/lazdatadesktop.po | 12 +- .../languages/lazdatadesktop.pt_BR.po | 24 ++- .../lazdatadesktop/languages/lazdatadesktop.ru.po | 18 +- .../lazdatadesktop/languages/lazdatadesktop.uk.po | 24 ++- tools/lazdatadesktop/lazdatadeskstr.pas | 14 +- 18 files changed, 217 insertions(+), 737 deletions(-) rename components/wiki/{chm => css}/wiki.css (82%) delete mode 100644 components/wiki/html/wiki.css
delete mode 100644 components/wiki/xhtml/wiki.css

So if in fact did an updated when on branch activenogui

I'm assuming you are using Github,

I did exactly what you suggested.

and I assume you have your own github account.

I don't. Do I need one ?

Show quoted text 6 lines
Now if you haven't yet, create a new "Lazarus" repository via the Github web interface. DO NOT let Github initialize the the repository. Once Github has created the repository, it will show you the exact commands and URL information you need to use to link to it. When Github's instructions refer to 'origin', replace that with the name 'github'.

I suppose for the moment I am lost here :-(

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: Close. My Lazarus mirror doesn't have an 'activenogui' branch, so doing a pull will not…
Graeme Geldenhuys wrote
This is what you want. It is best to manually update your branch with the latest Trunk changes, at a time that suites you best.

OK.

I expected that the updates of any file I did not change locally should be performed, while remote updates to files that I did change locally would trigger a merge process, requiring manual help if appropriate, providing me with the merged version of the file locally, that I can go on modifying if I think necessary.

But maybe this is not a good idea...

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: Close. My Lazarus mirror doesn't have an 'activenogui' branch, so doing a pull will not…
Graeme Geldenhuys wrote
. When Github's instructions refer to 'origin', replace that with the name 'github'.

I created a github (you were right I do have an account and there I already do have an "epictimer" directory. So we seemingly already have been there some time ago ;-) )

I did:

git remote add github https://github.com/mschnell1/Lazarus.git

And this did not produce an error message.

So seemingly in fact there is this repository.

Does same already have a branch "activenogui" as I was at this branch when issuing the command ?

I don't want to push all the Larzarus files I pulled from "github/graeme" and all the files that have been created by compiling Lazarus to "github/mschnell1". How to avoid this ?

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
I don't want to push all the Larzarus files I pulled from "github/graeme" and all the files that have been created by compiling Lazarus to "github/mschnell1". How to avoid this ?

Then start again, by logging into Github. Then deleting your lazarus repository on Github (via their website). Then browse to my lazarus repository on Github and click the "fork" button. Your account should now have lazarus repository. Github should give you instructions on how to clone it, or hook it up to your existing local repository (on your computer). You only need to do the latter, because the repository history will be the same - no need to clone it again. When you eventually do a 'git push', it will only push the changes you added to the repository.

I recommend you use the git:// style URL, as it is much more efficient and faster than the https:// protocol.

I also recommend you read the official Git documentation. It is very well written and with loads of practical examples. It is easy reading.

http://git-scm.com/doc

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
Then start again, by logging into Github. Then deleting your lazarus repository on Github (via their website). Then browse to my lazarus repository on Github and click the "fork" button. Your account should now have lazarus repository. Github should give you instructions on how to clone it, or hook it up to your existing local repository (on your computer). You only need to do the latter, because the repository history will be the same - no need to clone it again. When you eventually do a 'git push', it will only push the changes you added to the repository.

I'll try to follow.....

I recommend you use the git:// style URL, as it is much more efficient and faster than the https:// protocol.

Unfortunately the Firewall here does not allow for the git protocol.

I also recommend you read the official Git documentation. It is very well written and with loads of practical examples. It is easy reading.

OK. I'll be back next year ;-)

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell: I just did a test (after doing nothing than what you suggested in you previous mail ).…
Michael Schnell wrote
So if in fact did an updated when on branch activenogui

Yes I expected that, but that is not an ideal setup.

Let me explain very quickly... I recommend you read at least one or two chapters of the git documentation [http://git-scm.com/doc]. Is is quick, but will give you some understanding and terminology used in git.

'git pull' actually does two commands. First it does a "fetch", which copies the latest changes to your repository, then if you are in a tracking branch, it will also do a "merge" with those latest changes.

The latter is something you DON'T want in a feature branch. I is much better to work in isolation, and update your feature branch when it suites you. Most actions in git can be undone safely, but if you set it up correctly from the start, it just makes life easier.

So, a "tracking branch" is normally a branch based of a branch on a remote repository. A 'git pull' will fetch the latest changes and merge those changes in to your local version of that branch. A "non-tracking" branch will not be touched by a 'git pull' command. You can manually update your branch my doing a 'git merge' when the time is right.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys

In fact I do see the advantage.

Somebody else could do some test with the unit I did, but if we want to include it in the IDE I suppose that hardly can done without the help of GIT, as I can't home some of the IDE experts will do this. So we will need to provide a fully functional and decently tested patch

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
include it in the IDE I suppose that hardly can done without the help of GIT,

There are alternatives, but they are much less convenient as far as I'm concerned. eg: emailing patches or zipped archives between developers, or asking the Lazarus team to create a branch for you in SVN and give you read/write access to that branch. Using Git is much faster and convenient. The lazarus team can also easily merge your changes from a Git repo into the SVN repo.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email