|
For writing data to an MMF that is more complex than a struct containing only value type members you would have to serialize that data into a byte array and then write that byte array to the MMF using MemoryMappedViewAccessor.WriteArray<T>[^]. In order to be able to read it back, you should also write the length of the byte-array to the MMF, probably directly before the start of the byte-array.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I need a runtime is similar to the Visual Studio forms designer examples, I hope it's not a Windows form, but Windows Presentation Foundation, it has a few features I need:
1. to design window
2. in the design window, add widge
I am very grateful to you if you help me
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Environment: - Windows XP/Windows7 32bit, 64 bit/Windows 2008 Server 64 bit/Windows 2012 Server 64 bit
.
Application Details: -
Application.exe [Visual Studio C# created]
Extract.exe [Visual Studio C# created]
.Net Frame Work: - 3.5 .Net Frame Work
.
Product Description: - We have a product Application.exe, which launch another process Extract.exe in command line for extracting image documents, after extraction; we store data into text file and read from Application.exe and store into data base.
Note: - Application.exe start from services.msc.
.
We run multiple instance of Application.exe after renaming it as Application-FirstInstance.exe, Application-SecondInstance.exe; each application exe launches Extract.exe. We create service for each Application-{Instance}.exe. Application works fine in multiple instances environment, but during run of each service; there are many Extract.exe and Application-{Instance}.exe visible in task manager.
.
Requirement Description: -
We want to kill related Extract.exe on stopping Application-{Instance}.exe from services, and it would be instant operation.
But we have to make sure that related Extract.exe is deleting, while stopping Application-{Instance}.exe from services. What will be right way to identifying particular Application-{Instance}.exe and related Extract.ext and killing operation?
.
Kindly assist us to find the resolution. Please let us know, if more information is required.
We will be really thankful.
|
|
|
|
|
The best solution is that when an instance of Application.exe is killed, it should close its instance of Extract.exe - since it is the only program that knows for sure which one it is.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi Sir,
That is right, but how will we know the reference of particular exe.
|
|
|
|
|
Presumably you start it using Process.Start? Which means you have the Process object, and all it's info...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi Sir,
We start it in same way, I will check from Process object for required value in application, and will let you know, that we have captured required info or not.
Thanks & Regards
|
|
|
|
|
Hi,
I need know how can reading byte using serialport I mean if any device send data in bytes by serialport I need code can be reading byte and display this data in textbox
for examble if micro controller send x=255 this data will send in ascii code how can read this value in C#
Regards
|
|
|
|
|
|
Use SerialPort.Read[^] to get the bytes, and then Bitconverter.ToString to output them to a textbox:
myTextBox.Text += BitConverter.ToString(arrayOfBytesFromSerailPort);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi ,
Thank you for support
I have equation I send data I text for example my_data="ST23.5255"
Iam using
serialport.ReadTo("ST") to Read ST from array text then now I have two value
1- 23.5 this is anolage value from temperature senser
2- 255 this value from anther senser
now my equation how can separated this value from array my_data and display this value in gauge or led array
I mean can be use method in C# convert string to float value and selected index from array because I have two value
Regards
|
|
|
|
|
Read the following three bytes - you will probably have to wait until they are available.
Then use float.Parse or float.TryParse (or their double equivalents) to convert the value.
Then do the same for the next three bytes.
What part of this is difficult?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
The difficult is how can separated the data from string because this array have multi data
for example
string w;
w = Port.ReadTo("ST");
and assume the data send "ST12.5127"
this data 12.5127 will store a text in W now I need convert 12.5 from text to float and convert 127 to float how can separated data from W
Sir can be written the code
Regards
|
|
|
|
|
SerialPort.Read[^] lets you specify how many characters (or bytes) to read...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
hasan hadi wrote: this data 12.5127 will store a text in W now I need convert 12.5 from text to
float and convert 127 to float
Convert.ToFloat("12.51"); You're not going to like this, but converting from one simple type to another simple type should not be an issue.
I suggest you buy a book and go through a lot of tutorials before attempting anything more complex.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
Sir what Book mean ?
Regards
|
|
|
|
|
Head First C#[^], or anything similar.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Down vote countered.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
string w = "ST12.5127";
float f1 = float.Parse( w.Substring( 2, 4 ) );
float f2 = float.Parse( w.Substring( 6, 3 ) );
Console.WriteLine( "f1: {0}", f1 );
Console.WriteLine( "f2: {0}", f2 );
modified 2-May-15 1:18am.
|
|
|
|
|
Thank you Sir this is good method
Regrds
|
|
|
|
|
Hi ,
this code is work but I have one problem
the problem in
ledArray1.SetValues(state_data,0,4)
this take Boolean array the c# message say cannot convert from byte[] to bool[] what can be doing?
this code is work
private void button1_Click(object sender, EventArgs e)
{
int baud_rate;
baud_rate = Convert.ToInt32(comboBox2.Text);
MessageBox.Show("" + baud_rate);
Port.Close();
Port = new SerialPort(comboBox1.Text, baud_rate);
Port.DataReceived += new SerialDataReceivedEventHandler(Port_DataReceived);
Port.Open();
button1.BackColor = Color.Lime;
}
string w;
private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] temp_read;
temp_read = new byte[6];
byte[] state_read;
state_read = new byte[4];
string w;
w = Port.ReadTo("ST");
if (w != string.Empty)
{
temp_read[0] = (byte)w[0];
temp_read[1] = (byte)w[1];
temp_read[2] = (byte)w[2];
temp_read[3] = (byte)w[3];
temp_read[4] = (byte)w[4];
state_read[0] = (byte)w[5];
state_read[1] = (byte)w[6];
state_read[2] = (byte)w[7];
state_read[3] = (byte)w[8];
string ff = Encoding.UTF8.GetString(temp_read, 0, 5);
float kk = Convert.ToSingle(ff);
string ff1 = Encoding.UTF8.GetString(state_read, 0, 4);
float kk1 = Convert.ToSingle(ff1);
thermometer1.Value = kk;
label1.Text = "" + kk1;
}
}
modified 1-May-15 14:27pm.
|
|
|
|
|
Seriously, when Eddie suggested that you need to read a book, he wasn't joking.
You seem to be trying to code by guesswork instead of from knowledge, and that's as likely to succeed in development as it is in driving. To continue the analogy, you seem to be trying to drive across the USA in a 40 ton articulated lorry when you haven't yet mastered riding a bicycle!
It doesn't work - it's clear from your questions that you don't understand the basics enough to do complex code yet. Please, for your own sake: go back and learn the early stuff.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thank you Sir
For me study course about C# before that but I have some Ambiguity in some point for me I writing the code and is work but I try choice anther method to obtain the same result
look her this my code again Sir I need only choice anther method
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ADC_and_display_value_in_computer
{
public partial class Form1 : Form
{
private string[] Ports;
private byte[] r_data;
public Form1()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
Ports = SerialPort.GetPortNames();
foreach (string port in Ports)
{
comboBox1.Items.Add(port);
}
}
private void button1_Click(object sender, EventArgs e)
{
int baud_rate;
baud_rate = Convert.ToInt32(comboBox2.Text);
MessageBox.Show("" + baud_rate);
Port.Close();
Port = new SerialPort(comboBox1.Text, baud_rate);
Port.DataReceived += new SerialDataReceivedEventHandler(Port_DataReceived);
Port.Open();
button1.BackColor = Color.Lime;
}
string w;
private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] temp_read;
temp_read = new byte[6];
byte[] state_read;
state_read = new byte[4];
string w;
w = Port.ReadTo("ST");
if (w != string.Empty)
{
temp_read[0] = (byte)w[0];
temp_read[1] = (byte)w[1];
temp_read[2] = (byte)w[2];
temp_read[3] = (byte)w[3];
temp_read[4] = (byte)w[4];
state_read[0] = (byte)w[5];
state_read[1] = (byte)w[6];
state_read[2] = (byte)w[7];
state_read[3] = (byte)w[8];
string ff = Encoding.UTF8.GetString(temp_read, 0, 5);
float kk = Convert.ToSingle(ff);
string ff1 = Encoding.UTF8.GetString(state_read, 0, 4);
float kk1 = Convert.ToSingle(ff1);
thermometer1.Value = kk;
label1.Text = "" + kk1;
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
button1.Enabled = true;
}
}
}
|
|
|
|
|
thank you for all
now final code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ADC_and_display_value_in_computer
{
public partial class Form1 : Form
{
private string[] Ports;
private byte[] r_data;
public Form1()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
Ports = SerialPort.GetPortNames();
foreach (string port in Ports)
{
comboBox1.Items.Add(port);
}
}
private void button1_Click(object sender, EventArgs e)
{
int baud_rate;
baud_rate = Convert.ToInt32(comboBox2.Text);
MessageBox.Show("" + baud_rate);
Port.Close();
Port = new SerialPort(comboBox1.Text, baud_rate);
Port.DataReceived += new SerialDataReceivedEventHandler(Port_DataReceived);
Port.Open();
button1.BackColor = Color.Lime;
}
string w;
private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string w;
w = Port.ReadTo("ST");
if (w != string.Empty)
{
float f1 = float.Parse(w.Substring(0, 5));
float f2 = float.Parse(w.Substring(5, 3));
thermometer1.Value = f1;
label1.Text = "" + f2;
ledArray1.SetValues(sheimy_Converter1.Convert_byte_to_boolarry((byte)f2));
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
button1.Enabled = true;
}
}
}
|
|
|
|