( Index )
Month

Brief Information about the March '10 CSIG Meeting

Air Log Chart - A Charting Utility to Display Air Card Data

by Bruce Arnold
AirLog    AirLog

Welcome to the CSIG, a Special Interest Group of the ACGNJ. This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs. (Some are FREE!)

Here's a brief synopsis of this month's meeting:

Last month's program recorded daily data from Network Usage to help control costs. Now, a separate program will analyze the data and plot a monthly chart. The application uses standard C++ GDI+ graphics to produce the above chart with options to print the chart and also to display the numeric data for each day. The chart can be advanced or retarded through the calendar from month to month.

Here's a brief synopsis of last month's meeting:

Air Cards are becoming extremely popular these days especially with the advent of Netbooks. They combine the features of a Wireless Network Card and a Modem in order to communicate directly from the PC to the Cell Phone Tower. As such, they provide Internet access, browsing, and file transfer without needing the normal land-based Internet provider. They can be built into the laptop or pluged-in via a USB or PCMCIA port.

That's all well and good but there is a "down side". A friend has an Air Card from Verizon and it costs him 60 dollars per month. And ... (wait for it) ... he is only allowed to download 5 Gigabytes! There is a surcharge if he goes over that amount. There is also a plan that costs 40 dollars per month but that only allows data usage of 250 Megabytes. Other phone companies have similar costs. So here's the problem: how do you keep track of your usage in order to control your cost?

The object of this program is collect data about your network send and receive usage. As can be seen in the screen shot above, the program displays a real-time account of the current daily network activity as well as the total usage during the current month. At the March meeting I plan to also graph the historic data that has been collected. (Note: be sure to place the program in your "Start Up" folder.)

Additional Comment:
If you don't have an AIR CARD, the application can be used to monitor any network traffic on your computer. For example, the above screen shot shows that my local network has transferred over 400 MegaBytes of data today. The bar graph is a speedometer showing the instantaneous speed of the network.

The program uses some of the most sophisticated Dot Net Library functions including the following:

Arrays
CopyFromScreen()
Deserialize()
DirectoryInfo()
DrawLine()
Dequeue()
Enqueue()
Font()
GetFolderPath()
MeasureString()
PointToScreen()
PrintDialog()
PrintDocument()
PrintPage()
Serialize()
SOAP: Simple Object Access Protocol
StreamWriter()
StreamReader()
String::Format()
try ... catch ... finally
WriteLine()
XML files


There are a number of ways to refer to Microsoft's latest compilers and code. Here's what Wikipedia says: The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

Microsoft .Net Framework 3.5
C++ 9.0
.Net 3.5
CLI
Common Language Infrastructure
Managed

Sample Code

// ******************************************************** // ****** PAINT values at the bottom of the ProgressBar (Netspeed) // ******************************************************** private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { sender; array<String^>^ values = gcnew array<String ^> {"10","100","1K","10K","100K","1M","10M RATE"}; int x = Netspeed->Location.X; int y = Netspeed->Location.Y + Netspeed->Height; int delta_x = Netspeed->Width / ABSCISSA_TICS; for each(String ^ tic in values) { e->Graphics->DrawRectangle(Pens::Red, x, y, 1, 4); // small vertical tic mark. e->Graphics->DrawString(tic, gcnew System::Drawing::Font( L"Microsoft Sans Serif", 6), Brushes::Black, Point(x-5, y+5)); // draw the numbers text. x += delta_x; } } // ******************************************************** // ****** Return the date in a format good for a filename - 2010_01.xml // ******************************************************** private: String ^ BuildDataFName(int yyyy, int mm) { String ^ ss = System::String::Format("{0:0000}_{1:00}.xml",yyyy,mm); return ss; } // ******************************************************** // ****** That's all folks. Form Closing. // ******************************************************** private: System::Void Form1_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e) { sender; e; DoSaveData(); } // ******************************************************** // ****** Save all of the data. // ******************************************************** private: System::Void DoSaveData() { String ^p = Environment::GetFolderPath(System::Environment::SpecialFolder::ApplicationData); IO::DirectoryInfo^ di = gcnew IO::DirectoryInfo(p); if (di->Exists) { IO::DirectoryInfo ^dis = gcnew IO::DirectoryInfo(di->FullName + "\\AirLog"); if (dis->Exists) { String ^mFile = gcnew String(dis->FullName) + "\\" + workingMonthFName; IO::FileStream ^fs = gcnew IO::FileStream(mFile, IO::FileMode::Create); try { XmlSerializer ^mSerializer = gcnew XmlSerializer(dailyBytes->GetType()); mSerializer->Serialize(fs, dailyBytes); } catch (...) //SerializationException e) { ; // MessageBox::Show("Failed to serialize."); } finally { fs->Close(); } } } }

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page