public void CreatePiDatastreamTest()
        {
            var time = new Time();

            time.Zone       = "Asia/Kolkata";
            time.Identifier = "time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "PI";
            datasource.Host = "https://test.piserver.com/piwebapi";
            datasource.ElementTemplateName = "SampleElementTempalte";
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var ds = new DatastreamRequest();

            ds.Name = "TestDatastreamStreaming" + randomNumber;
            var Field  = new Field();
            var Signal = new Signal();

            Signal.ValueIdentifier  = "value";
            Signal.SignalIdentifier = "signal";
            Field.Signal            = Signal;

            Field.Time    = time;
            ds.Field      = Field;
            ds.DataSource = datasource;

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var folder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                var path = folder + "/../../resources/addData.csv";

                var bytes   = File.ReadAllBytes(path);
                var options = new SortedDictionary <string, string>();
                options.Add("timeIdentifier", "time");
                options.Add("timeFormat", "YYYY-MM-DD HH:mm:ss");
                options.Add("timeZone", "GMT");
                options.Add("streaming", "false");
                options.Add("hasMoreData", "false");
                var inputstatus = _falkonry.AddInputStream(datastream.Id, bytes, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add data");
            }
        }
        public void CreateDatastreamWithBatchIdentifierTest()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "iso_8601";

            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();
            var datasource   = new Datasource();

            datasource.Type = "STANDALONE";
            ds.Name         = "TestDatastream" + randomNumber;
            var Field = new Field();

            Field.BatchIdentifier = "Batch";
            ds.Field      = Field;
            ds.DataSource = datasource;
            ds.Field.Time = time;
            var datastream = _falkonry.CreateDatastream(ds);

            _datastreams.Add(datastream);
            Assert.AreEqual(ds.Name, datastream.Name);
            Assert.AreNotEqual(null, datastream.Id);
            Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
            Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
            Assert.AreEqual(ds.Field.BatchIdentifier, datastream.Field.BatchIdentifier);
            Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
        }
        public void AddDataNarrowFormatCsv()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "YYYY-MM-DD HH:mm:ss";

            var Signal = new Signal();

            Signal.SignalIdentifier = "signal";
            Signal.ValueIdentifier  = "value";

            var Field = new Field();

            Field.Signal = Signal;
            Field.Time   = time;

            var datasource = new Datasource();

            datasource.Type = "PI";
            datasource.Host = "https://test.piserver.com/piwebapi";
            datasource.ElementTemplateName = "SampleElementTempalte";

            var ds = new DatastreamRequest();

            ds.Name       = "TestDSPI" + randomNumber;
            ds.Field      = Field;
            ds.DataSource = datasource;

            Datastream datastream = new Datastream();

            try
            {
                datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                Assert.AreEqual(ds.Name, datastream.Field.EntityName);
                var data    = "time,signal,value\n" + "2016-05-05 12:00:00,current,12.4\n2016-03-01 01:01:01,vibration,20.4";
                var options = new SortedDictionary <string, string>();

                options.Add("streaming", "false");
                options.Add("hasMoreData", "false");

                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(null, exception.Message, "Cannot add data");
            }
        }
        public void DeleteDatastreamByIdTest()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "Time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "STANDALONE";
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();

            ds.Name = "TestDS" + randomNumber;
            var Field = new Field();

            Field.Time = time;

            ds.Field      = Field;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error deleting datastream");
            }
        }
        public void CreateDatastreamWithoutTimeFormat()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            //time.Format = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "STANDALONE";
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();

            ds.Name = "TestDatastream" + randomNumber;
            var Field = new Field();

            Field.Time = time;

            ds.Field      = Field;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                Assert.AreEqual(true, false, "No exception in case of missing time format");
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, "Missing time format.", "Incorrect error message in case of missing time format");
            }
        }
