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 7896823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:59:35+00:00 2026-06-03T07:59:35+00:00

How would you structure a simple simulation engine using Reactive Extensions? For example, suppose

  • 0

How would you structure a simple simulation engine using Reactive Extensions? For example, suppose you had a class Motor with properties IsPowered and Speed. You want to react to IsPowered changing from false to true by having Speed ramp up from 0 to 1000 RPM by 10 RPM each second for 100 seconds.

Abstracting this a bit, suppose you want to provide a pluggable API where the class and its properties aren’t known in advance. Instead, the simulation engine gets an observable stream of property changes which is reacts to by creating additional property changes, many of which take place in increments over time leveraging Rx. What might such an API look like?

  • 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-06-03T07:59:36+00:00Added an answer on June 3, 2026 at 7:59 am

    A simulation API would need a type to represent property changes and a simulation method that had an incoming and outgoing IObservable<T> stream of changes. The implementation of the simulation engine would consist of rules that reacted to incoming property changes to update the output stream.

    The type would be like this (although a struct would probably be better than a class):

    class PropertyChange
    {
        public PropertyChange(string name, object value) { Name = name; Value = value; }
        public string Name { get; private set; }
        public object Value { get; private set; }
    }
    

    The simulation method would look like the following. To demonstrate multiple rules, this code presupposes a property IsLightOn that simply tracks IsPowered.

    IObservable<PropertyChange> Simulate(IObservable<PropertyChange> incomingChanges)
    {
        var isLightOnRule =
            from c in incomingChanges
            where c.Name == "IsPowered"
            select new PropertyChange("IsLightOn", c.Value);
    
        var ramp = Observable.Generate(0, speed => (speed <= 1000), speed => speed + 10, speed => new PropertyChange("Speed", speed), _ => TimeSpan.FromSeconds(1));
        var speedRule = incomingChanges
            .Where(c => c.Name == "IsPowered" && (bool)c.Value)
            .SelectMany(ramp);
    
        // Add more rules here.
    
        return Observable.Merge(isLightOnRule, speedRule /* merge more rules here */);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table structure and would like to map it using Fluent Hibernate
I would like to display a directory structure using Gtk# widgets through F#, but
I am trying to determine which implementation of the data structure would be best
I'm looking for a Java built-in data structure that would be the best at
Table structure- int PrimaryKey DateTime Date int Price What I would like to do
I would like to populate a DateTime structure from a string, but it is
I would like to create a structure with rails g scaffold Article , but
i would like create a array of structure which have a dynamic array :
What would be the best data structure to store all the words of a
I would like to reflect the XML tree in my object structure, but I

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.