A Tiny Meter + Animated Tray Icon Class

User projects written in or related to FreeBASIC.
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

A Tiny Meter + Animated Tray Icon Class

Postby calstover » Aug 24, 2007 10:05

So many netmeters, none I like. I want to see what's going on with super fast refresh, but little or no CPU load. I don't care what happened 5 minutes ago, just gimme a current average speed and a byte counter. I want meaningful indications for low and high traffic. I want a sizeable window.

So its a logarithmic scale bar graph... all buffered GDI in a sizable dialog. I've only completed the top graph (downloads)... the bottom will be the same for uploads. I also plan to add tickeys for peak speed and for disk freespace. The scale can be over any range, but it's currently set by constants in the .bi file.

http://calstover.com/snews/freebasic/atinymeter/

(updated link 16-Oct-07)

compile (I'm using 0.18 beta dated June 30):
fbc -s gui netmeter3.bas netmeter3.rc

Then fire it up and go download something. Click the bmp to change adapters (if you have more than 1 enabled) and to rezero the counter. Does it work with dialup adapters? How hilarious/ignorant is my code? What would you change? Finally, can someone explain how can I insert at the beginning of an array without moving every item down one at a time? I've GOTTA be doing that wrong. (see line 495)
Last edited by calstover on Dec 25, 2007 3:33, edited 2 times in total.
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Postby DrV » Aug 24, 2007 19:33

There really is no good way to insert at the beginning of an array; however, if you just think about things a bit differently, you could interpret any element as the "beginning" of the array, wrapping around when you get to the end - a circular buffer.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Aug 24, 2007 20:45

You could try this to insert at the beginning of the array...

Code: Select all

Sub NetMeterStats.AddData (uiBC As UInteger, dbTS As Double)
Dim Temp(1 To NDP_MAX) As NTMTR_DATA_PT

   If (uiBC = 0) Then Exit Sub

   MoveMemory @Temp(2), @DataPts(1), SizeOf(NTMTR_DATA_PT) * (NDP_MAX-1)
   Temp(1).uiBytCnt = uiBC
   Temp(1).dbTimStp = dbTS
   MoveMemory @DataPts(1), @Temp(1),  SizeOf(NTMTR_DATA_PT) * (NDP_MAX)

   If StartTm = -1 Then ReZeroCtr()

End Sub
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

Postby calstover » Aug 31, 2007 3:57

vdecampo wrote:You could try this to insert at the beginning of the array...


Thanks for that; it was just what I had in mind and had no idea how to implement... later I will build up a proper circular array object.

Another plea for help:

I'm using a dialog and GDI simply because I can't find a way to implement a standard freebasic window while properly handling the resizing and size limiting like I've done here. If I can, I'll switch before going too much further. Anybody have examples or pointers?
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

new version

Postby calstover » Oct 17, 2007 5:35

I've fleshed it out some, renamed it A Tiny Meter, and posted it at my site.

http://calstover.com/snews/freebasic/atinymeter/
Voltage
Posts: 110
Joined: Nov 19, 2005 7:36
Location: Sydney, Australia
Contact:

Postby Voltage » Oct 18, 2007 1:11

Cool proggy. :)

I downloaded the program from your website, but I had to rename it to an .exe ?

Anyway, after that it worked.... but I had no idea what it was doing... until I reviewed the web page.

My advice would be to label the program itself, so that the user has immediate visual feedback as to what is what. Just label it as you have the web site diagram.
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Postby Kot » Oct 18, 2007 15:31

I don't know what's wrong, but it doesn't work on my computer, it eats all the processor time and doesn't even show. It's visible only in Windows Task Manager when I must kill the process because there is no other way to turn it off. WindowsXP, Avira Antivir Personal Edition, PCTools Firewall Plus.
axipher
Posts: 891
Joined: Dec 27, 2005 16:37
Location: Sudbury,Ontario
Contact:

Postby axipher » Oct 18, 2007 16:08

Windows XP Pro SP1 Zonealarm, AVG, Spybot

Works beautiful, nice and clean too, Zonealarm didn't even ask me to allow it or anything which is nice, possibility of minimize to tray?
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

Postby calstover » Oct 23, 2007 2:57

Kot wrote:I don't know what's wrong, but it doesn't work on my computer, it eats all the processor time and doesn't even show. It's visible only in Windows Task Manager when I must kill the process because there is no other way to turn it off. WindowsXP, Avira Antivir Personal Edition, PCTools Firewall Plus.


Are you using dialup? I know the adapter checking is not very robust!
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

Postby calstover » Oct 23, 2007 3:00

axipher wrote:Windows XP Pro SP1 Zonealarm, AVG, Spybot

Works beautiful, nice and clean too, Zonealarm didn't even ask me to allow it or anything which is nice, possibility of minimize to tray?


I want to, but it's not within my skill level. Yet. How is CPU usage for you? Ima add a speed setting anyway, but I'm curious.
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

Postby calstover » Oct 23, 2007 3:04

Voltage wrote:Cool proggy. :)

I downloaded the program from your website, but I had to rename it to an .exe ?

Anyway, after that it worked.... but I had no idea what it was doing... until I reviewed the web page.

My advice would be to label the program itself, so that the user has immediate visual feedback as to what is what. Just label it as you have the web site diagram.


Yeah posting an exe is probably a bad idea... I should at least zip it.

I'm fighting the labeling vs cleaniliness issue. I'll add them and another switch to turn 'em off. They're not needed once you know what you're looking at.

How is the text? Should the overall size be smaller?
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

Postby calstover » Oct 23, 2007 3:09

axipher wrote:Zonealarm didn't even ask me to allow it or anything


It simply checks the byte counts. Doesn't mess with the TCP/IP stack, and I wouldn't know how to do that anyway.
axipher
Posts: 891
Joined: Dec 27, 2005 16:37
Location: Sudbury,Ontario
Contact:

Postby axipher » Oct 23, 2007 18:39

BTW: With everything running I could (AutoCAD, Adobe Photoshop CS2, FireFox, Zonealarm, etc), it still ran smoothly at ~0-3% CPU
calstover
Posts: 68
Joined: Aug 21, 2006 16:51

Now with animated tray icon goodness

Postby calstover » Dec 25, 2007 2:23

I've created a simple trayicon class, fbTrayIcon, which provides a DC you can draw on with GDI. The gizmo converts your drawing into an Icon and sends it to the system tray. (see fbtrayicon.bi)

It also sends a message to the parent window (you supply it's handle to the constructor) when mouse activity occurs on the tray icon. To see how this works, check lines 59-69 in a_tiny_meter.bas

I've wrapped that into another class, specialized for A Tiny Meter, atm_fbTrayIcon. This type simply takes two integers 0-32 and draws little progress bars on the tray icon. To make your own animated icon, you should modify this file. (see atm_fbtrayicon.bi)

You'll find these files in source code link on the project's web site:

http://calstover.com/snews/freebasic/atinymeter/

I also fixed some resource leaks. They were due to resources created before testing to see if the routine should exit. Seems fantastic now but took forever to figure out ;-)

Return to “Projects”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 5 guests