Пример #6
0
        public void AddDataNarrowFormatCsv()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "YYYY-MM-DD HH:mm:ss"
            };
            var Signal = new Signal
            {
                SignalIdentifier = "signal",
                ValueIdentifier  = "value"
            };
            var Field = new Field
            {
                Signal = Signal,
                Time   = time
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };
            var ds = new DatastreamRequest
            {
                Name       = "TestDSPI" + randomNumber,
                Field      = Field,
                DataSource = datasource
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var data    = "time, tag, value \n" + "2016-05-05T12:00:00Z, Unit1_current, 12.4 \n 2016-03-01 01:01:01, Unit1_vibration, 20.4";
                var options = new SortedDictionary <string, string>
                {
                    { "timeIdentifier", "time" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", "GMT" },
                    { "streaming", "true" }
                };
                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add data");
            }
        }
        // Cannot add historical input data(csv format) to Datastream with time identifier missing
        public void AddDataCsvMissingTimeIdentifier()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "timestamp";
            time.Format     = "iso_8601";

            var Field = new Field();

            Field.Time             = time;
            Field.EntityIdentifier = "signal";

            var datasource = new Datasource();

            datasource.Type = "PI";
            datasource.Host = "https://test.piserver.com/piwebapi";
            datasource.ElementTemplateName = "SampleElementTempalte";

            var ds = new DatastreamRequest();

            ds.Name       = "Test " + randomNumber;
            ds.Field      = Field;
            ds.DataSource = datasource;

            Datastream datastream = new Datastream();

            try
            {
                datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var data = "timestamp,signal,value\n" + "2016-05-05 12:00:00,current,12.4\n2016-03-01 01:01:01,vibration,20.4";
                SortedDictionary <string, string> options = new SortedDictionary <string, string>();


                options.Add("timeZone", "GMT");
                options.Add("timeFormat", "YYYY-MM-DD HH:mm:ss");
                options.Add("fileFormat", "csv");
                options.Add("streaming", "false");
                options.Add("hasMoreData", "false");
                options.Add("signalIdentifier", "signal");
                options.Add("valueIdentifier", "value");

                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);
                Assert.AreEqual(true, false, "No error message for missing time identifier");
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, "Missing time identifier.", "Incorrect error message for missing time identifier");
            }
        }
Пример #8
0
        public void TestAssessmentCreate()
        {
            var time = new Time
            {
                Zone       = "GMT",
                Identifier = "Time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "STANDALONE"
            };
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var Field = new Field
            {
                Time = time
            };
            var ds = new DatastreamRequest
            {
                Name       = "TestDS" + randomNumber,
                Field      = Field,
                DataSource = datasource
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotSame(null, datastream.Id);
                // create assessment
                AssessmentRequest asmtRequest = new AssessmentRequest
                {
                    Name       = "TestAsmt",
                    Datastream = datastream.Id
                };
                var assessmentCreated = _falkonry.CreateAssessment(asmtRequest);
                Assert.AreEqual(assessmentCreated.Name, asmtRequest.Name);
                Assert.AreNotEqual(null, assessmentCreated.Id);

                // get Assessment List
                List <Assessment> assessmnetList = _falkonry.GetAssessments();
                Assert.AreEqual(assessmnetList.Count > 0, true);

                // get assessment by id
                Assessment fetchedassessment = _falkonry.GetAssessment(assessmentCreated.Id);
                Assert.AreEqual(assessmentCreated.Name, asmtRequest.Name);
                Assert.AreNotEqual(null, fetchedassessment.Id);

                // check for aprioricondition list
                Assert.AreEqual(fetchedassessment.AprioriConditionList.Length == 0, true);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "CRUD operation failed for assessment");
            }
        }
 public Datastream CreateDatastream(DatastreamRequest datastream)
 {
     try
     {
         return(_falkonryService.CreateDatastream(datastream));
     }catch (Exception)
     {
         throw;
     }
 }
        public void AddDataFromStreamJson()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "STANDALONE";
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();

            ds.Name = "TestDS" + randomNumber;
            var Field = new Field();

            Field.Time    = time;
            ds.Field      = Field;
            ds.DataSource = datasource;

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var folder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                var path = folder + "/../../resources/addData.json";

                var bytes = File.ReadAllBytes(path);

                var options = new SortedDictionary <string, string>();
                options.Add("timeIdentifier", "time");
                options.Add("timeFormat", "YYYY-MM-DD HH:mm:ss");
                options.Add("timeZone", "GMT");
                options.Add("streaming", "false");
                options.Add("hasMoreData", "false");


                var inputstatus = _falkonry.AddInputStream(datastream.Id, bytes, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(null, exception.Message, "Cannot add data");
            }
        }
        public void createDatastreamOlderNarrowFormatSingleEntity()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "PI";
            var ds     = new DatastreamRequest();
            var Field  = new Field();
            var Signal = new Signal();

            Signal.ValueIdentifier = "value";
            Signal.TagIdentifier   = "tag";
            Signal.IsSignalPrefix  = true;
            Signal.Delimiter       = "-";
            Field.Signal           = Signal;
            Field.Time             = time;
            ds.Field      = Field;
            ds.DataSource = datasource;
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            ds.Name       = "TestDS" + randomNumber;
            ds.Field.Time = time;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                Assert.AreEqual(ds.Field.Signal.ValueIdentifier, datastream.Field.Signal.ValueIdentifier);
                Assert.AreEqual(ds.Field.Signal.TagIdentifier, datastream.Field.Signal.TagIdentifier);
                Assert.AreEqual(ds.Field.Signal.IsSignalPrefix, datastream.Field.Signal.IsSignalPrefix);
                Assert.AreEqual(ds.Field.Signal.Delimiter, datastream.Field.Signal.Delimiter);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error creating datastream");
            }
        }
