Hi..
I have 3 forms,form1,form2 and form3. I have to perform following things
1. Send data from form1 to serial port.
2. when form1 get value '1', show second form.
3. when click a button in form2 show form3.
4. when click a send button call a function in form1 and send data to serial port.
5. Wait for response.
6. When get a response again send data without clicking the button.
7. wait for response.
8. When get a response again send data without clicking the button.
9. continues this procedure so many times
But my problem is that how can I manage this with timer. after getting acknowledgement am sending next data and I stop the timer. But when I get acknowledgement I cant send data, because I already stopped the timer. Is there any solution to this?
code in form3
private void button1_Click(object sender, EventArgs e)
{
int temp =Convert.ToInt32( comboBox1.Text);
if (comboBox1.Text == "25")
{
tempp[0] = 0;
}
else if (comboBox1.Text == "30")
{
tempp[0] = 1;
}
else if (comboBox1.Text == "37")
{
tempp[0] = 2;
}
int filter = Convert.ToInt32(comboBox2.Text);
int asp = Convert.ToInt32(textBox1.Text);
int prnt = Convert.ToInt32(textBox2.Text);
int abs = Convert.ToInt32(textBox3.Text);
byte[] cmdt = BitConverter.GetBytes(Form1.SETTEMPERATURE);
byte[] nn = BitConverter.GetBytes(Form1.SETFILTER);
byte[] len = new byte[1];
byte[] ERR = new byte[1];
len[0] = 3;
((Form1)this.Owner).SerialPortValueUpdated(len, cmdt, ERR, tempp);
}
private void Filter_Load(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (Form1.tflag == 1&&Form1.filflag==0)
{
label7.Text = "FILTER...";
rrr = 1;
}
if (Form1.filflag == 1&&Form1.tflag==0)
{
label7.Text = "ACK...";
fltflag = 1;
}
if (rrr == 1)
{
byte[] nn = BitConverter.GetBytes(Form1.SETFILTER);
byte[] len = new byte[1];
byte[] ERR = new byte[1];
byte[] val = new byte[1];
len[0] = 3;
((Form1)this.Owner).SerialPortValueUpdated(len, nn, ERR, val);
timer1.Stop();
}
if (fltflag == 1)
{
Form1.filflag = 0;
byte[] nn = BitConverter.GetBytes(Form1.GETRAWADS);
byte[] len = new byte[1];
byte[] ERR = new byte[1];
byte[] val = new byte[1];
len[0] = 3;
((Form1)this. Owner).SerialPortValueUpdated(len, nn, ERR, val);
}
}