Beispiel #1
0
        static void Main(string[] args)
        {
            int number_of_device = 10;

            ////IActor1 actor = ActorProxy.Create<IActor1>(ActorId.CreateRandom(), new Uri("fabric:/Application1/Actor1ActorService"));
            ////System.Threading.Tasks.Task<string> retval = actor.GetHelloWorldAsync();
            ////Console.Write(retval.Result);
            ////Console.ReadLine();
            IThing[] things = new IThing[number_of_device];
            for (int i = 1; i <= number_of_device; i++)
            {
                ThingData chillerConfigData = new ThingData();
                chillerConfigData.ThingMetaData = new ThingMetaData()
                {
                    ID   = i,
                    Name = "Device" + i
                };

                var attributeList = new List <AttributeData>();
                chillerConfigData.AttributeDatas = attributeList;
                AddAttribute(attributeList, chillerConfigData.ThingMetaData.Name, "Temperature", chillerConfigData.ThingMetaData.Name + "Temperature", "Temperature", DataType.Double, "F", 0, CreateTempLimitData());
                AddAttribute(attributeList, chillerConfigData.ThingMetaData.Name, "Humidity", chillerConfigData.ThingMetaData.Name + "Humidity", "Humidity", DataType.Double, "%", 0, CreateHumidityLimitData());
                AddAttribute(attributeList, chillerConfigData.ThingMetaData.Name, "Pressure", chillerConfigData.ThingMetaData.Name + "Humidity", "Pressure", DataType.Double, "psi", 0, CreatePresureLimitData());
                IThing actor1 = ActorProxy.Create <IThing>(new ActorId(chillerConfigData.ThingMetaData.ID), new Uri("fabric:/Application1/ThingActorService"));
                actor1.SetData(chillerConfigData);
                things[i - 1] = actor1;
            }

            Console.Write("Deplyment is done");


            for (int i = 1; i <= number_of_device; i++)
            {
                /////IThing actor1 = ActorProxy.Create<IThing>(new ActorId(i), new Uri("fabric:/Application1/ThingActorService"));
                var actor1             = things[i - 1];
                Task <ThingData> model = actor1.GetData();
                ThingData        data  = (ThingData)model.Result;
                Console.Write(data.ThingMetaData.ID + ":" + data.ThingMetaData.Name + "\n");
            }

            Console.ReadLine();

            /*
             * IThing device1 = ActorProxy.Create<IThing>(new ActorId(1), new Uri("fabric:/Application1/ThingActorService"));
             * var chiller1 = new Chiller("1", "Device1");
             * chiller1.SimulateData();
             * var runtimeDatas = chiller1.AttributeRuntimeDatas.Values;
             * ////Task<bool> retval1 = device1.ProcessEventAsync(runtimeDatas);
             * ////Console.Write(retval1.Result);
             *
             * List<AttributeRuntimeData> attributeRuntimeDatas = new List<AttributeRuntimeData>();
             * foreach (var data in chiller1.AttributeRuntimeDatas.Values)
             * {
             *  attributeRuntimeDatas.Add(data);
             * }
             */

            ////AttributeRuntimeData attributeRuntime = new AttributeRuntimeData();
            ////attributeRuntime.Name = "Temperature";
            ////attributeRuntime.dqt = new DataQualityTimestamp()
            ////{
            ////    Value = 50,
            ////    Timestamp = DateTime.UtcNow,
            ////    Status = "Good"
            ////};
            //attributeRuntimeDatas.Add(attributeRuntime);
            ///device1.ProcessEventAsync(attributeRuntimeDatas);

            ////ISampleScriptActor script = ActorProxy.Create<ISampleScriptActor>(new ActorId(Guid.NewGuid()), new Uri("fabric:/Application1/SampleScriptActorService"));
            ////while (true)
            ////{
            ////    Console.ReadLine();
            ////    Console.Write(script.GetValueOfB().Result);
            ////}
        }