Пример #12
0
        public void TestAssessmentDelete()
        {
            var time = new Time
            {
                Zone       = "GMT",
                Identifier = "Time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "STANDALONE"
            };
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var Field = new Field
            {
                Time = time
            };
            var ds = new DatastreamRequest
            {
                Name       = "TestDS" + randomNumber,
                Field      = Field,
                DataSource = datasource
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotSame(null, datastream.Id);
                // create assessment
                AssessmentRequest asmtRequest = new AssessmentRequest
                {
                    Name       = "TestAsmt",
                    Datastream = datastream.Id
                };
                var assessmentCreated = _falkonry.CreateAssessment(asmtRequest);
                _falkonry.DeleteAssessment(assessmentCreated.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "CRUD operation failed for assessment");
            }
        }
        public void CreatePiDatastreamTest()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "PI";
            datasource.Host = "https://test.piserver.com/piwebapi";
            datasource.ElementTemplateName = "SampleElementTempalte";
            var ds     = new DatastreamRequest();
            var Field  = new Field();
            var Signal = new Signal();

            Signal.ValueIdentifier  = "value";
            Signal.SignalIdentifier = "signal";
            Field.Signal            = Signal;
            Field.Time    = time;
            ds.Field      = Field;
            ds.DataSource = datasource;
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            ds.Name       = "TestDS" + randomNumber;
            ds.Field.Time = time;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error creating datastream");
            }
        }
Пример #14
0
        // Create Datastream
        public Datastream CreateDatastream(DatastreamRequest datastream)
        {
            try
            {
                var data = JsonConvert.SerializeObject(datastream, Formatting.Indented,
                                                       new JsonSerializerSettings()
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });

                var datastreamJson = _http.Post("/datastream", data);


                return(JsonConvert.DeserializeObject <Datastream>(datastreamJson));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void CreateStandaloneDatastream()
        {
            var time = new Time
            {
                Zone       = "Asia/Kolkata",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "STANDALONE"
            };
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var Field = new Field
            {
                Time = time
            };
            var ds = new DatastreamRequest
            {
                Name       = "TestDS" + randomNumber,
                Field      = Field,
                DataSource = datasource
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error creating datastream");
            }
        }
        public void CreateMicrosecondsDatastream()
        {
            var time = new Time();

            time.Zone       = "Asia/Kolkata";
            time.Identifier = "time";

            time.Format = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "STANDALONE";
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();

            ds.Name          = "TestDS" + randomNumber;
            ds.TimePrecision = "micro";
            var Field = new Field();

            Field.Time = time;

            ds.Field      = Field;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                Assert.AreEqual(ds.TimePrecision, datastream.TimePrecision);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error creating datastream");
            }
        }
        public void GetDatastreamsTest()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "Time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "STANDALONE";
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();

            ds.Name = "TestDS" + randomNumber;
            var Field = new Field();

            Field.Time = time;

            ds.Field      = Field;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);

                // get datastreams list
                List <Datastream> datastreamList = _falkonry.GetDatastreams();
                Assert.AreEqual(datastreamList.Count > 0, true);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot retrieve list of datastreams");
            }
        }
