|
Probably because you are always looking at the same offset into the RFMAccess::TSimHeader_arr and RFMAccess::TSimSignal_arr structures - zero!
|
|
|
|
|
see every occurrance of "TSimSignal_arr[0]."
I'd also consider cleaning up your data structures. I've been doing this for 10+ years, and I still can't stand doubly indexed (2d) arrays used for characters.... not intuitive at all.
<br />
struct TSimHeader<br />
{<br />
char Name[45][20];<br />
char Unit[45][20];<br />
double Min[45];<br />
double Max[45];<br />
int SignalCount;<br />
int SimStatus;<br />
}static TSimHeader_arr[10];<br />
<br />
<br />
struct TSimSignal<br />
{<br />
double Value[45];<br />
double TimeStamp;<br />
}static TSimSignal_arr[10];<br />
couldn't this be something more like:
<br />
#define MAX_ENTRIES (45)<br />
#define MAX_ARRAY_SIZE (10)<br />
#define MAX_STRING_SIZE (20)<br />
<br />
struct TSimHeaderEntry<br />
{<br />
char Name[MAX_STRING_SIZE];<br />
char Unit[MAX_STRING_SIZE];<br />
double Min;<br />
double Max;<br />
};<br />
<br />
<br />
struct TSimHeader<br />
{<br />
TSimHeaderEntry Entries[MAX_ENTRIES];<br />
int SignalCount;<br />
int SimStatus;<br />
}static TSimHeader_arr[MAX_ARRAY_SIZE];<br />
<br />
<br />
struct TSimSignal<br />
{<br />
double Value[MAX_ENTRIES];<br />
double TimeStamp;<br />
<br />
}static TSimSignal_arr[MAX_ARRAY_SIZE];<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
strcmp() returns 0 if the strings are the same, non-zero if they are different. Your if statements will always be executed if the strings are not the same, which I assume is the majority of times. It looks like you want the if statements to be executed if the strings are equal, so you'll need to modify them like this:
if(strcmp(temp, "pla") == 0) etc...
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I would like to query my monitor for its EDID data. From another thread here I got an advice to communicate directly with my video card (since there's no Windows API call for querying the EDID, only in the DDK), but I don't know how to use the nvidia driver's functions in my code.
I thought there was a lib or a dll which I had to link into my code and a .h file which contains the name of the functions included in the lib or dll. I've downloaded the nvsdk which contains everything from openGL to directX but there's nothing there I could use.
I've also checked NVidia's developer site, but I haven't found any valuable info regarding my problem.
Any ideas?
|
|
|
|
|
well.. in a program i have got a lot of functions like these (it is function based, so no chance in using a class [would be my first idea to solce this problem])
fun2;
fun3;
void fun1(int i)
{
if(i == 0)
fun2();
else
fun3();
}
well.. now there are a lot of fun2's and fun3's so there are a lot of fun1's too..
is there any neat solution doing this with templates ?
thanks for your help,
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Not with templates that I can think of, but you can use the preprocessor...
#define CHOOSE_FUNCTION(i, f1, f2) do { if((i) == 0) (f1)(); else (f2)(); } while(0)
CHOOSE_FUNCTION(i, fun2, fun3);
CHOOSE_FUNCTION(j, fun4, fun5);
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Bernhard wrote:
is there any neat solution doing this with templates ?
What you might have been thinking of was template specialisation based on an integer constant - it's a possiblity, but it's unlikely that it would work. Most of the time you want to dispatch the function based on a number specified at compile time run time.
Bernhard wrote:
it is function based, so no chance in using a class
Ryan's solution might be the best in this case, but consider the alternative of using a standard map to dispatch the functions
#pragma warning(disable:4786)
#include <iostream>
#include <map>
#include <functional>
using namespace std;
typedef void (*func)();
void fun1()
{
cout << "a" << endl;
}
void fun2()
{
cout << "b" << endl;
}
int main()
{
std::map<int,func> m;
m[1] = &fun1;
m[2] = &fun2;
m[1]();
m[2]();
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
well, this could really be a solution..
but the problem is somewhere different:
i have got 2 sets of functions, doing the same thing..
it depends on 1 parameter which function i have to chose (from set a or set b)
!! WARNING PSEUDOCODE !!
!! this is not intended to run, just to show the concept !!
void a_get();
void b_get();
void a_set();
void b_set();
void get()
{
if (a)
a_get();
else
b_get();
}
void set()
{
if (a)
a_set();
else
b_set();
}
now it is very cumbersome to write this for every function and i wanted to know if there isn't any possibility to write something like:
template <fun1, fun2>
{
if (a)
fun1;
if (b)
fun2;
}
template<&a_get, &b_get> get;
template<&a_set, &b_set> set;
yeah.. and this was what it was all about.
thanks for your efforts (both of you, altough i write you back)
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
well.. after writing the pseudocode (thinking again about this problem), i found out this solution by myself..
template <void f1(), void f2>
class call_fun
{
call_fun () {};
public:
call_fun (char c)
{
if('A' == c)
{
cout << "call_fun: A selected" << endl;
f1();
}
else
{
cout << "call_fun: not A selected" << endl;
f2();
}
};
};
void fun11()
{
cout << "Hello from fun11" << endl;
}
void fun12()
{
cout << "Hello from fun12" << endl;
}
void fun21()
{
cout << "Hello from fun21" << endl;
}
void fun22()
{
cout << "Hello from fun22" << endl;
}
int main()
{
call_fun<&fun11, &fun12> a ('A');
call_fun<&fun11, &fun12> b ('B');
cout << endl;
call_fun<&fun21, &fun22> c('A');
call_fun<&fun21, &fun22> d('B');
return 0;
}
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
I have two questions.
1. Is there any way to check to see if there is a device on the other end of the serial port. The device itself does not have anything that will send out "yes i am here".
2. The device i am connecting to constantly send data unless a stop command is issued, how do i keep receiving the incoming data? Right now I execute the following code using a receive button, but I have to keep pressign the receive button to keep getting the code:
// Receive on the Serial Port
if( m_MySerialPort.IsOpen() )
{
m_bytesRead = m_MySerialPort.Read( m_readBuffer, 100 );
m_ctrlTextIn.SetWindowText(m_readBuffer);
}
else AfxMessageBox(" Compass not responding in Recieve function!");
|
|
|
|
|
1) If the device is constantly sending data unless a stop command is issued then you already know if it is attached (or that something is attached). Just send a start command, if you receive any data it is attached.
2) You could start a timer (StartTimer(), KillTimer()) or use a seperate thread to poll the serial port.
INTP
|
|
|
|
|
Hey,
I've got one question. I need to display an AutoCAD or Microstation drawings within a SDI frame. But I don't know how to do this. Is it possible with DirectX or OpenGL??
It would be nice to bet some helpfull informations.
Thanks for any replies!!!
|
|
|
|
|
Check www.opendwg.org[^]. There's a toolkit and a viewkit which put together should help. It's members-only downloads, but thats the most I can think of at the moment. There are a couple of articles here, but they are for writing DXF, not reading it.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I would like to edit a Russian (Cyryllic) string in MFC's Edit/RichEdit box, then DDX it and write it to file... of course to be read again and put into the edit box.
Should I use Unicode (i.e. compile my application for Unicode)? Will it work with Win9x? How do I setup Edit box for cyryllic font?
Regards,
BB
|
|
|
|
|
My inclination would be to use Unicode, but I haven't worked with a non-english version of Windows, so I don't know if it's absolutely necessary. If you want it to work on an english version of Windows, then yes, you'll have to use Unicode. In this case, it won't work with Win9x, unless you link with the Microsoft Layer for Unicode (check the MSDN docs for this). You should be able to use any font that supports cyrillic characters. I think the Arial Unicode font does - you'll have to check, and distribute one with your app if necessary.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is there a way to get the number of logical processors in a Windows XP system? If I see that the application is running on Windows XP and that hyperthreading is enabled (how do I do that?) I guess I could just divide by two?
Are there any api calls for this? I found something about GetLogicalProcessorInformation , but that didn't seem to be what I need.
Thanks,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
What is the difference between normal CPU and logical CPU? One solution is GetSystemInfo().
Kuphryn
|
|
|
|
|
With Hyperthreading you have physical processors and logical processors. Example, let's say:
I have to physical processors each one is also a logical processor. I then enable hyperthreading on both CPUs. Windows now thinks that I have 4 logical processors, that being each physical processor now represents two logical.
I wish to be able to get the number of physical processors and then also the number of logical processors. The reason for this is that if I were to have 4 real physical processors I might then spin out 8 threads. On the other hand, if I have only two physical processors that each are hyperthreaded I would only spin out 6 threads (logical processors aren't as capable as a physical processor).
Hope this offers some explanation.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Try GetSystemInfo. I believe that the SYSTEM_INFO.dwNumberOfProcessors returns the number of logical processors (although I could be wrong).
onwards and upwards...
|
|
|
|
|
see answer to kuphryn...
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I found the answer on Intel's site:
CPU Counting Utility[^]
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I need 2 structures that have references to eachother. In this situation I need to do some forward declaring. I know how to do this when using a reference (pointer) to the other structure, but I don't want to use pointers so I don't have to create the structure with new and destroying them with delete when I don't need them anymore.
So what my question basically comes down to, is it possible to have circular references without using pointers? e.g. something like:
<br />
typedef std::list<struct TParamValue> TParamValues;<br />
typedef std::list<struct TParamField> TParamFields;<br />
<br />
typedef struct TParamValue<br />
{<br />
CString value;
CString description;
TParamFields fields;
} TParamValue;<br />
<br />
typedef struct TParamField<br />
{<br />
unsigned long index;
unsigned long bits;
CString description;
CString currentValue;
TParamValues values;
} TParamField;<br />
|
|
|
|
|
Brian van der Beek wrote:
So what my question basically comes down to, is it possible to have circular references without using pointers?
No. To fully specify a structure, the compiler has to know the size of every member, which means they have to be fully specified. If you have a circular reference, neither of the structures are fully specified, so neither can be compiled because they rely on the other one.
It's a never-ending loop which the compiler can not sort out. The only way to solve this problem is using pointers or references.
However, your situation may work (I'm not sure what the compiler might complain about). std::list internally uses pointers, so the compiler might accept it. You can try, but don't be surprised if it doesn't work.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
It's a never-ending loop which the compiler can not sort out. The only way to solve this problem is using pointers or references.
I was afraid of that.
Ryan Binns wrote:
However, your situation may work (I'm not sure what the compiler might complain about). std::list internally uses pointers, so the compiler might accept it. You can try, but don't be surprised if it doesn't work.
I doesn't work. I do have a question about your remark though. Does std::list use pointers? I always though it just stored the specified type, i.e. <T> instead of <T*> .
|
|
|
|
|
Brian van der Beek wrote:
I do have a question about your remark though. Does std::list use pointers? I always though it just stored the specified type, i.e. <t> instead of <t*>.
I was wrong It stores the object as a member of a private structure - which it stores pointers of. I forgot about that . So no, your situation won't work.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|