Пример #1
0
        SolarSystem(int domainId)
        {
            planets =
                new Dictionary <string, PlanetInfo>();

            // PlanetInfo(orbitRadius, size, year-in-earth-days)
            planets.Add("Mercury", new PlanetInfo(30, 8, 88));
            planets.Add("Venus", new PlanetInfo(50, 15, 225));
            planets.Add("Earth", new PlanetInfo(70, 17, 365));
            planets.Add("Mars", new PlanetInfo(90, 12, 686));
            planets.Add("Jupiter", new PlanetInfo(120, 30, 4329));

            // Yes, the Moon too!
            planets.Add("Moon", new PlanetInfo(20, 8, 365));

            RTI.RxDDS.DefaultParticipant.DomainId = domainId;

            RTI.RxDDS.DefaultParticipant
            .RegisterType <ShapeType,
                           ShapeTypeTypeSupport>();

            this.triangleWriter =
                RTI.RxDDS.DefaultParticipant
                .CreateDataWriter <ShapeType>("Triangle");

            this.circleWriter =
                RTI.RxDDS.DefaultParticipant
                .CreateDataWriter <ShapeType>("Circle");
        }
Пример #2
0
        SolarSystem(int domainId)
        {
            planets =
                new Dictionary<string, PlanetInfo>();

            // PlanetInfo(orbitRadius, size, year-in-earth-days)
            planets.Add("Mercury", new PlanetInfo(30,   8,  88));
            planets.Add("Venus",   new PlanetInfo(50,  15,  225));
            planets.Add("Earth",   new PlanetInfo(70,  17,  365));
            planets.Add("Mars",    new PlanetInfo(90,  12,  686));
            planets.Add("Jupiter", new PlanetInfo(120, 30, 4329));

            // Yes, the Moon too!
            planets.Add("Moon",    new PlanetInfo(20,  8,  365));

            RTI.RxDDS.DefaultParticipant.DomainId = domainId;

            RTI.RxDDS.DefaultParticipant
                     .RegisterType<ShapeType,
                                   ShapeTypeTypeSupport>();

            this.triangleWriter =
                RTI.RxDDS.DefaultParticipant
                         .CreateDataWriter<ShapeType>("Triangle");

            this.circleWriter =
                RTI.RxDDS.DefaultParticipant
                         .CreateDataWriter<ShapeType>("Circle");
        }
 public static IDisposable Subscribe <TSource>(
     this IObservable <TSource> source,
     DDS.TypedDataWriter <TSource> dw)
 {
     DDS.InstanceHandle_t instance_handle = DDS.InstanceHandle_t.HANDLE_NIL;
     return(source.Subscribe(
                Observer.Create <TSource>(o => dw.write(o, ref instance_handle))));
 }
 public static IObservable <TSource> DisposeAtEnd <TSource>(
     this IObservable <TSource> source,
     DDS.TypedDataWriter <TSource> dw,
     TSource instance)
 {
     DDS.InstanceHandle_t instance_handle = DDS.InstanceHandle_t.HANDLE_NIL;
     return(source.Do(o => dw.write(o, ref instance_handle),
                      ex => dw.dispose(instance, ref instance_handle),
                      () => dw.dispose(instance, ref instance_handle)));
 }
Пример #5
0
 //initializes typed datawriters for this object.
 public void initializeDataWriters()
 {
     mSensorDataWriter =
         DefaultParticipant.CreateDataWriter <SensorData>("QueryOutput", typeof(SensorData).ToString());
     mPlayerDataWriter =
         DefaultParticipant.CreateDataWriter <PlayerData>("PlayerOutput", typeof(PlayerData).ToString());
     mCurrentRunningDataWriter =
         DefaultParticipant.CreateDataWriter <CurrentRunningData>("CurrentRunningDataTopic", typeof(CurrentRunningData).ToString());
     mAggregateRunningDataWriter =
         DefaultParticipant.CreateDataWriter <AggregateRunningData>("AggregateRunningDataTopic", typeof(AggregateRunningData).ToString());
     mPlayerBallPossessionDataWriter =
         DefaultParticipant.CreateDataWriter <PlayerBallPossession>("PlayerBallPossessionTopic", typeof(PlayerBallPossession).ToString());
     mTeamBallPossessionDataWriter =
         DefaultParticipant.CreateDataWriter <TeamBallPossession>("TeamBallPossessionTopic", typeof(TeamBallPossession).ToString());
     mshotOnGoalDataWriter =
         DefaultParticipant.CreateDataWriter <ShotOnGoalData>("ShotOnGoalDataTopic", typeof(ShotOnGoalData).ToString());
 }
 public static IDisposable OnDataAvailable <TSource>(
     this IObservable <TSource> source,
     DDS.TypedDataWriter <TSource> dw)
 {
     return(source.Subscribe(dw));
 }
