Talguy 0 Junior Poster in Training

I am spliting my soft real-time application into two processes, one is the gui and the other is the hardware communications. I would like to to have both processes monitor each other as they send data back and forth. When one detects that the other has crashed it will launch it again and continue normal operation. Would it be wise to set this up as a Peer-to-Peer style communications so that the one that crashes now becomes the client and the other other becomes the server. I was thinking of using tcp/ip locally as my interprocess communications, is this a good idea, is there something better? My Target OS is Minimal Ubuntu.

Talguy 0 Junior Poster in Training

I am programing VBA for excel and was wondering if anyone knows where I can fidn the documentation for the selection object. Also do you know how I can get the VB editor to recognize thet object so when I type Selection and put the period after it, it pops up the list of properties and methods available in the object.

Thanks in advance

Talguy

Talguy 0 Junior Poster in Training

ok would have like to ability to work on some home projects while at work.

Talguy 0 Junior Poster in Training

I don't think that is what I am looking for. Let me clarify my question. I am looking for a web based IDE that will allow me to program a C++ program in a web based interface. Upload the file to a remote server to be compiled and return the command line results or errors to me.

Talguy 0 Junior Poster in Training

Does anyone know of an web based programming utility where I can program C++ in a web page and have it compile on my remote server. I run an LAMP server

Talguy 0 Junior Poster in Training

I have recently voluteered to be a mentor for a local inexperienced FIRST robotics team. The main area I will be mentoring is the programming aspect of the competition. The controllers for last years robot was programmed using LabView but they also can be programmed in C++. The better teams in the league with the more capable bots program their's in C++. What would be the best ways to teach High School kids how to program in C++? I was think of starting out with flow charts and robot relate problems to example conditionals i.e. move robot forward till its a foot from the wall. Once they have an understanding of how to structure pseudo code algortihms then I would start getting into how to transfer the pseudo code to actual C++ code. Does this seem like a good method to start with.

Talguy 0 Junior Poster in Training

con: the file can't be easily changed. If you need to change something (i.e. add or delete info) then you might have to write a small conversion program that converts the data from from old format to new.

I thought about this and my solution is to compare the dates when they were created and if the config file is newer than the serialized file delete the serial file, parse in the config file and then serialize the data out to disk.

Talguy 0 Junior Poster in Training

I am trying to boost the performance of the startup of my realtime application. I have the interfaces laided out in a xml file that are parsed in and created into a data structure. Would it be worth while for me to struture my program so that once the interface data structure is created that I serialize the data structure and store it in a binary format on the disk so that when the program starts up again it will read in the already created data structure instead of determining what is what.

Talguy 0 Junior Poster in Training

Figured out my problem. I had to extend the textbox object with a class module. Inside the class module I had a function that handled onClick events that would search for every object that had the same tag as the active control. Below is my code for the extended class

Option Explicit

Private WithEvents TC_txtbox As TextBox
Private day As String
' Set the textbox so that its events will be handled
Public Property Set TextBox(ByVal m_tcTxtBox As access.TextBox)
    Set TC_txtbox = m_tcTxtBox
    TC_txtbox.OnClick = "[Event Procedure]"
    TC_txtbox.Enabled = True
End Property
' Handle and onClick event of the
Private Sub TC_txtbox_Click()
    ' Find out the controls that where clikck
    If Not IsNull(day) Then
        ' Highlight text inside text box
        Me.ActiveControl.SelStart = 0
        Me.ActiveControl.SelLength = Len(Me.ActiveControl.Text)
    Else
        ' Day has not been set enable text boxes
        day = Form_TimeCard.ActiveControl.Tag
        
        Dim ctl As Control
        For Each ctl In Form_TimeCard.Controls
            If day = ctl.Tag Then
                ctl.Enabled = True
                ctl.Locked = False
            End If
        Next ctl
        End If
End Sub
' Handle change event
Private Sub TC_txtbox_Change()
    Debug.Print "Shit Changed"
End Sub

Public Property Get Name() As String
    Name = TC_txtbox.Name
End Property
Talguy 0 Junior Poster in Training

yea thats not too bad. I figured from searching the web that I can create a class module with the following statement at the top of the file.

WithEvents class_name as access.TextBox

and then provide my logic for handling the event

Question: Do I need to have my textbox enabled and/or unlocked for a click event to happen cause right now I have all the boxes disabled and locked?

Talguy 0 Junior Poster in Training

that looks to only work if I click a certain box under the day and then it would unlock the reset. I want it so that a user can click any of the boxes under a certain day and it would unlock all the boxes. But each text boxes when clicked calls the same onClick function like this

