Hello,
I'm in the process of making a class library for communicating with a PLC.
I'm uncertain what would be the best design pattern to use. I've made some
experimentation s with the aggregate component design pattern much like
SerialPort is build but the problem with this is that my class library is
using async sockets under the hood. The communication itself is ethernet
using .NET async sockets.
Therefore I need to have some sort of callback method. Right now I supply a
ResultCallback delegate to the publically exposed methods on my Plc class.
Forexample:
public void ReadBit(ResultC allback resultCallback, MemoryArea memoryArea,
short beginningAddres s, short noItems, byte bit)
What this does is to return the result of the operation to the method that
resultcallback is pointing to. Where ResultCallback looks like this public
delegate void ResultCallback( object result)
The callback methods then casts the result to whatever the expected return
type is (boolean, short, int, etc).
Now I'm considering making it so that the user of the class library has to
create a PlcCommand object and then use Plc.Send(comman dObject) and then
attach an eventhandler to the command object or some such.
I hope this gives you an idea what kind of library I'm making. Any
suggestions in terms of the design would be much appreciated. 0 1104 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: yan |
last post by:
Hi, everybody. I'm new to this great forum, so hello!
I start with a problem of my project.
I have an Abstract Base Class used as base class for differentes
Derived classes. The derived classes must able to set the behavior
af a function f() at run-time. I want use the same function behavior
also in Another Class, but without using inheritance because
Another Class not extend Base Class.
I have used a function pointer and static members...
|
by: Bryan Parkoff |
last post by:
I have created three classes according to my own design. First class
is called CMain. It is the Top Class. Second class and third class are
called CMemory and CMPU. They are the sub-classes.
Two sub-classes have the relationship to communicate back and forth
through this pointer. The pointer is responsible inside Top class for
allocating and deallocating two sub-classes.
CMemory class is responsible to allocate and deallocate memory...
|
by: Aguilar, James |
last post by:
My previous example used the concept of a Shape class heirarchy, so I will
continue with that.
Suppose I have something like fifty different shapes, and I am trying to
instantiate one of them. The trick is, the instatiation will be based on a
string with the exact same name as the type that I am trying to instantiate.
Obviously, writing a fifty element long switch statement is an inferior
solution. So, how can I instantiate based on...
|
by: Steven T. Hatton |
last post by:
The following may strike many of you as just plain silly, but it represents
the kind of delelima I find myself in when trying to make a design
decision. This really is a toy project written for the purpose of learning
to work with C++. It therefore makes some sense for me to give the
situation the amount of consideration presented below. To be quite honest,
I'm amazed at the amount there is to say about such a seemingly simple...
|
by: Matthias Kaeppler |
last post by:
Sorry if this has been discussed before (I'm almost certain it has), but
I didn't know what to google for.
My problem is, I have a class, a gtkmm widget, and I want it to serve as
a base class now, but I'm not sure if I'm taking the proper steps in
order to not break the whole class.
Are there any guidelines what I have to watch out for?
One question would e.g. be:
| |
by: fernandez.dan |
last post by:
I'm still learning how to use Object Oriented concepts. I'm have a
basic question dealing with design. I have two classes that deal with
I/O pertaining to network and usb that inherit from an abstract parent
with four basic functions: Open, Read, Write, and Close.
// Note alot of the stuff has been left out
// just to give a basic picture
class IO
{
public:
|
by: Kalpesh |
last post by:
Hello,
I am facing a design problem here & need your expert design advice on
this.
Scenario:
I have a class called Vendor - which has several simple attributes like
Name, Address etc
Now, each vendor has some attributes - which are not "simple"
Basically, they can be an instance of another class
|
by: Kalpesh |
last post by:
Hello,
I am facing a design problem here & need your expert design advice on
this.
Scenario:
I have a class called Vendor - which has several simple attributes like
Name, Address etc
Now, each vendor has some attributes - which are not "simple"
Basically, they can be an instance of another class
|
by: nw |
last post by:
Hi,
I previously posted a question asking for suggestions on my class
design. My original code consisted of a pure virtual base class Body
which contained a number of integration algorithms which are applied
to the Body. Generally only one integration algorithm is used via an
integrate() method, which selected the integration algorithm to call
depending on a variable.
Code similar to the following was suggested as a improvement. I have
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |