|
I share (I think) a sense of BitVector32 being a kind of strange creature: not close enough to the metal to be suitable for hard-core bit-twiddling; not high-level enough to carry with it state information: if I send you a BitVector32 value you can know nothing about whether it uses masks or sections, etc.
I wrote an extended 'BitVector32 a while ago (as a Class), but realizes I was duplicating what you can do with [Flags] Enums more easily/
cheers, Bill
«When I consider my brief span of life, swallowed up in an eternity before and after, the little space I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which know me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then.» Blaise Pascal
|
|
|
|
|
|
|
So where do you stuck on this?
modified 20-Sep-20 21:01pm.
|
|
|
|
|
Hello,
I have several data collecting points, each connected to different equipment type; i.e. WorkStation A with DataCollector type DC2, WS B with DC3, WS C with DC2 etc... Each data collector having different protocols.
It is my intention to write a DLL for each DC type with a getData() function in a uniform way, and thus encapsulate communication details for each type.
The idea is to have a config file with the local DC type for each station and link the proper DLL at runtime.
Is that possible?
Thank you,
modified 2-May-17 7:41am.
|
|
|
|
|
icristut wrote: Is that possible? Yes.
|
|
|
|
|
Well... thank you, I guess...
Should I post another one with "How" ??
|
|
|
|
|
Well your question is not very clear. If you know how to create the DLL, and you know how your applications can access the config data, and you know how to load a DLL at runtime ... then it should be quite simple. But maybe you have an actual programming question.
|
|
|
|
|
I don't know how to link to a specific DLL at runtime. Thank you.
I actually didn't know WHAT to google
|
|
|
|
|
icristut wrote: WHAT to google C# plugin frameworks.
This space for rent
|
|
|
|
|
|
I take it you know about interfaces, writing code to implement them, and how plugin frameworks work, correct?
|
|
|
|
|
|
|
Hi Dev,
I am using your form designer, it's too good for me. I just want to know about Form Designer is that,
how can i develop the same with your demo source. I need the complete source, how can i get the same. Please suggest.
Thanks
Mangesh Sachane.
|
|
|
|
|
Mangesh, I think you are slightly confused. You have posted this question in the general C# forum but it reads to me like you are asking about the functionality in a particular article. The articles have forums at the end - you should ask your question there as that's the best chance you have of the article writer actually seeing your question.
This space for rent
|
|
|
|
|
If you refer to an article you should post your question in the related forum (scroll down to the bottom of the article).
CodeProject is a community of nearly 13 million members where some of them have written articles. It is rather improbable that the author of a specific article reads your post here and recognises that it is about his article.
|
|
|
|
|
Hi,
I come here because I need help to convert a C code into a C# code.
This is the C code which consists of eliminating aberrant values of a serie of data, then smoothing the data.
int main(int argc, char *argv[])
{
int i, i1, n, low, high, filter=2, ntime=20 ;
double time[20]={20.0,48.0,42.3,39.9,39.0,41.4,44.0,52.0,53.1,49.7,42.0,40.1,100.0,45.0,50.0,47.0,43.1,41.0,39.0,42.2};
double average[20]={0.0},difference[20]={0.0},averagedif[20]={0.0}, localaverage ;
double timeresult[20], smoothing[20]={0.0};
for ( i = 0 ; i < ntime ; i++ ) {
low = i - filter ;
high = i + filter ;
if ( low < 0 ) low = 0 ;
if ( high >= ntime ) high = ntime ;
n = 0 ;
for ( i1 = low ; i1 < high ; i1++ ) {
average[i] = average[i] + time[i1] ;
n = n + 1 ;
}
average[i] = average[i] / (double)n ;
difference[i] = average[i] - time[i] ;
}
for ( i = 0 ; i < ntime ; i++ ) {
low = i - filter ;
high = i + filter ;
if ( low < 0 ) low = 0 ;
if ( high >= ntime ) high = ntime ;
n = 0 ;
for ( i1 = low ; i1 < high ; i1++ ) {
averagedif[i] = averagedif[i] + difference[i1] ;
n = n + 1 ;
}
averagedif[i] = averagedif[i] / (double)n ;
if ( fabs(difference[i]) < fabs(averagedif[i]) )
timeresult[i] = time[i] ;
else {
if ( i != 0 && i != (ntime-1) ) {
if ( (difference[i]*difference[i-1] < 0.0) && (difference[i-1]*difference[i+1] > 0.0)) {
localaverage = 0.0 ;
n = 0 ;
for ( i1 = low ; i1 < high ; i1++ ) {
if ( i1 != i ) {
localaverage = localaverage + time[i1] ;
n = n + 1 ;
}
}
localaverage = localaverage / (double)n ;
timeresult[i] = localaverage ;
}
else
timeresult[i] = time[i] ;
}
else
timeresult[i] = time[i] ;
}
}
for ( i = 0 ; i < ntime ; i++ ) {
low = i - filter ;
high = i + filter ;
if ( low < 0 ) low = 0 ;
if ( high >= ntime ) high = ntime ;
n = 0 ;
for ( i1 = low ; i1 < high ; i1++ ) {
smoothing[i] = smoothing[i] + timeresult[i1] ;
n = n + 1 ;
}
smoothing[i] = smoothing[i] / (double)n ;
}
fprintf ( stdout, "\n T\taverage\tdifference\taveragedif\tT result\tSmoothing\n");
for ( i = 0 ; i < ntime ; i++ )
fprintf ( stdout, "\n %g\t%g\t%g\t%g\t%g\t%g",time[i],average[i],difference[i],averagedif[i],timeresult[i],smoothing[i]);
writefich ( time, 20, "Input.dat" );
writefich ( timeresult, 20, "Output.dat" );
writefich ( smoothing, 20, "Smoothing.dat" );
return 1 ;
}
Do you have some suggestions to help me to convert this C code into C# ?
Thanks in advance !
|
|
|
|
|
This site does not provide code conversion services.
But there should be no problems to convert the calculations. Besides the variable declarations that code portions can be used as they are.
To print to the console use Console.WriteLine() . The C %g format corresponds to the default C# floating point format. If you need other formats use for example Double.ToString(string format) .
The code for writefich() is not shown. So I can only guess that it writes raw data (binary) arrays to a file. If so, use the BinaryWriter class (see BinaryWriter.Write Method (Double) (System.IO)[^]). If the files are text files use the TextWriter class instead.
|
|
|
|
|
Jochen has covered the mechanics, but the general principle is: don't even try. You get away with it for this code, but most C and C++ code is not suitable for a conversion process - you can get working code at the end, but the code you get is not "good" C# - it's generally pretty poor because C#has built in ways to do things.
Finding a lump of code on the internet that does a similar job and converting it to your language is not normally a good solution: look at the algorithm it is using and rewrite it in the target language instead.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks for your answers !
I understand that it's not perfect to convert directly C into C# but I don't know how works C# so it's pretty difficult. I'm going to see what I can do.
|
|
|
|
|
If you don't know the target language, then learn it! Otherwise you can't sort out subtle differences between the two - and you end up with the computer equivalent of Chinese manuals translated to English: "Thank you for your purchase of CHUWI products Hi12 Series Tablet poly nuclear, Hi12 is a quad-core Tablet PC products CHUWI well-launch of the brand can swim the internet." (Which is the intro to the user manual for the WookieTab)
Sorting out the code version of that can be a total nightmare unless you understand the target and source languages pretty damn well!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I don't know if this is possible. I'm relatively new to C#. I would like to overlay a largely transparent line drawing over the entire screen (or parts of it) such that the image does not receive focus. Rather, any windows directly below the image would receive focus as if the image were not there at all, yet the image would be "always on top" of the windows below. The effect would be similar to taping a line drawing on transparent plastic to the screen. I can overlay an image, but the trick is for the image to ignore mouse activity and pass the mouse to the window(s) below. Thanks for any tips.
|
|
|
|
|
Yes, it is possible, but it is not a simple matter for someone new to C#.
|
|
|
|
|
Richard: Thanks for your quick reply. I'm not really new to C#, just rusty since I haven't used it in a while. However I have in the past worked with images, windows, etc., so if you could give me some hints on the tricks necessary to create what I would call a ghost overlay I'd really appreciate it. You don't need to keep it simple or basic. I will get it. I'm guessing there would be some message re-routing or pass-through involved, but I'm not sure. Thanks again.
|
|
|
|
|