Пример #18
0
        public void AddFactsForBatchDatastream()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };

            var Signal = new Signal
            {
                ValueIdentifier  = "value",
                SignalIdentifier = "signal"
            };
            var Field = new Field
            {
                Signal           = Signal,
                Time             = time,
                EntityIdentifier = "Unit",
                BatchIdentifier  = "batch"
            };
            var ds = new DatastreamRequest
            {
                Field      = Field,
                DataSource = datasource,
                Name       = "TestDS" + randomNumber
            };

            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);

                datastream = _falkonry.GetDatastream(datastream.Id);

                //add data
                var data    = "time,Unit,current,vibration,state,batch\n2016-05-05T12:00:00.000Z,Unit1,12.4,3.4,On,batch1";
                var options = new SortedDictionary <string, string>
                {
                    { "timeIdentifier", "time" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", time.Zone },
                    { "streaming", "false" },
                    { "hasMoreData", "false" },
                    { "entityIdentifier", "Unit" },
                    { "batchIdentifier", "batch" }
                };
                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);

                // add assessment
                var asmt          = new AssessmentRequest();
                var randomNumber1 = System.Convert.ToString(rnd.Next(1, 10000));
                asmt.Name       = "TestAssessment" + randomNumber1;
                asmt.Datastream = datastream.Id;
                var optionsFacts = new SortedDictionary <string, string>
                {
                    { "entityIdentifier", datastream.Field.EntityIdentifier },
                    { "valueIdentifier", "Health" },
                    { "batchIdentifier", "Batch" }
                };
                var assessment = _falkonry.CreateAssessment(asmt);

                var data1 = datastream.Field.EntityIdentifier
                            + ",Health,Batch\nUnit1,Normal,batch1\nUnit1,Normal,batch2";
                var response = _falkonry.AddFacts(assessment.Id, data1, optionsFacts);

                //check data status
                CheckStatus(response.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add facts");
            }
        }
Пример #19
0
        public void AddJsonData()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var time = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "YYYY-MM-DD HH:mm:ss"
            };
            var Field = new Field
            {
                Time             = time,
                EntityIdentifier = "Unit"
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };
            var ds = new DatastreamRequest
            {
                Name       = "TestDSJSON" + randomNumber,
                Field      = Field,
                DataSource = datasource
            };

            // Input List
            var inputList = new List <Input>();
            var currents  = new Input
            {
                Name      = "current",
                ValueType = new ValueType(),
                EventType = new EventType()
            };

            currents.ValueType.Type = "Numeric";
            currents.EventType.Type = "Samples";
            inputList.Add(currents);

            var vibration = new Input
            {
                Name      = "vibration",
                ValueType = new ValueType(),
                EventType = new EventType()
            };

            vibration.ValueType.Type = "Numeric";
            vibration.EventType.Type = "Samples";
            inputList.Add(vibration);

            var state = new Input
            {
                Name      = "state",
                ValueType = new ValueType(),
                EventType = new EventType()
            };

            state.ValueType.Type = "Categorical";
            state.EventType.Type = "Samples";
            inputList.Add(state);

            ds.InputList = inputList;

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var data    = "{\"time\" :\"2016-03-01 01:01:01\",\"Unit\":\"Unit1\", \"current\" : 12.4, \"vibration\" : 3.4, \"state\" : \"On\"}";
                var options = new SortedDictionary <string, string>
                {
                    { "streaming", "true" }
                };
                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add data");
            }
        }
