الإجابة How make input payload?

  • Wednesday, February 13, 2013 11:32 AM
     
     
    For example

    input data (like HistoricalData)

    Date,          sensor1, value1, sensor2, value2, sensor3, value3, ~~~~~~, sensor700, value700
    2009-12-30, s1,        0.1,      s2,         2.33,     s3,         1.99,    ~~             s700,         5,333



    and spec data

    sensor1, 1.2, sensor2, 1,6, sensor3, 1,8 ~~~~ , sensor700, 1,55



    I need to compare the values of all the sensors with spec data.



    How can make inputpayload? and inputadapters?



    I hope so users best advice!!

All Replies

  • Wednesday, February 13, 2013 3:47 PM
     
     Answered Has Code

    If you have not read it, I would suggest reading Creating Event Types on MSDN. That will give you the ground rules for creating event types that will work with StreamInsight. I don't know how big your historical data is, but you have a maximum size for an event which is 16kb. Also, 700 sensors worth of data is alot of left-right code to write so you might want to consider 1 event per sensor reading. Here is an event type you could start with:

    public class HistoricalData
    {
        public string SensorId { get; set; }
        public DateTime Timestamp { get; set; }
        public float Value { get; set; }
    }
    Take a look at Creating Input and Output Adapters on MSDN if you are wanting to use adapters. You would probably have an easier time with the new Rx based StreamInsight 2.1 event sources/sinks model (see Using Event Sources and Event Sinks on MSDN).
  • Thursday, February 14, 2013 1:58 AM
     
      Has Code

    Thanks advice!

    It sensor data over 16kb!! so I  divide sensor data in inputadapter.

    and I make InputPayload this even types.

        public class HistoricalDataPayload
        {
            // after ouput will make entire sensor data
            public Guid HeaderGUID { get; set; }
            public string Time { get; set; }
            // 700 
            public string ItemCount { get; set; }
            public sensorItem sensoritem;
        }
    
        public class sensorItem
        {
            public Guid HeaderGUID = Guid.Empty;
            public string sensorid = string.Empty;
            public string value = string.Empty;
        }

    and InputAdapter divide sensor data!

                int SensorCount = Int32.Parse(ItemCount);
                for (int i = 0; i < SensorCount; i++)
                {
                    // Produce INSERT event
                    currEvent = CreateInsertEvent();
                    currEvent.StartTime = now;
                    currEvent.Payload = _cell;
    
                    EnqueueOperationResult ret = Enqueue(ref currEvent);
                    if (ret == EnqueueOperationResult.Success)
                    {
                        Console.WriteLine("Success");
                    }
                }

    or all sensor data Input? 

    public class HistoricalDataPayload
        {
            // after ouput will make entire sensor data
            public Guid HeaderGUID { get; set; }
            public string Time { get; set; }
            // 700 
            public string ItemCount { get; set; }
            public sensorItem sensoritem0;
            public sensorItem sensoritem1;
            public sensorItem sensoritem2;
            public sensorItem sensoritem3;
            public sensorItem sensoritem4;
            .
            .
            .
            .
            .
            .
            .
             public sensorItem sensoritem700;
        }

    Which is best guide?

    I hope so users best advice!!


  • Thursday, February 14, 2013 4:40 PM
     
     Answered Has Code

    I don't know what your datasource is for these events so the actual implementation of the input source/adapter is going to be up to you. At a high level, the job of the input adapter/source is to acquire data from a data source and transform it into a payload class that will be enqueued into the StreamInsight engine. That said, I think if you have 1 large event with all 700 sensor readings, you could potentially exceed the maximum event size in StreamInsight (16kb) depending on the types contained in your payload event. Floats are 4kb each and Doubles are 8kb a piece. Strings are going to vary in size depending on their contents. Check out the documentation for Creating Event Types on MSDN. What happens if you add an additional sensor reading to the original 700? You would have to change the payload class, recompile, and deploy your app. I think this would be a better approach:

    public class HistoricalData
    {
    	public Guid HeaderGuid { get; set; }
    	public DateTime Timestamp { get; set; }
    	public string SensorId { get; set; }
    	public string Value { get; set; }
    }

    Using this class, you can add/remove sensor readings without having to change your payload class.

    What are you trying to do with the data exactly?