|
We are going to add a USB connection to our system.
I am estimating that this will at least double the speed of transmission from the little box to the PC/GUI.
There is a real possibility that we will send the data at 10x the existing speed. Maybe 14x
The GUI amasses 8192 bytes per second, and draws 20 graphs from that one second.
The samples will still be one second apart, they will just jump across ten times faster.
Has anyone gone through this biz before ? Is there anything my GUI/PC guy needs to beef up in the GUI to handle this ? He has a thread for the data reception and a thread for the graphing of that data.
|
|
|
|
|
That really depends on how the threads communicate. Does the data reception thread send the data to the GUI thread, or does the GUI poll the data thread. Also important: where and how is the data stored.
The biggest issues I foresee are that your data thread could become too fast for the GUI thread and the latter starts lagging behind, or when the GUI thread locks some resource that this could cause the data thread to hang on the lock too much to keep up with the increased data.
|
|
|
|
|
public enum Type
{
None = 0,
Found =1,
NotAval = 2
};
public enum ShortType
{
None = 0,
Fd =1,
NA = 2
};
class Properties
{
public Type type;
};
List<Properties> props;
...
...
//
|
|
|
|
|
Can you avoid that situation in the first place? Cast immediately while populating that list, for example. Or cast when getting the items out of the list.
ptr_Electron wrote: Not happening. At least, not really. Someone will probably suggest LINQ's Cast<T>[^], but all that does is change a normal loop into a lazy loop.
|
|
|
|
|
|
Go back and fix the problem. If you want long and short names you might be interested in a DescriptionAttribute.
|
|
|
|
|
|
Even if you could cast a List<T> to a different type, (which you can't without playing silly buggers a lot) you couldn't do what you want: the list is not of the enum, it is a List of the Class containing the enum, which is a very, very different item indeed.
Summing you want to do this to have human readable names for your enum elements, have a look at this: Human readable strings for enum elements[^]
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
If the enums are in your sources, try the solutions already suggested.
But if you cannot change the sources (e.g. Third Party), you may add a wrapper class - thus actually introducing a third enum which you use in your application, and whenever you need to communicate with Third Party, the wrapper does the translation. Not a nice solution, but feasable.
|
|
|
|
|
Hi,
I'm trying to copy connectionStrings from C:\test2\web.config to c:\test1\app.config. In web.config, connectionString element looks as below. both config files are not belong to my project.
<connectionStrings>
<add name="SqlServerConnectionString" connectionString="server=NAPALDEVDBS02.dev.psisystems.local\DEV08; database=VPO1; User ID={0}; Password={1}; Pooling=True; Min Pool Size=5; Max Pool Size=40; Connect Timeout=10;" providerName="System.Data.SqlClient" />
<add name="SqlServerConnectionPropertiesString" connectionString="Initial Catalog=VPO1;Integrated Security=False;Uid=WSAccountData;Pwd=drUc5u8r;" providerName="System.Data.SqlClient" />
<add name="VPO1" connectionString="server=NAPALDEVDBS02.dev.psisystems.local\DEV08; database=VPO1; User ID=VPOServer; Password=Mon186ster;" />
</connectionStrings>
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = @"c:\test1\app.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
ExeConfigurationFileMap fileMapWeb = new ExeConfigurationFileMap();
fileMapWeb.ExeConfigFilename = @"C:\test2\web.config";
Configuration configWeb = ConfigurationManager.OpenMappedExeConfiguration(fileMapWeb, ConfigurationUserLevel.None);
var connectionStringsWeb = (ConnectionStringsSection)configWeb.GetSection("connectionStrings");
Thanks in advance.
|
|
|
|
|
Hi all!
Is there a way of checking overflow, carry, etc on integer arithmetic in C#?
I'm an old assembler programmer and I sometimes would like this funtionality when performing bitwise operations on integer variables.
Also, I would like to see ROL and ROR (rotate left, rotate right). Do these exist in C#?
For performance reasons, implementing a class realizing this is not an option.
Thank you.
|
|
|
|
|
See Arithmetic Exceptions[^]. ROL and ROR are not part of the language, you would need to write your own versions.
hanzibal2 wrote: For performance reasons, implementing a class realizing this is not an option. If you are worried about performance then you should not be using C#.
Use the best guess
|
|
|
|
|
Quote: ROL and ROR are not part of the language
Although << and >> (as well as <<= and >>=) are equivalent to SHL and SHR if I remember my aseembly language correctly...
|
|
|
|
|
You are, of course, correct. I have only once or twice in 20+ years of C/C++/C# programming felt the need for rotation shift operators. But in my assembler days I probably used them all the time.
Use the best guess
|
|
|
|
|
Thank you for your answer.
There are so many advantages with C# over almost any other language that I just can't live without and since C# is the language I chose for my project, why not write repetitive sections as effective as possible?
You are correct, but you answered a question that I didn't ask
|
|
|
|
|
hanzibal2 wrote: You are correct, but you answered a question that I didn't ask Where exactly did I do that?
Use the best guess
|
|
|
|
|
Did you consider the checked[^] keyword?
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
Great, that's exactly what I was looking for. Thanks!
|
|
|
|
|
checked is horribly slow. If you're working with the carry as a performance optimization, you're better off calculating it manually. See Hacker's Delight chapter 2.12, Overflow Detection.
|
|
|
|
|
Hello all, got myself a confusing mess here. I am going to provide as much information as possible, just let me know if something doesn't make sense.
On load, I have a file check and backup that is executed. The backup, doesn't work at all (the Move) and the create, only creates for the first item in the cluster. Here is the code.
string instText = comboInst.GetItemText(comboInst.SelectedItem);
string folder = instText.Substring(0, 4);
string path = @"C:\Nightly\Institutions\" + folder + "\\";
string email = folder + "Email.txt";
string sourceFile = @"C:\Nightly\Institutions\" + folder + "\\" + folder + "Email.txt";
string destinationFile = @"C:\Nightly\Institutions\" + folder + @"\Archive\";
foreach (string file in settingsFiles)
{
if (File.Exists(path + email))
{
File.Move(sourceFile, destinationFile);
}
if (!File.Exists(path + email))
{
Directory.CreateDirectory(path);
using (File.Create(path + email)) { }
}
What happens is, the file does NOT get moved if the file exists, and when it creates the file if a file doesn't exist, it only does it for the first item in the list, not each as you would expect a foreach statement to process.
If anyone could offer some insight on the wrongdoings of my ways I would appreciate it. Thanks!
|
|
|
|
|
If you run the code you've shown it will throw exceptions at the points where it is failing - examine those exceptions and you will see some of where you're going wrong.
Other points -
You need to check the archive directory exists and doesn't contain a file with that name before calling Move
I would append the filename to your destinationFile string - not just the path
Your loop is going to keep creating/moving the same file
|
|
|
|
|
Put your code in a try-catch block or step through your code to find the exact location of your error.
Once you fix it, your files should move from one location to the other.
|
|
|
|
|
What is in settingsFiles and why do you have a loop which uses the same file name each time through? There is also a bit of duplication in your paths in the above: sourceFile and path + email both evaluate to the same string.
Use the best guess
|
|
|
|
|
settingsFile is a string of settings files, no way to know how many there will be so that is why it loops. Here is the string.
string[] settingsFiles = Directory.GetFiles(@"C:\Nightly\Institutions\", "settings.ini", SearchOption.AllDirectories);
|
|
|
|
|
Yes, but why are you using it to create a loop when it has nothing to do with the file that you are trying to move?
Use the best guess
|
|
|
|