Private sub handler_Click() ' all textboxes call this automatically
    ' find out the active control name
end sub

but i don't want to do this

Private sub txt_1_Click()
 call handler_event(box_name)
end Sub

Private sub txt_2_Click()
 call handler_event(box_name)
end Sub

Private sub txt_3_Click()
 call handler_event(box_name)
end Sub

public sub handler_event(name as String)
    ' perform logic here
end sub
Talguy 0 Junior Poster in Training

yea I did that with a dictionary. But how would I set it up so that when any of the text boxes are clicked they call the same event handler function

Talguy 0 Junior Poster in Training

I wrote code like that to find a control by name but what I am trying to do is I have a weekly timecard where all the boxes deailing (Clock in, clock out, lunch start, lunch end, total hours worked) I would like to give th myself the ability to edit the time card incase I made a mistake that does not match up with my company's clockin machine. So their are seven days and under each day I have 6-8 textboxes. If I click on of those textboxes under a certain day it will unlock all the text boxes above and below it so that I can edit the information. I can do this by having a click event for each text box but that would be a whole lot of redundant code for 60+ boxes. How can I have one function that handles all the click events for the form and have it get the active control so that I can determine what day of the week needs to be unlocked for editing

Talguy 0 Junior Poster in Training

Is there a way to determine what control I clicked using a global click event. I would like to be able to click a form text box table I created for my access app to enable to enable and unlock it without have a million on click event handlers

Talguy 0 Junior Poster in Training

Found my problem I was calling initDict too late in my form_open function

Talguy 0 Junior Poster in Training

I set the rs (Recordset) on line 123

Talguy 0 Junior Poster in Training

the problem seems to be happening in but_search_click not form_open. I get the error when I call Debug.Print "Search Dict count: " & weekDict.Count line 112

Talguy 0 Junior Poster in Training

Thanks that worked

Talguy 0 Junior Poster in Training

I am getting runtime error 424 when I try to access my global dictionary's count. It works fine when in the sub routine that initializes the dictionary and right after the sub routine was called inside the form_open event. Why would I be getting this error when I click a button and the event handler function needs to kow the size of the dictionary so it can iterate through its items

below is my code, sorry if it is a mess just picked up VBA a week ago. This is not a school project I am making this app to track my times that I clocked in at work so that I can ensure myself that overtime will be included into my pay check

Option Compare Database
' Global Variables
Public clk_inout As Boolean
Public weekDict
Public weekOf As Variant
Public curDay As Variant
Option Explicit
' Initialize the weekly time chart control dictionary
Public Sub initDict()
    Set weekDict = CreateObject("Scripting.Dictionary")
    Dim dayDict
    
    Set dayDict = CreateObject("Scripting.Dictionary")
    dayDict.Add "In", Me.txt_Sun_in
    dayDict.Add "Lunch_Out", Me.txt_Sun_LO
    dayDict.Add "Lunch_in", Me.txt_Sun_LI
    dayDict.Add "Lunch_total", Me.txt_Sun_LT
    dayDict.Add "Out", Me.txt_Sun_out
    dayDict.Add "Day_total", Me.txt_Sun_out
    dayDict.Add "Paid_OT", Me.txt_Sun_OT
    weekDict.Add 1, dayDict
    Set dayDict = Nothing
    
    Set dayDict = CreateObject("Scripting.Dictionary")
    dayDict.Add "In", Me.txt_M_in
    dayDict.Add "Lunch_Out", Me.txt_M_LO
    dayDict.Add "Lunch_in", Me.txt_M_LI
    dayDict.Add "Lunch_total", Me.txt_M_LT
    dayDict.Add "Out", Me.txt_M_out
    dayDict.Add "Day_total", Me.txt_M_out
    dayDict.Add "Paid_OT", Me.txt_M_OT
    weekDict.Add 2, dayDict
    Set dayDict = Nothing
    
    Set dayDict = CreateObject("Scripting.Dictionary")
    dayDict.Add "In", Me.txt_T_in
    dayDict.Add "Lunch_Out", Me.txt_T_LO
    dayDict.Add "Lunch_in", Me.txt_T_LI
    dayDict.Add "Lunch_total", Me.txt_T_LT
    dayDict.Add "Out", Me.txt_T_out
    dayDict.Add "Day_total", …
Talguy 0 Junior Poster in Training

Why is it that when I call recordCount on a rescordset it returns 1 even when I know that there is two different records in it and able to access those two records in the set.

Talguy 0 Junior Poster in Training