Пример #20
0
        // Add live input data (csv format) to Datastream (Used for live monitoring)
        public void AddDataCsv()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var time = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var Field = new Field
            {
                EntityIdentifier = "Unit",
                Time             = time
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };
            var ds = new DatastreamRequest
            {
                Name       = "TestDSCSV" + randomNumber,
                Field      = Field,
                DataSource = datasource
            };

            // Input List
            var inputList = new List <Input>();
            var currents  = new Input
            {
                Name      = "current",
                ValueType = new ValueType(),
                EventType = new EventType()
            };

            currents.ValueType.Type = "Numeric";
            currents.EventType.Type = "Samples";
            inputList.Add(currents);

            var vibration = new Input
            {
                Name      = "vibration",
                ValueType = new ValueType(),
                EventType = new EventType()
            };

            vibration.ValueType.Type = "Numeric";
            vibration.EventType.Type = "Samples";
            inputList.Add(vibration);

            var state = new Input
            {
                Name      = "state",
                ValueType = new ValueType(),
                EventType = new EventType()
            };

            state.ValueType.Type = "Categorical";
            state.EventType.Type = "Samples";
            inputList.Add(state);

            ds.InputList = inputList;

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var data    = "time,Unit,current,vibration,state\n2016-05-05T12:00:00.000Z,Unit1,12.4,3.4,On\n2016-05-06T12:00:00.000Z,Unit1,12.4,3.4,On";
                var options = new SortedDictionary <string, string>
                {
                    { "timeIdentifier", "time" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", "GMT" },
                    { "entityIdentifier", "Unit" },
                    { "streaming", "false" },
                    { "hasMoreData", "false" }
                };
                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);

                options["streaming"] = "true";

                inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add data");
            }
        }
        public void createDatastreamWideFormatMultipleEntities()
        {
            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "iso_8601";

            var datasource = new Datasource();

            datasource.Type = "PI";
            var ds = new DatastreamRequest();
            // Input List
            var inputList = new List <Input>();
            var currents  = new Input();

            currents.Name           = "current";
            currents.ValueType      = new ValueType();
            currents.EventType      = new EventType();
            currents.ValueType.Type = "Numeric";
            currents.EventType.Type = "Samples";
            inputList.Add(currents);

            var vibration = new Input();

            vibration.Name           = "vibration";
            vibration.ValueType      = new ValueType();
            vibration.EventType      = new EventType();
            vibration.ValueType.Type = "Numeric";
            vibration.EventType.Type = "Samples";
            inputList.Add(vibration);

            var state = new Input();

            state.Name           = "state";
            state.ValueType      = new ValueType();
            state.EventType      = new EventType();
            state.ValueType.Type = "Categorical";
            state.EventType.Type = "Samples";
            inputList.Add(state);

            ds.InputList = inputList;
            var Field  = new Field();
            var Signal = new Signal();

            Field.Signal           = Signal;
            Field.Time             = time;
            Field.EntityIdentifier = "car";
            ds.Field      = Field;
            ds.DataSource = datasource;
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            ds.Name       = "TestDS" + randomNumber;
            ds.Field.Time = time;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                Assert.AreEqual(ds.Field.EntityIdentifier, datastream.Field.EntityIdentifier);
                Assert.AreEqual(datastream.InputList.Count, 3);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error creating datastream");
            }
        }
