Now that the design is finished and development is started, its time to document my development.
I will start at the basics. Let’s look at the various C# datatypes and their byte sizes. This will become apparent when we look at structures, byte arrays and memory mapped files.
I am developing an industrial automation project which gathers its data from a PLC as UDP messages at an interval between 55msec and 100 msec.
We are also using a SQL Server 2008 database to store the production data for long term storage and reporting.
The user interface will use windows forms. However, I need to explore Ajax and Silverlight to verify that these products can provide the performance needed.
But, right now, I am developing the base classes to manage memory mapped files, UDP connections, and MSMQ queues.
C# has two kinds of data types: value types and reference types. The reference types are defined as classes or objects; they are not pointers (Sidenote: pointers are available in C# but only to be used in unsafe code). The value type means that these types contain their values directly. These types are also knows as simple types and primitive types.
|Bool||8||True/False logical values|
|Byte||8||8-bit unsigned integer|
|char||8||One (1) unicode character. This is the not same as byte.|
|double||64||Double-precision floating point value. This is most widely used of the floating point values in C# because many of the math functions using the double datatype|
|float||32||Single-precision floating point value. This data type is the one I use to communicate with the PLC since their floating point size is a maximum of 32 bits|
|int||32||Integer value. This data type is the one I use to transfer integer values with the PLC|
|long||64||Long integer value. I rarely use this value for I don’t need numbers as large as this provides, but I do use it to keep track of time (ticks).|
|sbyte||8||A signed byte which is equivalent to C/C++ char data type.|
|short||8||A signed short integer. For those times when I need to transfer a 16-bit integer with the PLC, I use this data type.|
|uint||32||An unsigned integer. For those times when I need to transfer a 32-bit packed integer, I use this data type.|
|ulong||64||An unsigned long integer.|
|ushort||64||An unsigned short integer. For those times when I need to transfer a 16-bit packed integer, I use this data type./td>|