What would be a good book for me to learn about advanced networking (Setting up DHCP servers, Security, etc..)

Talguy 0 Junior Poster in Training

I have two questions one is kind of a newbie question and the other one is a little more advanced. I have been coding C++ off and on for the past couple of years as a hobby and a little for my EE classes. I usually in my class reference all my class members with the keyword "this->" when using them internally in my methods. I always wondered if this was a good practice or not OR os does it only apply to certain situation.

For my advanced question, I have some hardware that I would like it to send me information instead of my polling it. Right now I have it structured to be polled for data using a thread. This data is placed in a circular buffer awaiting further processing by the main thread. I was thinking that I could derive my Hardware class as a Event Source from the gtkmm gui library. When the hardware object thread detects that the hardware has just sent a packet of data over the serial RS-232 connection it will trigger the onEvent callback and then place the data into the circular queue. Should I adjust my hardware interface code to be an event based model or should I leave as the thread deticated polling main loop. I currently use libSerial for my comms.

Talguy 0 Junior Poster in Training

Thanks for the info. I'll try to do it the easy way by using mutexs and see if that meets my needs.

Talguy 0 Junior Poster in Training

I am still working on my realtime application for my car that will be running on Minimal Ubuntu and the gtkmm library. My current application runs alright for a singly thread application. I am in the process of multi-threading it (still learning threads). What I thought would be the best way to rewrite the back end was using a single queue shared across three threads. Someone suggested a better method where I would have a circular buffer in each hardware communication thread. The somehow communicate with the circular queues from the main thread to get the oldest data.

My question is how can I communicate from the main thread to a worker to get data from the buffer in a lock less or in the least amount of locks using either pthreads or glibmm::threads?

Talguy 0 Junior Poster in Training

I am trying to draw a gradient in a rectangle using cairomm. I found the code below which helped a lot. My problem is I want to turn this rectangle into a progress bar. Is there a way to modify the code so that it at a certain percentage of the bar the gradient only shows in that length of the bar. also the gradient needs to not be the stop and start colors, but needs to be the start color to color in the gradient corresponding to the percentage of the rectangles length. How would I go about doing this? These would be used in a automotive application that I have been developing.

// Create the context for the widget
    Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context();

    ...

    // Rectangle
    double x0 = 0.0;
    double y0 = 0.0;
    double x1 = 100.0;
    double y1 = 100.0;

    // Colors
    Gdk::Color start_color( "blue" );
    Gdk::Color end_color( "midnight blue" );
    
    // Create the linear gradient diagonal
    Cairo::RefPtr< Cairo::LinearGradient > background_gradient_ptr = Cairo::LinearGradient::create (
        x0, y0, x1, y1);
    
    // Set grandient colors
    background_gradient_ptr->add_color_stop_rgb (0, 
            start_color.get_red_p(), start_color.get_green_p(), start_color.get_blue_p());
    
    background_gradient_ptr->add_color_stop_rgb (1, 
            end_color.get_red_p(), end_color.get_green_p(), end_color.get_blue_p());

    // Draw a rectangle and fill with gradient
    context->set_source (background_gradient_ptr);
    
    context->rectangle (x0, y0, x1, y1);
    
    context->fill();
Talguy 0 Junior Poster in Training

look into openCV and pattern finding.

Talguy 0 Junior Poster in Training

sounds like you could use a little help from Beej.

so i could do something like this on the transmitter's end

int sendall(int s, char *buf, int *len) {
    int total = 0;        // how many bytes we've sent
    int bytesleft = *len; // how many we have left to send
    int n;

    while(total < *len) {
        n = send(s, buf+total, bytesleft, 0);
        if (n == -1) break;
        total += n;
        bytesleft -= n;
    }
    *len = total; // return number actually sent here
    return n==-1?-1:0; // return -1 on failure, 0 on success
}

and on the the receiver's end I would be able to get the total length of the data I am sending from a property in the TCP header or in where ever i define it if UDP. From that I could just modify the code above to receive data that has a larger size than the transfer frame can handle

Talguy

Talguy 0 Junior Poster in Training

thanks man for the links. Was searching all of google and couldn't find anything.

I have another question a little off topic from my original question but still socket related. Is there a callback in bsd sockets that lets me know when a chunk of data has been received so that I can determine how much data is left to be received.

Talguy 0 Junior Poster in Training

I have created a icmp ping function but it doesn't always work due to the firewall of the computer I am trying to ping. I heard you can get around this using a tcp ping. How can i construct a tcp ping packet. I did a little research and it uses the ack, syn flags in the packet, but don't get how to tell if the computer responded correctly since it is random sequences.