Пример #22
0
        public void AddFactsForSingleEntity()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };
            var Signal = new Signal
            {
                ValueIdentifier  = "value",
                SignalIdentifier = "signal"
            };
            var Field = new Field
            {
                Signal = Signal,
                Time   = time
            };
            var ds = new DatastreamRequest
            {
                Field      = Field,
                DataSource = datasource,
                Name       = "TestDS" + randomNumber
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                Assert.AreEqual(ds.Name, datastream.Field.EntityName);
                Assert.AreEqual(ds.Name, datastream.Field.EntityName);
                datastream = _falkonry.GetDatastream(datastream.Id);

                // add assessment
                var asmt          = new AssessmentRequest();
                var randomNumber1 = System.Convert.ToString(rnd.Next(1, 10000));
                asmt.Name       = "TestAssessment" + randomNumber1;
                asmt.Datastream = datastream.Id;
                var options = new SortedDictionary <string, string>
                {
                    { "startTimeIdentifier", "time" },
                    { "endTimeIdentifier", "end" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", time.Zone },
                    { "valueIdentifier", "Health" }
                };
                var assessment = _falkonry.CreateAssessment(asmt);

                var data1    = "time,end,Health" + "\n2011-03-31T00:00:00Z,2011-04-01T00:00:00Z,Normal\n2011-03-31T00:00:00Z,2011-04-01T00:00:00Z,Unit1,Normal";
                var response = _falkonry.AddFacts(assessment.Id, data1, options);

                //check data status
                CheckStatus(response.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add facts");
            }
        }
Пример #23
0
        public void AddFactsWithAdditionalKeywordFromStream()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };

            var Signal = new Signal
            {
                ValueIdentifier  = "value",
                SignalIdentifier = "signal"
            };
            var Field = new Field
            {
                Signal = Signal,
                Time   = time
            };
            var ds = new DatastreamRequest
            {
                Field      = Field,
                DataSource = datasource,
                Name       = "TestDS" + randomNumber
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);

                datastream = _falkonry.GetDatastream(datastream.Id);

                // add assessment
                var asmt          = new AssessmentRequest();
                var randomNumber1 = System.Convert.ToString(rnd.Next(1, 10000));
                asmt.Name       = "TestAssessment" + randomNumber1;
                asmt.Datastream = datastream.Id;
                var options = new SortedDictionary <string, string>
                {
                    { "startTimeIdentifier", "time" },
                    { "endTimeIdentifier", "end" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", time.Zone },
                    { "entityIdentifier", "car" },
                    { "valueIdentifier", "Health" },
                    { "additionalKeyword", "testTag" }
                };
                var assessment = _falkonry.CreateAssessment(asmt);
                var folder     = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                var path       = folder + "/../../resources/factData.json";
                var bytes      = File.ReadAllBytes(path);
                var response   = _falkonry.AddFactsStream(assessment.Id, bytes, options);

                //check data status
                CheckStatus(response.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add facts");
            }
        }
        public void AddDataWideFormatJsonBatch()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));

            var time = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "YYYY-MM-DD HH:mm:ss";

            var Field = new Field();

            Field.Time            = time;
            Field.BatchIdentifier = "batch";

            var datasource = new Datasource();

            datasource.Type = "PI";
            datasource.Host = "https://test.piserver.com/piwebapi";
            datasource.ElementTemplateName = "SampleElementTempalte";

            var ds = new DatastreamRequest();

            ds.Name       = "TestDSJSON" + randomNumber;
            ds.Field      = Field;
            ds.DataSource = datasource;

            // Input List
            var inputList = new List <Input>();
            var currents  = new Input();

            currents.Name           = "current";
            currents.ValueType      = new ValueType();
            currents.EventType      = new EventType();
            currents.ValueType.Type = "Numeric";
            currents.EventType.Type = "Samples";
            inputList.Add(currents);

            var vibration = new Input();

            vibration.Name           = "vibration";
            vibration.ValueType      = new ValueType();
            vibration.EventType      = new EventType();
            vibration.ValueType.Type = "Numeric";
            vibration.EventType.Type = "Samples";
            inputList.Add(vibration);

            var state = new Input();

            state.Name           = "state";
            state.ValueType      = new ValueType();
            state.EventType      = new EventType();
            state.ValueType.Type = "Categorical";
            state.EventType.Type = "Samples";
            inputList.Add(state);

            ds.InputList = inputList;

            Datastream datastream = new Datastream();

            try
            {
                datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                Assert.AreEqual(ds.Name, datastream.Field.EntityName);
                var data    = "{\"time\" :\"2016-03-01 01:01:01\", \"current\" : 12.4, \"vibration\" : 3.4, \"state\" : \"On\", \"batch\" : \"batch1\"}";
                var options = new SortedDictionary <string, string>();
                options.Add("streaming", "false");
                options.Add("hasMoreData", "false");
                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot add data");
            }
        }
