public void MyTestInitialize()
        {
            greenhouse = new Greenhouse();
            greenhouse.GreenhouseID = "UnitTesting";
            greenhouse.IP           = "127.0.0.1";
            greenhouse.Password     = "******";
            greenhouse.Port         = 8070;

            db.Greenhouses.Add(greenhouse);
            db.SaveChanges();

            datalog = new Datalog();
            datalog.Greenhouse_ID       = greenhouse.GreenhouseID;
            datalog.TimeOfReading       = DateTime.Now;
            datalog.InternalTemperature = 20;
            datalog.ExternalTemperature = 20;
            datalog.Humidity            = 20;
            datalog.Waterlevel          = 20;

            foreach (Datalog log in db.Datalogs)
            {
                if (log.Greenhouse_ID == datalog.Greenhouse_ID)
                {
                    db.Datalogs.Remove(log);
                }
            }

            db.SaveChanges();

            client    = new ClientMock(greenhouse.IP, greenhouse.Port);
            client.ID = greenhouse.GreenhouseID;
            client.ListenForCommunication();

            ServiceFacadeGetter.getInstance();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Datalog datalog = db.Datalogs.Find(id);

            db.Datalogs.Remove(datalog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Greenhouse_ID,TimeOfReading,InternalTemperature,ExternalTemperature,Humidity,Waterlevel")] Datalog datalog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(datalog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(datalog));
 }
        // GET: Datalogs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Datalog datalog = db.Datalogs.Find(id);

            if (datalog == null)
            {
                return(HttpNotFound());
            }
            return(View(datalog));
        }
        public void datalog(string greenHouseID, DateTime timeofreading, Nullable <double> internalTemperature, Nullable <double> externalTemperature, Nullable <double> humidity, Nullable <double> waterlevel)
        {
            GreenhouseDBContext db      = new GreenhouseDBContext();
            Datalog             datalog = new Datalog();

            datalog.Greenhouse_ID       = greenHouseID;
            datalog.TimeOfReading       = timeofreading;
            datalog.InternalTemperature = (float)internalTemperature;
            datalog.ExternalTemperature = (float)externalTemperature;
            datalog.Humidity            = (float)humidity;
            datalog.Waterlevel          = (float)waterlevel;

            db.Datalogs.Add(datalog);
            db.SaveChanges();
        }
Пример #6
0
        static public UInt32 PasswdStrToUInt32(String pwdStr)
        {
            UInt32 pwdUInt32 = 0;

            try
            {
                for (int i = 0, s = 28; i < pwdStr.Length; i++, s -= 4)
                {
                    byte nibble = Byte.Parse(pwdStr.Substring(i, 1), System.Globalization.NumberStyles.HexNumber);
                    pwdUInt32 |= (uint)((nibble & 0x0f) << s);
                }
            }
            catch (Exception e)
            {
                Datalog.LogStr("Byte Parse " + pwdStr + " failed with reason: " + e.Message);
                pwdUInt32 = 0; // reset to 0 to be safe
            }

            return(pwdUInt32);
        }