awdkmfgefas
Member
- Beiträge
- 5
- Reaktionspunkte
- 0
-> Hier kostenlos registrieren
Hallo
ich will in meinen Windows Forms Programm die Istposition einer Achse auslesen. Dies habe ich schon geschaft, aber denn Wert dauernd mit einer AddDeviceNotification zu Aktualisieren funktioniert nicht.
Mit diesem Code kann ich die Position auslesen, aber ich muss wenn ich die aktuelle Position wissen will den Button drücken
TcAdsClient tcAds;
private AdsStream ds;
private BinaryReader br;
tcAds = new TcAdsClient();
tcAds.Connect("127.0.0.1.1.1", 501);
private void button4_Click(object sender, EventArgs e)
{
ds = new AdsStream(20);
br = new BinaryReader(ds);
tcAds.Read(0x4101, 0x00010002, ds);
ds.Position = 0;
label2.Text = br.ReadDouble().ToString();
}
Danach habe ich den Code umgeändert, dieser sollte mittels einer Device Notification den Wert andauernd Aktualisieren, jedoch funktioniert es nicht.
TcAdsClient tcAds;
private AdsStream ds;
private BinaryReader br;
tcAds = new TcAdsClient();
tcAds.Connect("127.0.0.1.1.1", 501);
ds = new AdsStream(20);
br = new BinaryReader(ds);
int handle1 = tcAds.AddDeviceNotification(0x4101, 0x00010002, ds, 20, 0, AdsTransMode.OnChange, 100, 0, null);
tcAds.AdsNotification += new AdsNotificationEventHandler(OnNotification);
private void OnNotification(object sender, AdsNotificationEventArgs e)
{
ds.Position = 0;
ergebnis = br.ReadDouble().ToString();
this.Invoke((MethodInvoker)delegate
{
label3.Text = ergebnis;
});
}
Es würde mich freuen wenn mir bei meinen Problem wer helfen kann.
ich will in meinen Windows Forms Programm die Istposition einer Achse auslesen. Dies habe ich schon geschaft, aber denn Wert dauernd mit einer AddDeviceNotification zu Aktualisieren funktioniert nicht.
Mit diesem Code kann ich die Position auslesen, aber ich muss wenn ich die aktuelle Position wissen will den Button drücken
TcAdsClient tcAds;
private AdsStream ds;
private BinaryReader br;
tcAds = new TcAdsClient();
tcAds.Connect("127.0.0.1.1.1", 501);
private void button4_Click(object sender, EventArgs e)
{
ds = new AdsStream(20);
br = new BinaryReader(ds);
tcAds.Read(0x4101, 0x00010002, ds);
ds.Position = 0;
label2.Text = br.ReadDouble().ToString();
}
Danach habe ich den Code umgeändert, dieser sollte mittels einer Device Notification den Wert andauernd Aktualisieren, jedoch funktioniert es nicht.
TcAdsClient tcAds;
private AdsStream ds;
private BinaryReader br;
tcAds = new TcAdsClient();
tcAds.Connect("127.0.0.1.1.1", 501);
ds = new AdsStream(20);
br = new BinaryReader(ds);
int handle1 = tcAds.AddDeviceNotification(0x4101, 0x00010002, ds, 20, 0, AdsTransMode.OnChange, 100, 0, null);
tcAds.AdsNotification += new AdsNotificationEventHandler(OnNotification);
private void OnNotification(object sender, AdsNotificationEventArgs e)
{
ds.Position = 0;
ergebnis = br.ReadDouble().ToString();
this.Invoke((MethodInvoker)delegate
{
label3.Text = ergebnis;
});
}
Es würde mich freuen wenn mir bei meinen Problem wer helfen kann.