Пример #25
0
        public void GetFacts()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };
            var ds = new DatastreamRequest();

            var Signal = new Signal
            {
                ValueIdentifier  = "value",
                SignalIdentifier = "signal"
            };
            var Field = new Field
            {
                Signal           = Signal,
                Time             = time,
                EntityIdentifier = "Unit"
            };

            ds.Field      = Field;
            ds.DataSource = datasource;
            ds.Name       = "TestDS" + randomNumber;
            ds.DataSource = datasource;
            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);

                datastream = _falkonry.GetDatastream(datastream.Id);

                //add data
                var data    = "time,Unit,current,vibration,state\n 2016-05-05T12:00:00.000Z,Unit1,12.4,3.4,On";
                var options = new SortedDictionary <string, string>
                {
                    { "timeIdentifier", "time" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", time.Zone },
                    { "streaming", "false" },
                    { "hasMoreData", "false" },
                    { "entityIdentifier", "Unit" }
                };
                InputStatus inputstatus = _falkonry.AddInput(datastream.Id, data, options);

                //check data status
                CheckStatus(inputstatus.Id);

                // add assessment
                var asmt          = new AssessmentRequest();
                var randomNumber1 = System.Convert.ToString(rnd.Next(1, 10000));
                asmt.Name       = "TestAssessment" + randomNumber1;
                asmt.Datastream = datastream.Id;
                var assessment = _falkonry.CreateAssessment(asmt);

                var optionsFacts = new SortedDictionary <string, string>
                {
                    { "startTimeIdentifier", "time" },
                    { "endTimeIdentifier", "end" },
                    { "timeFormat", "iso_8601" },
                    { "timeZone", time.Zone },
                    { "entityIdentifier", datastream.Field.EntityIdentifier },
                    { "valueIdentifier", "Health" }
                };

                var data1 = "time,end," + datastream.Field.EntityIdentifier
                            + ",Health\n2011-03-31T00:00:00.000Z,2011-04-01T00:00:00.000Z,Unit1,Normal\n2011-03-31T00:00:00.000Z,2011-04-01T00:00:00.000Z,Unit1,Normal";
                inputstatus = _falkonry.AddFacts(assessment.Id, data1, optionsFacts);

                //check data status
                CheckStatus(inputstatus.Id);

                /// Get Facts
                options = new SortedDictionary <string, string>
                {
                    { "startTime", "2011-03-30T00:00:00.000Z" },
                    { "endTime", "2011-04-01T00:00:00.000Z" },
                    { "responseFormat", "application/json" }
                };
                var factsData = _falkonry.getFacts(assessment.Id, options);
                Assert.AreEqual(factsData.Response.Length > 0, true);
                Assert.AreEqual(factsData.Response.ToLower().Contains(optionsFacts["startTimeIdentifier"].ToLower()), true);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Cannot get facts");
            }
        }
        public void CannotAddDataMissingBatch()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var ds           = new DatastreamRequest();
            var time         = new Time();

            time.Zone       = "GMT";
            time.Identifier = "time";
            time.Format     = "iso_8601";
            ds.Name         = "TestDSCSV" + randomNumber;

            var Field = new Field();

            Field.EntityIdentifier = "Unit";
            Field.BatchIdentifier  = "batch";
            Field.Time             = time;
            ds.Field = Field;
            var datasource = new Datasource();

            datasource.Type = "PI";
            datasource.Host = "https://test.piserver.com/piwebapi";
            datasource.ElementTemplateName = "SampleElementTempalte";
            ds.DataSource = datasource;

            // Input List
            var inputList = new List <Input>();
            var currents  = new Input();

            currents.Name           = "current";
            currents.ValueType      = new ValueType();
            currents.EventType      = new EventType();
            currents.ValueType.Type = "Numeric";
            currents.EventType.Type = "Samples";
            inputList.Add(currents);

            var vibration = new Input();

            vibration.Name           = "vibration";
            vibration.ValueType      = new ValueType();
            vibration.EventType      = new EventType();
            vibration.ValueType.Type = "Numeric";
            vibration.EventType.Type = "Samples";
            inputList.Add(vibration);

            var state = new Input();

            state.Name           = "state";
            state.ValueType      = new ValueType();
            state.EventType      = new EventType();
            state.ValueType.Type = "Categorical";
            state.EventType.Type = "Samples";
            inputList.Add(state);

            ds.InputList = inputList;

            Datastream datastream = new Datastream();

            try
            {
                datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);
                var data    = "time,Unit,current,vibration,state,batch_changed\n 2016-05-05T12:00:00.000Z,Unit1,12.4,3.4,On,batch1";
                var options = new SortedDictionary <string, string>();
                options.Add("timeIdentifier", "time");
                options.Add("timeFormat", "iso_8601");
                options.Add("timeZone", time.Zone);
                options.Add("streaming", "false");
                options.Add("hasMoreData", "false");
                options.Add("entityIdentifier", "Unit");

                var inputstatus = _falkonry.AddInput(datastream.Id, data, options);
                Assert.AreEqual(true, false, "No exception in case of missing entity Identifier");
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, "Missing batch identifier", "Incorrect error message for missing entity identifier");
            }
        }
        public void AddEntityMeta()
        {
            var rnd          = new System.Random();
            var randomNumber = System.Convert.ToString(rnd.Next(1, 10000));
            var time         = new Time
            {
                Zone       = "GMT",
                Identifier = "time",
                Format     = "iso_8601"
            };
            var datasource = new Datasource
            {
                Type = "PI",
                Host = "https://test.piserver.com/piwebapi",
                ElementTemplateName = "SampleElementTempalte"
            };
            var Signal = new Signal
            {
                ValueIdentifier  = "value",
                SignalIdentifier = "signal"
            };
            var Field = new Field
            {
                Signal = Signal,
                Time   = time
            };
            var ds = new DatastreamRequest
            {
                Field      = Field,
                DataSource = datasource,
                Name       = "TestDS" + randomNumber
            };

            try
            {
                var datastream = _falkonry.CreateDatastream(ds);
                _datastreams.Add(datastream);
                Assert.AreEqual(ds.Name, datastream.Name);
                Assert.AreNotEqual(null, datastream.Id);
                Assert.AreEqual(ds.Field.Time.Format, datastream.Field.Time.Format);
                Assert.AreEqual(ds.Field.Time.Identifier, datastream.Field.Time.Identifier);
                Assert.AreEqual(ds.DataSource.Type, datastream.DataSource.Type);

                datastream = _falkonry.GetDatastream(datastream.Id);
                var entityMetaRequestList = new List <EntityMetaRequest>();
                var entityMetaRequest1    = new EntityMetaRequest
                {
                    Label    = "User readable label",
                    SourceId = "1234-21342134",
                    Path     = "//root/branch1/"
                };
                var entityMetaRequest2 = new EntityMetaRequest
                {
                    Label    = "User readable label2",
                    SourceId = "1234-213421rawef",
                    Path     = "//root/branch2/"
                };
                entityMetaRequestList.Add(entityMetaRequest1);
                entityMetaRequestList.Add(entityMetaRequest2);

                var entityMetaResponseList = _falkonry.PostEntityMeta(entityMetaRequestList, datastream);
                Assert.AreEqual(2, entityMetaResponseList.Count);

                // Get entitymeta
                entityMetaResponseList = _falkonry.GetEntityMeta(datastream);
                Assert.AreEqual(2, entityMetaResponseList.Count);
            }
            catch (System.Exception exception)
            {
                Assert.AreEqual(exception.Message, null, "Error creating entitymeta");
            }
        }