Re: Remoting Events Question/Problem (Not Firing)
From: Kelly Wilkerson (KellyWilkerson_at_discussions.microsoft.com)
Date: 11/08/04
- Next message: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Previous message: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- In reply to: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Next in thread: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Reply: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Nov 2004 13:37:02 -0800
Hey Ken,
Thanks for your reply. I made the changes and still no luck. In Event A, I
write the value of the changed OPC tag to another tag to verify that Event A
is indeed firing. However, when I make the call to fire Event B so that the
subscribing client will take the appropriate action, it does nothing. I have
looked at just about every sample and example or newsgroup thread and tried
the suggested fix and just cannot seem to get it right (for about a week
now). Any other ideas are greatly appreciated. I can send you any code you
need if it helps.
Thanks again,
Kelly.
"Ken Kolda" wrote:
> The first thing I noticed is that you're explicitly using the "tcp server"
> channel on the server and the "tcp client" channel on the client. When you
> use callbacks, your server effectively becomes a client and your client a
> server. So, do two things:
>
> 1) In your server config, change "tcp server" to just "tcp"
> 2) In your client config, change "tcp client" to "tcp" and add port="0" to
> the channel definition.
>
> If that doesn't solve the problem, post back with additional details on what
> happens when you try to raise the event (e.g. you get an exception, nothing
> happens at all, etc.).
>
> Ken
>
>
> "Kelly Wilkerson" <KellyWilkerson@discussions.microsoft.com> wrote in
> message news:DA71CE53-ED18-4FC4-B2FB-8B6FC5A95FFE@microsoft.com...
> > Here is the issue... I have a Remotable Type that is exposed to a Client
> > Application (Windows Forms Application) using a very simple Server
> (Console
> > Application). The Server should fire an Event (Event B) passing a
> > System.Collections.Queue containing a collection of structs when another
> > Event (Event A) fires/occurs on the Server. The problem is that Event A
> > fires, the Queue on populated, but Event B will not fire on the Client.
> The
> > DataServer.cs, DataClientDemo.cs, and associated exe.config files are
> > attached (Sorry for the length, but could not attach .zip file). Thanks
> in
> > advance for your help.
> >
> > Kelly.
> >
> > ------------------------------------
> > James K. Wilkerson
> > Cephalopod Software, Inc.
> > ------------------------------------
> >
> > -------DataServer.cs File -------
> > using System;
> > using System.Collections;
> > using OPC;
> > using OPCDA;
> > using OPCDA.NET;
> >
> > namespace CSI.Octopus.Server.Data
> > {
> > public class DataChangedEventArgs : EventArgs
> > {
> > public DataChangedEventArgs(Queue changes)
> > {
> > _changes = changes;
> > }
> > public Queue Changes
> > {
> > get { return _changes; }
> > }
> > protected Queue _changes;
> > }
> >
> > public delegate void DataChangedEventHandler(object sender,
> > DataChangedEventArgs e);
> >
> > public class DataServer : MarshalByRefObject
> > {
> > public event DataChangedEventHandler DataChangedEvent;
> > public struct DataItemStructure
> > {
> > public string itemName;
> > public string itemType;
> > public string itemValue;
> > public string itemTimeStamp;
> > public string itemDescription;
> > }
> >
> > private OpcServer server = null;
> > private SyncIOGroup ioGroup;
> > private RefreshGroup refreshGroup;
> > private ItemDef ItemData;
> > private string gripper1 = "Simulator.Robot5.R5Gripper1";
> > private string gripper2 = "Simulator.Robot5.R5Gripper2";
> > private DataItemStructure dataItem = new DataItemStructure();
> > private Queue itemChanges = null;
> >
> > public DataServer()
> > {
> > try
> > {
> > server = new OpcServer();
> > server.Connect("KEPware.KEPServerEx.V4");
> > OPCDA.NET.RefreshEventHandler callback = new
> > OPCDA.NET.RefreshEventHandler(CallbackHandler);
> > refreshGroup = new OPCDA.NET.RefreshGroup(server,
> 100,
> > callback);
> > refreshGroup.Add(gripper1);
> > ioGroup = new SyncIOGroup(server);
> > ioGroup.Add(gripper2);
> > ItemData = ioGroup.Item(gripper2);
> > }
> > catch
> > {
> > server = null;
> > }
> > }
> >
> > private void CallbackHandler(object sender,
> RefreshEventArguments
> > arg)
> > {
> > if(arg.Reason == RefreshEventReason.DataChanged)
> > {
> > for(int i = 0; i <= arg.items.Length; i++)
> > {
> > dataItem.itemName = arg.items[i].OpcIDef.ItemID;
> > dataItem.itemType = "string";
> > dataItem.itemValue = arg.items[i].OpcIRslt.DataValue.ToString();
> > if (dataItem.itemValue == "True")
> > {
> > ioGroup.Write(ItemData, "True");
> > }
> > else
> > {
> > ioGroup.Write(ItemData, "False");
> > }
> > dataItem.itemTimeStamp =
> arg.items[i].OpcIRslt.TimeStamp.ToString();
> > dataItem.itemDescription = "Robot 5 Gripper 1 Open/Closed 0/1";
> > itemChanges.Enqueue(dataItem);
> > }
> > DataChangedEventArgs args = new DataChangedEventArgs(itemChanges);
> > if (DataChangedEvent != null)
> > DataChangedEvent(this, args);
> > }
> > itemChanges.Clear();
> > }
> > }
> > }
> >
> > -------ItemServer.exe.config File -------
> > <configuration>
> > <system.runtime.remoting>
> > <application>
> > <service>
> > <wellknown mode = "Singleton" type = "DataServer.DataServer,
> > DataServer" objectUri = "DataServer"/>
> > </service>
> > <channels>
> > <channel ref = "tcp server" port = "1234"/>
> > </channels>
> > </application>
> > </system.runtime.remoting>
> > </configuration>
> >
> > -------DataClientDemo.cs File (Portions to save space)-------
> > private Data.DataServer dataServer;
> > private Data.DataChangedEventHandler NewDataChangedEventHandler;
> > private Data.DataServer.DataItemStructure dataItem;
> >
> > public frmMain()
> > {
> > InitializeComponent();
> > RemotingConfiguration.Configure("ItemClient.exe.config");
> > dataServer = new DataServer();
> > NewDataChangedEventHandler = new
> > Data.DataChangedEventHandler(OnDataChanged);
> > dataServer.DataChangedEvent += NewDataChangedEventHandler;
> > }
> >
> > private void OnDataChanged(object sender, Data.DataChangedEventArgs e)
> > {
> > for (int i = 0; i < e.Changes.Count - 1; i++)
> > {
> > dataItem =
> (Data.DataServer.DataItemStructure)e.Changes.Dequeue();
> > if (dataItem.itemName == "Simulator.Robot5.R5Gripper1")
> > {
> > if (dataItem.itemValue == "True")
> > {
> > ledR5Gripper1.BackColor = Color.Red;
> > }
> > else
> > {
> > ledR5Gripper1.BackColor = Color.Yellow;
> > }
> > }
> > }
> > }
> >
> > -------ItemClient.exe.config File -------
> > <?xml version="1.0" encoding="utf-8" ?>
> > <configuration>
> > <system.runtime.remoting>
> > <application>
> > <client>
> > <wellknown type = "DataServer.DataServer, DataServer" url =
> > "tcp://localhost:1234/DataServer"/>
> > </client>
> > <channels>
> > <channel ref = "tcp client"/>
> > </channels>
> > </application>
> > </system.runtime.remoting>
> > </configuration>
> >
>
>
>
- Next message: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Previous message: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- In reply to: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Next in thread: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Reply: Ken Kolda: "Re: Remoting Events Question/Problem (Not Firing)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|