Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3794028
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:51:59+00:00 2026-05-19T12:51:59+00:00

VB.NET 2010, .NET 4 Hello, I’ve been struggling with the logic of this for

  • 0

VB.NET 2010, .NET 4

Hello,

I’ve been struggling with the logic of this for a while and was hoping for a little insight.

I am working on an application for controlling an industrial machine composed of many devices attached to the computer. Most if it is reasonable straight forward, but I’m having trouble thinking about the RS-232 devices. One of the RS-232 devices is a fancy power supply with many functions. The ones that are relevant right now are voltage read, voltage write, current read, and current write.

The design pattern I’m trying to implement is one in which each attached device is represented by an object that has methods for reading/writing etc and properties for things like COM port etc.

For this power supply, clearly the Port reference should be shared among the instances, so I have a base class (say, PowerSupply) with a Protected Shared Property Port As IO.Ports.SerialPort. Then I have a couple classes that inherit from this class, PowerSupplyVoltage and PowerSupplyCurrent that each define read/write methods and properties for holding the last read/written values.

My issue is in parsing the response from the power supply using the Port.DataRecieved event on the shared SerialPort object. The protocol the power supply uses specifies what data it’s sending in each response packet. So, basically, it might say something equivalent to “The voltage is 100V” or “The current is 1A” or “The voltage has been set to 150V” etc.

I’m trying to parse this in a shared function. Only during the parsing process would I determine which instance’s read/written value to update. I can’t access the read/written value properties of the instances from within the shared function. My brain hurts from trying to think how to do this right. The best I could think of is creating some kind of PowerSupplyCommunicator object that would maintain references to PowerSupplyVoltage and PowerSupplyCurrent instances along with the shared Port and DataRecievedHandler functions. This seems kind of kludgy though. Any thoughts on a smart way to go about this?

Thanks a lot in advance,
Brian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:52:00+00:00Added an answer on May 19, 2026 at 12:52 pm

    I would suggest having the shared object export an Event, which would be raised whenever a parameter messages comes over the serial port. The various object instances could then subscribe to the event, and update themselves as appropriate.

    A slight variation on this approach would be for the shared object to provide a “register” method by which instances can supply a delegate that they’d like to have the shared object call when a message comes in for them. Conceptually, this would be very similar to an event, except that the shared object could examine the incoming message and only call the delegate of the instance to which it directed.

    A third variation would be to have the object instances support one or more interfaces like INotifyVoltageChanged, INotifyCurrentChanged, etc. and call some method in the shared object to register themselves.

    It’s important when using any of these approaches, however, to note that if one of the individual object instances is abandoned, the shared object will likely keep a reference to it forever. If approach #3 is used, the shared object could hold a WeakReference to the object rather than a normal (“strong”) reference. That would slow down slightly the handling of update notifications, but would avoid the risk of having an abandoned object live forever. Certainly the individual object instances should implement IDisposable, and should unsubscribe from any notifications when Disposed, but unless weak references are used the imperative that Dispose actually be called is stronger than with many other types of objects. Note that unless weak references are used, a Finalizer will be worthless.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a new ASP.NET web application using vb.net 2010 Now I need to
UPDATE 10/19/2010 I know I asked this question a while ago, but the workarounds
I have a VS.NET 2010 + MVC 3.0 application and I've got a autocompletion
I am working on an ASP.NET project in Visual Studio .NET 2010 and attempting
iam using Asp.Net 2010 and MVC3 framework..I am new to this. When user registers
I am trying to convert my vb.net 2010 web forms application into a C#
VB.NET 2010, .NET 4 Hello all, I'm by no means a good programmer and
VB.NET 2010, .NET 4 Hello, I recently read about using SynchronizationContext objects to control
I have a VB.NET 2010 Winforms application where I'd like to include line numbers
Hello i am currently developing a ASP.NET MVC 3 application that uses the new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.