Talguy 0 Junior Poster in Training

I'm not looking to use a scripting language. I was looking to have it coded in c/c++ and port into a mobile application.

Talguy 0 Junior Poster in Training

I have been coding an IP scanner for god knows what reason. The program kind of works. It does find active computers on the network but for some reason it does not find my computer using its network ip or its internal ip (127.0.0.1). Also it can not find any of my fios set top boxes. Ping is able to find every computer or device that is active on the network. Another problem I have been seeing with the program is that it finds the two active device that it is able to connect with right away then pause for a long long time (a minute or three) before printing out information about not being able to connect to ip x.x.x.x. I think part of this reason is due to not getting a lock to print to the console but i'm not sure this is the first time I'm using threads. I looked in the task manager and it shows 0% usage of the CPU when the program stalls. Could someone take a look at my code and suggest and changes or enhancements to it.

Thanks in advance

#include <string>
#include <sstream>
#include <iostream>
#include <pthread.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

void ipStrToInt(unsigned int (&ip)[4], std::string);
const std::string get_ip();
const std::string inttostr(const unsigned int);
void *scan(void *ptr);

unsigned int IP[4] = {0,0,0,0};
unsigned int beginIP[4] = {0,0,0,0};
unsigned int endIP[4] = {0,0,0,0};
unsigned int startPort=0, stopPort=0;
unsigned int thread_cnt = 0, upIPcnt = 0;
bool …
Talguy 0 Junior Poster in Training

I have a verizon fios router and would like to setup some subnets. Does anyone know how I could have all the wireless computer on the network have the ips 10.100.xx.xx and all my hardwired devices to have the ips 192.168.xx.xx.

Talguy 0 Junior Poster in Training

I'm writing a shell script for I can launch a program from the terminal using ./AppName but how can i get the return value either 0 or 1 to determine if the program executed correctly

Talguy 0 Junior Poster in Training

that worked. Thanks a lot

Talguy 0 Junior Poster in Training

Can I use libxml++ to parse html. I'm trying to find all the images in a xml file and store the image data directly into the src attribute of the web page.

I know there is a bit of a difference between html and xml that's why I am asking the question

Talguy 0 Junior Poster in Training

Does sqlite contain a function that would look at every row in a column and find the ones contain a string I supply it with. I'm trying to make a dynamic database search that would query retrieve rows from the database every time I type a new letter into my search box for a desktop app.

Talguy 0 Junior Poster in Training

I can write a procedural application fine with graphics just fine. I have a new project where I am finally going to learn how to code with concurrency in mind. So I want to make an alarm clock that can have repeating alarms and selectable alarm tunes through itunes or something similar. When an alarm is fired it displays and overlaid window over everything. If snooze is clicked then the set snooze time is decreased by so many seconds each time it is clicked. if dismiss is clicked then a game like simon would show up and the user would have to win a round to cancel the alarm.

So with my description established now comes the question on how to structure the program's code. So would i have the graphics and the interface run in one thread while a seperate thread runs the timer and the function that compares the current time and date with the alarms. Also would the code that controls a media player go in another thread?

Talguy

Talguy 0 Junior Poster in Training

Not really sure if this is the right forum but it seems to best match my question. I am looking for a computer tool kit that I can use for work. Requirements are able to carry basic tools to to fix computer hardware and also it needs to have a CD sleeve or two to store my software tools. Hasn't anyone come across something like this before, I've been searching every where online and could not find something like it. If you seen something similar could you point me to it.

Talguy

Talguy 0 Junior Poster in Training

it could be connected to the computer via a USB port but even though that device is physically using the usb port it could be functioning as a virtual com port. If it is you can use any serial port library that is compatible with windows to read the data that is on the magnetic strip.

Talguy 0 Junior Poster in Training

your command should be this ./vehicle

sorry forgot to tell you there was no space and carrots when running the command in the terminal

Talguy 0 Junior Poster in Training

if you program compiled correctly then there shouldn't really be a problem with the could. In the terminal windows you want to change the directory to the directory where your executable is. The type the follow without the quotes "./ <your file name>" this will execute your program

Talguy 0 Junior Poster in Training

When working in linux the program that I like to use Netbeans to code c++ applications in is netbeans w/ c++ plugin. Takes a little time to set your project up but once its done your set all you have to do is hit build and run.

Talguy 0 Junior Poster in Training

So I can crop an image in cariomm and display it to the canvas, but what I want to do is crop the image and save the cropped image to a Cairo::ImageSurface so that I can paint just the section of the overall image to the screen with out have to recrop the image all the time. Below is the code that I use to crop the image and paint it to the screen.

Cairo::RefPtr<Cairo::Context> context;
Cairo::RefPtr< Cairo::ImageSurface > image_surface_ptr_  = Cairo::ImageSurface::create_from_png("image.png");

context->save();
context->set_source (image_surface_ptr_, 0.0, 0.0);
context->rectangle (0.0, 0.0, somewidth, someheight);
context->clip();
context->paint();
context->restore();
Talguy 0 Junior Poster in Training

I am revisiting my EE senior design project that I finished up about 8 months ago. We basically took your vehicles instrument cluster and replaced it with a computer and graphically rendered your vehicles metric with the help of a datalogger. For the graphics I used cairomm for its vector graphics and ability to draw png files to the canvas. I also used gtkmm for the drawing canvas and its interrupt functions. Our final product we could only crank out 6.5 frames a second. I am currently trying add some features that we did not get too but I want to be able to draw a minimum of 20 frames a second to the screen. Does anyone know of another graphics library other than OpenGL for linux that can do 2d graphics and draw png files to the screen much faster than cariormm. If not does anyone know any good optimization tips for using the cairo graphics library.

Talguy 0 Junior Poster in Training

Thanks that was the error

Talguy 0 Junior Poster in Training

Last week I was goofing around with multidimensional vectors and removing an element from each row. I got my code to remove and element from each row working inside int main, but when I put all this code inside of a function I started to get errors. The common error that I am getting is

main.cpp:83: error: conversion from ‘__gnu_cxx::__normal_iterator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >’ to non-scalar type ‘__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >’ requested
main.cpp:84: error: no match for ‘operator<’ in ‘ITx < ((std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >*)Mat)->std::vector<_Tp, _Alloc>::end [with _Tp = std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, _Alloc = std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]()’

not really sure why I am getting this error. Not that great with pointers and kind of understand them to a point for a non computer sci major. Why would I be getting this error and how can I correct it. Below is my code

#include <iostream>
#include <string>
#include <vector>


void removeElement(std::vector<std::vector<std::string> > &Mat, std::string El);

int main() {

    std::vector<std::vector<std::string> > voteMat;
    std::vector<std::string> chairRank;

    std::string temp;

    int NC,NV;
    // NC -> number of candidates
    // NV -> …
Talguy 0 Junior Poster in Training

Does anyone know how I would be able to remotely manage a couple of computers (Windows) where I can boot them up and shut them down remotely from a central low power computer. Also I would like to remotely schedule the power down of external monitors.

Talguy 0 Junior Poster in Training

Thanks that helps a lot. I also found that I had a major error in my code also. I never actually pushed the variables onto the map, so every time I tried to accessed the map there wouldn't be anything to access.

Also I have worked with make files before just that this time I was using Xcode as my IDE and it doesn't generate a make file. Sorry I forgot to write one up to make compiling easier.

Talguy 0 Junior Poster in Training

Attached is my code compressed in a zip file. Also any tips or pointers on how to write good code would be helpful since I have been teaching myself this stuff programmer.

Talguy 0 Junior Poster in Training

I have been posting a bit about my current side project, a scripting language interpreter. I have gotten past my getline error I talked about in a previous post and am now trying to get the results from the script. I created a map of all the labels in the script with a list of every operation that happens under the list. like this map<string, list<Operation *>>. When ever I try to access the list at a given key I am returned with a bad access error. I try to access the list in the map like this

Operation *currentOP;
    std::list<Operation *> *currentLst;
 
    std::map<std::string,std::list<Operation *> >::iterator labelPtr;
    
    labelPtr = this->labelOPMap.find(currentLabel);
    *currentLst = labelPtr->second; // Problem Here

This is how I am pushing the list onto the map

if(this->hasLabel(programLine)) {
    // push the label and OPlst onto the map
    labelOPMap[label] = *OPlst;
                      
    // Get the new label
    label = this->getLabel(this->positionOfChar('[',programLine),programLine);
                    
    if(!this->labelExist(label)) {
        // Clip the label off the string
        programLine = programLine.substr(this->positionOfChar(']',programLine)+1);
                        
        // Create a new Operation List
        OPlst = new std::list<Operation *>;
    }
}

// Parse the current line of the document and return an operation object
OP = this->ProcessLine(programLine);
                
// push the Operation onto the list
OPlst->push_back(OP);

Does anyone know why I would be getting an bad access error. I am not the best with pointers either.