Пример #7
0
    IDisposable splitterDelayNAverageWindow(DDS.DomainParticipant participant)
    {
        long WINDOW_SIZE = 50;
        long HISTORY_SIZE = 20;

        circle_writer = DefaultParticipant.CreateDataWriter<ShapeTypeExtended>("Circle");
        var rx_square_reader =
        DDSObservable.FromKeyedTopic<string, ShapeTypeExtended>(
            participant, "Square", shape => shape.color);
        // test_shape_vals.ToObservable().GroupBy(shape => shape.color);

        return new CompositeDisposable(
                new IDisposable[] {
                       rx_square_reader
                          .Subscribe(square_instance =>
                                     square_instance
                                       .Shift(HISTORY_SIZE)
                                       .SubscribeAndDisposeOnCompleted(circle_writer,
                                                    new ShapeTypeExtended { color = square_instance.Key } )),
                       rx_square_reader
                          .Subscribe(square_instance =>
                              {
                                  square_instance.Zip(
                                    square_instance
                                    .Select(square => square.x)
                                    .WindowAggregate(WINDOW_SIZE,
                                                     0.0,
                                                     (avgX, tail, head, count) => (avgX * count + tail - head) / count,
                                                     (avgX, tail, count, prevCount) =>
                                                     {
                                                         if (prevCount > count) tail *= -1;
                                                         return (avgX * prevCount + tail) / count;
                                                     }),
                                    square_instance
                                    .Select(square => square.y)
                                    .WindowAggregate(WINDOW_SIZE,
                                                     0.0,
                                                     (avgY, tail, head, count) => (avgY * count + tail - head) / count,
                                                     (avgY, tail, count, prevCount) =>
                                                        {
                                                            if (prevCount > count) tail *= -1;
                                                            return (avgY * prevCount + tail) / count;
                                                        }),
                                   (square, avgX, avgY) =>
                                       new ShapeTypeExtended
                                       {
                                           x = (int) avgX,
                                           y = (int) avgY,
                                           shapesize = square.shapesize,
                                           color = square.color
                                       })
                                .SubscribeAndDisposeOnCompleted(triangle_writer,
                                                              new ShapeTypeExtended { color = square_instance.Key});
                              })
                    });
    }
Пример #8
0
    IDisposable splitterDelayNAverage(DDS.DomainParticipant participant)
    {
        circle_writer = DefaultParticipant.CreateDataWriter<ShapeTypeExtended>("Circle");

        var rx_square_reader =
        DDSObservable.FromTopic<ShapeTypeExtended>(participant, "Square");
        int MAX_HISTORY = 20;
        int countX = 0, countY = 0;

        // var rx_square_reader = Observable.Range(10, 100);
        return new CompositeDisposable(
                new IDisposable[] {
                       rx_square_reader
                          .Shift(MAX_HISTORY)
                          .SubscribeAndDisposeOnCompleted(circle_writer, new ShapeTypeExtended { color = "BLUE" }),

                       rx_square_reader.Zip(
                          rx_square_reader
                            .Select(square => square.x)
                            .RollingAggregate(0.0,
                                              (avgX, x) =>
                                              {
                                                  avgX = ((avgX * countX) + x) / (countX+1);
                                                  countX++;
                                                  return avgX;
                                              }),
                          rx_square_reader
                            .Select(square => square.y)
                            .RollingAggregate(0.0,
                                              (avgY, y) =>
                                              {
                                                  avgY = ((avgY * countY) + y) / (countY+1);
                                                  countY++;
                                                  return avgY;
                                              }),
                          (square, avgX, avgY) =>
                              new ShapeTypeExtended {
                                  x = (int) avgX,
                                  y = (int) avgY,
                                  shapesize = square.shapesize,
                                  color = square.color })
                          .Subscribe(triangle_writer)
                    });
    }
Пример #9
0
 //initializes typed datawriters for this object.
 public void initializeDataWriters()
 {
     mSensorDataWriter =
           DefaultParticipant.CreateDataWriter<SensorData>("QueryOutput", typeof(SensorData).ToString());
     mPlayerDataWriter =
       DefaultParticipant.CreateDataWriter<PlayerData>("PlayerOutput", typeof(PlayerData).ToString());
     mCurrentRunningDataWriter =
       DefaultParticipant.CreateDataWriter<CurrentRunningData>("CurrentRunningDataTopic", typeof(CurrentRunningData).ToString());
     mAggregateRunningDataWriter =
       DefaultParticipant.CreateDataWriter<AggregateRunningData>("AggregateRunningDataTopic", typeof(AggregateRunningData).ToString());
     mPlayerBallPossessionDataWriter =
       DefaultParticipant.CreateDataWriter<PlayerBallPossession>("PlayerBallPossessionTopic", typeof(PlayerBallPossession).ToString());
     mTeamBallPossessionDataWriter =
       DefaultParticipant.CreateDataWriter<TeamBallPossession>("TeamBallPossessionTopic", typeof(TeamBallPossession).ToString());
     mshotOnGoalDataWriter =
       DefaultParticipant.CreateDataWriter<ShotOnGoalData>("ShotOnGoalDataTopic", typeof(ShotOnGoalData).ToString());
 }