public ActionResult DeleteConfirmed(int id)
        {
            RpiVersion rpiVersion = db.RpiVersions.Find(id);

            db.RpiVersions.Remove(rpiVersion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,VersionNo,Description")] RpiVersion rpiVersion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rpiVersion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rpiVersion));
 }
        public ActionResult Create([Bind(Include = "Id,VersionNo,Description")] RpiVersion rpiVersion)
        {
            if (ModelState.IsValid)
            {
                db.RpiVersions.Add(rpiVersion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rpiVersion));
        }
Esempio n. 4
0
        public IOconfMap(string row, int lineNum) : base(row, lineNum, "Map")
        {
            format = "Map;SerialNo/COM1/USB1-1.1;BoxName;[NodeName];[baud rate]";

            var list = ToList();

            if (list[0] != "Map")
            {
                throw new Exception($"IOconfMap: wrong format: {row} {format}");
            }
            bool isWindows = RpiVersion.IsWindows();

            if (isWindows && list[1].StartsWith("COM"))
            {
                USBPort = list[1];
            }
            else if (!isWindows && list[1].StartsWith("USB"))
            {
                USBPort = "/dev/" + list[1];
            }
            else
            {
                SerialNumber = list[1];
            }

            BoxName = list[2];
            if (list.Count <= 3)
            {
                return;
            }

            string distributedNodeName = list.Count == 5 ? list[3] : default;
            var    baudrate            = 0;

            if (list.Count >= 5 && !int.TryParse(list[4], out baudrate))
            {
                CALog.LogErrorAndConsoleLn(LogID.A, $"Failed to parse the baud rate for the board: {BoxName}. Attempting with defaults.");
            }
            else if (list.Count == 4 && int.TryParse(list[3], out baudrate))
            {
                BaudRate = baudrate;
            }
            else
            {
                distributedNodeName = list[3];
            }

            BaudRate        = baudrate;
            DistributedNode = distributedNodeName != default
                ? IOconfFile.GetEntries <IOconfNode>().SingleOrDefault(n => n.Name == distributedNodeName) ?? throw new Exception($"Failed to find node in configuration for Map: {row}. Format: {format}")
                : !IOconfFile.GetEntries <IOconfNode>().Any() ? DistributedNode : throw new Exception($"The node name is not optional for distributed deployments: {row}. Format: {format}");
        }
        // GET: Rpi/RpiVersions/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RpiVersion rpiVersion = db.RpiVersions.Find(id);

            if (rpiVersion == null)
            {
                return(HttpNotFound());
            }
            return(View(rpiVersion));
        }
        static async Task MainAsync(string[] args)
        {
            try
            {
                CALog.LogInfoAndConsoleLn(LogID.A, RpiVersion.GetWelcomeMessage($"Upload temperature data to cloud"));
                Console.WriteLine("Initializing...");
                using (var serial = await SerialNumberMapper.DetectDevices())
                {
                    if (args.Length > 0 && args[0] == "-listdevices")
                    {
                        return; // SerialNumberMapper already lists devices, no need for further output.
                    }
                    // close all ports which are not Hub10
                    serial.McuBoards.Where(x => !x.productType.Contains("Temperature") && !x.productType.Contains("Hub10STM")).ToList().ForEach(x => x.SafeClose(System.Threading.CancellationToken.None).Wait());

                    var email = IOconfSetup.UpdateIOconf(serial);

                    using var cmd   = new CommandHandler(serial);
                    using var usb   = new ThermocoupleBox(cmd);
                    using var cloud = new ServerUploader(cmd.GetFullSystemVectorDescription(), cmd);
                    CALog.LogInfoAndConsoleLn(LogID.A, "Now connected to server...");
                    _ = Task.Run(() => cmd.RunSubsystems());

                    int i = 0;
                    var uploadThrottle = new TimeThrottle(100);
                    while (cmd.IsRunning)
                    {
                        var(sensorsSamples, vectorTime) = cmd.GetFullSystemVectorValues();
                        cloud.SendVector(sensorsSamples.Select(v => v.Value).ToList(), vectorTime);
                        Console.Write($"\r data points uploaded: {i++}"); // we don't want this in the log file.
                        uploadThrottle.Wait();
                        if (i == 20)
                        {
                            DULutil.OpenUrl(cloud.GetPlotUrl());
                        }
                    }
                }
                CALog.LogInfoAndConsoleLn(LogID.A, Environment.NewLine + "Bye..." + Environment.NewLine + "Press any key to exit");
            }
            catch (Exception ex)
            {
                ShowHumanErrorMessages(ex);
            }

            Console.ReadKey();
        }