コード例 #1
0
ファイル: Quality.cs プロジェクト: lumizila/MindInfinity-EEG
    public IEnumerator populateQuality(string data)
    {
        DevClass dev = new DevClass();

        parseDev(data, dev);
        if (globalscripts.language == "pt")
        {
            qualityText.GetComponent <TextMeshProUGUI> ().text = "Bateria do dispositivo: " + dev.battery;
            int i = 1;
            foreach (float channel in dev.channels)
            {
                qualityText.GetComponent <TextMeshProUGUI> ().text += "\n Canal " + i + ": " + channel.ToString();
                i++;
            }
        }
        else
        {
            qualityText.GetComponent <TextMeshProUGUI> ().text = "Device battery: " + dev.battery;
            int i = 1;
            foreach (float channel in dev.channels)
            {
                qualityText.GetComponent <TextMeshProUGUI> ().text += "\n Channel " + i + ": " + channel.ToString();
                i++;
            }
        }
        yield return(0);
    }
コード例 #2
0
ファイル: Quality.cs プロジェクト: lumizila/MindInfinity-EEG
    public void parseDev(string data, DevClass dev)
    {
        devEventClass res = JsonUtility.FromJson <devEventClass> (data);

        dev.battery = res.dev[0];
        dev.signal  = res.dev[1];

        //parse of signals
        //delete the first `"dev":[' chars
        //TODO checar se substring[8 ou 7]
        string chans       = data.Substring(8);
        int    indexofList = chans.IndexOf("[");

        chans        = chans.Substring(indexofList + 1, (chans.LastIndexOf("]") - indexofList - 2));
        dev.channels = chans.Split(',').Select(float.Parse).ToList();
    }
コード例 #3
0
ファイル: DataBaseOperations.cs プロジェクト: BojanSteric/RES
 public void SaveData(DevClass dc)
 {
     using (AMIEntities entity = new AMIEntities())
     {
         foreach (Merenje m in dc.ListMerenje.Values)
         {
             Device d = new Device()
             {
                 Devcode = dc.AMIDevCode.ToString(),
                 time    = dc.TimeStamp.ToString(),
                 idMer   = dc.ListMerenje[m.Id].Id.ToString(),
             };
             entity.Devices.Add(d);
             entity.SaveChanges();
         }
     }
 }
コード例 #4
0
ファイル: DataBaseOperations.cs プロジェクト: BojanSteric/RES
        public List <DevClass> LoadDevices()
        {
            List <DevClass> devs = new List <DevClass>();

            using (AMIEntities entity = new AMIEntities())
            {
                List <Device>  ds = entity.Devices.ToList <Device>();
                List <Merenja> ms = entity.Merenjas.ToList <Merenja>();
                int            i  = 0;
                foreach (var d in ds)
                {
                    DevClass dc = new DevClass();

                    dc.AMIDevCode = Int32.Parse(d.Devcode);
                    dc.TimeStamp  = Int32.Parse(d.time);
                    dc.idMer      = ms[i].idMerenja;

                    devs.Add(dc);

                    i++;
                }
            };
            return(devs);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: BojanSteric/RES
        static void Main(string[] args)
        {
            ChannelFactory <IDevice> factory = new ChannelFactory <IDevice>(
                new NetTcpBinding(),
                new EndpointAddress("net.tcp://localhost:4000/DeviceMethods"));

            IDevice kanal = factory.CreateChannel();


            int type  = kanal.randomType();
            int value = kanal.randomValue();


            List <Merenje> merenje = new List <Merenje>();

            //Baza.devices.Add(d.AMIDevCode, d);
            Dictionary <int, Merenje> z = new Dictionary <int, Merenje>();

            for (int j = 1; j < 4; j++)
            {
                type  = kanal.randomType();
                value = kanal.randomValue();

                Merenje m = new Merenje(j, (measurmentType)type, value);
                merenje.Add(m);
                //Baza.devices.Add(d.AMIDevCode, d);


                z.Add(m.Id, m);
                Console.WriteLine(" tip " + m.Tip + " val " + m.Vrednost);
                Thread.Sleep(1000);
            }


            int i = kanal.formirajKljuc();

            DevClass d = new DevClass(i, z);

            kanal.DodajDevice(d);
            Console.WriteLine("Uspesno dodat dev");
            Console.WriteLine("dev " + d.AMIDevCode + " time " + d.TimeStamp + " p " + d.Power.ToString());

            kanal.DodajMerenjaDevice(merenje, d);
            Console.WriteLine("uspesno dodato merenje");


            if (kanal.dobaviDevice(i, out DevClass dc))
            {
                Console.WriteLine("dev " + dc.AMIDevCode + " time " + dc.TimeStamp);
                List <Merenje> ss = d.dobaviTipMerenje();
                Console.WriteLine(ss[0].Tip);
            }


            Console.WriteLine("q - za disconnect");
            if (Console.ReadLine() == "q")
            {
                kanal.ukloniDevice(i);

                Console.WriteLine("device diskonektovan");
            }

            Console.ReadKey();
        }