Beispiel #1
0
 public ValueResponseBatch[] GetResponses()
 {
     ValueResponseBatch[] responses = new ValueResponseBatch[Responses.Count];
     // Responses.CopyTo(0, responses, 0, responses.Length);
     Array.Copy(Responses.ToArray(), responses, Responses.Count);
     Responses.Clear();
     Logger.Write(Logger.Tag.INFO, "Retrieved " + responses.Length.ToString() + " ValueResponses");
     return(responses);
 }
Beispiel #2
0
        public void ProcessWrite(WriteRequest wrq)
        {
            ValueResponseBatch rr = new ValueResponseBatch
            {
                UUID      = wrq.UUID,
                Responses = new HashSet <ValueResponse>()
            };

            foreach (string sensorID in wrq.Points)
            {
                rr.Responses.Add(new ValueResponse {
                    Timestamp = Utils.Millis,
                    Epoch     = "millis",
                    Value     = wrq.Value,
                    Measure   = "temperature",
                    Unit      = "celcius",
                    Protocol  = "test",
                    Point     = sensorID
                });
            }

            Logger.Write(Logger.Tag.INFO, "Processed " + rr.Responses.Count.ToString() + " write requests");
            Responses.Add(rr);
        }
Beispiel #3
0
 public static byte[] EncodeValueResponseBatch(ValueResponseBatch batch)
 {
     return(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(batch, Formatting.None)));
 }