Ejemplo n.º 1
0
        private void saveDevices()
        {
            mainConsole = new device();
            devicesA.Clear();
            devicesB.Clear();

            for (int i = 0; i < dataGridViewDevices.Rows.Count; i++)
            {
                device device = readDevice(i);
                switch (device.connection)
                {
                case "A":
                    devicesA.Add(device);
                    break;

                case "B":
                    devicesB.Add(device);
                    break;

                default:
                    mainConsole = device;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["userID"] != null)
     {
         if (Session["isAdmin"].Equals(true))
         {
             device device = db.devices.Find(id);
             db.devices.Remove(device);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else if (Session["userID"] != null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Ejemplo n.º 3
0
 /*
  * Delete function is to delete a specific device. Works only for admin.
  */
 // GET: devices/Delete/5
 public ActionResult Delete(int?id)
 {
     if (Session["userID"] != null)
     {
         if (Session["isAdmin"].Equals(true))
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             device device = db.devices.Find(id);
             if (device == null)
             {
                 return(HttpNotFound());
             }
             return(View(device));
         }
         else if (Session["userID"] != null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "DeviceID,DName,DManufacturer,DType,DOS,DOSVersion,DProcessor,DRAM,UserID")] device device)
 {
     if (Session["userID"] != null)
     {
         if (Session["isAdmin"].Equals(true))
         {
             if (ModelState.IsValid)
             {
                 db.Entry(device).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             ViewBag.UserID = new SelectList(db.users, "userID", "userName", device.UserID);
             return(View(device));
         }
         else if (Session["userID"] != null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Ejemplo n.º 5
0
        private device readDevice(int row)
        {
            device device = new device();

            try
            {
                device.locked     = StringToBool(dataGridViewDevices.Rows[row].Cells["locked"].Value.ToString());
                device.type       = dataGridViewDevices.Rows[row].Cells["Device"].Value.ToString();
                device.connection = dataGridViewDevices.Rows[row].Cells["AES50"].Value.ToString();
                device.name       = dataGridViewDevices.Rows[row].Cells["Name"].Value.ToString();
                device.output     = dataGridViewDevices.Rows[row].Cells["Output"].Value.ToString();
                device.input      = new channel[dataGridViewChannels.Rows.Count];
                for (int j = 0; j < device.input.Length; j++)
                {
                    device.input[j].name    = dataGridViewChannels.Rows[j].Cells["Name"].Value.ToString();
                    device.input[j].phantom = StringToBool(dataGridViewChannels.Rows[j].Cells["Phantom"].Value.ToString());
                    device.input[j].phase   = StringToBool(dataGridViewChannels.Rows[j].Cells["Phase"].Value.ToString());
                    device.input[j].icon    = dataGridViewChannels.Rows[j].Cells["Icon"].Value.ToString();
                    device.input[j].color   = dataGridViewChannels.Rows[j].Cells["Color"].Value.ToString();
                    device.input[j].invert  = StringToBool(dataGridViewChannels.Rows[j].Cells["Invert"].Value.ToString());
                }
            }
            catch
            {
                MessageBox.Show("Corrupted file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            return(device);
        }
        public void FillIp(string myip)
        {
            if (!makeguuidifnodevice())
                {
                    var mydevice = new device();

                    mydevice.UUIDDevice = Guid.NewGuid().ToString();
                    _GUIDDevice = mydevice.UUIDDevice;
                    mydevice.IP = myip+":8554";
                    mydevice.Protocol = "rtsp://";
                    mydevice.PCOwner = Environment.UserName;

                    using (var musik = new pcindexEntities())
                    {
                        musik.devices.Add(mydevice);
                        musik.SaveChanges();
                    }

                }
                else
                {
                    using (var musik = new pcindexEntities())
                    {
                        var olddevice = (from p in musik.devices select p).ToList();
                        if (myip != olddevice[0].IP)
                        {
                            olddevice[0].IP = myip+":8554";

                            musik.SaveChanges();

                        }
                    }

                }
        }
Ejemplo n.º 7
0
        public IHttpActionResult Putdevice(int id, device device)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != device.ID)
            {
                return(BadRequest());
            }

            db.Entry(device).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!deviceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 8
0
        public void SaveDevInfoToDevice()
        {
            Bll bll = new Bll();

            Log.Info(LogTags.BaseData, "获取设备信息...");

            var archors = bll.Archors.ToList();
            var cameras = bll.Dev_CameraInfos.ToList();
            var list    = bll.DevInfos.GetListWithDetail(archors, cameras);


            List <device> devices = new List <device>();

            for (int i = 0; i < list.Count; i++)
            {
                DevInfo item   = list[i];
                device  device = new device();
                BaseDataHelper.SetDevice(device, item);
                //db.devices.Add(device);
                devices.Add(device);
                if (i % 20 == 0)
                {
                    Log.Info(LogTags.BaseData, string.Format("device:{0}({1}/{2})", device.name, i, list.Count));
                }
            }
            Log.Info(LogTags.BaseData, "保存设备信息...");

            BaseDataDb db = new BaseDataDb();
            var        r  = db.SetTable(db.devices, devices);

            //db.AddRange(devices);
        }
Ejemplo n.º 9
0
        private bool check_buffer(List <ushort> list, device address)
        {
            bool result = false;

            run_lock = true;
            System.Threading.Thread.Sleep(5);
            ushort[] buffer = new ushort[list.Count * 3];

            try
            {
                buffer = list.ToArray();
            }
            catch (System.ArgumentException) //for some reason if buffer size is wrong
            {
                return(false);
            }

            if (iface.current_job.Extended)
            {
                result = (buffer.Any(sh => ((sh & 0xff) == address.Address[0])) && buffer.Any(sh => ((sh & 0xff) == address.Address[1])) &&
                          buffer.Any(sh => ((sh & 0xff) == iface.current_job.ReadAddress)));
            }
            else
            {
                result = (buffer.Any(sh => ((sh & 0xff) == address.Address[0])) && buffer.Any(sh => ((sh & 0xff) == iface.current_job.ReadAddress)));
            }

            run_lock = false;
            return(result);
        }
Ejemplo n.º 10
0
 /*
  * Edit function is to edit a specific device. Works only for admin.
  */
 // GET: devices/Edit/5
 public ActionResult Edit(int?id)
 {
     if (Session["userID"] != null)
     {
         if (Session["isAdmin"].Equals(true))
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             device device = db.devices.Find(id);
             if (device == null)
             {
                 return(HttpNotFound());
             }
             ViewBag.UserID = new SelectList(db.users, "userID", "userName", Session["userID"].ToString());
             return(View(device));
         }
         else if (Session["userID"] != null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Ejemplo n.º 11
0
        public LoginActor()
        {
            ReceiveAsync <LoginTask>(async(task) =>
            {
                device    = task.device;
                role      = task.role;
                data      = task.data;
                serverApi = task.serverApi == null ? ServerApiManager.GetByRoleId(role.id) : task.serverApi;

                if (serverApi == null)
                {
                    InitServerApi();
                    task.serverApi = serverApi;
                }

                if (data == null)
                {
                    task.data = data = new role_data()
                    {
                        role_id = role.id
                    };
                }
                task.serverApi = serverApi;
                Sender.Tell
                (
                    await Context.ActorOf <MemberActor>().Ask <bool>(task) &&
                    await Context.ActorOf <ApiLoginActor>().Ask <bool>(task) &&
                    await Context.ActorOf <LoginToMemberCenterActor>().Ask <bool>(task)
                );
            });
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Delete(string id, string serialCode, string port)
        {
            string name, error, loginName;

            if (CookieHelper.HasCookie(out name, out error) == false)
            {
                return(RedirectToAction("", "LoginUI"));
            }
            else
            {
                new RoleHelper().GetRoles(name, out role, out department1Code, out loginName);
                ViewData["VisitorRole"] = role;
                ViewData["username"]    = loginName;
            }
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index", "Device"));
            }
            int slaveID     = int.Parse(id);
            int servicePort = int.Parse(port);

            using (mlrmsEntities db = new mlrmsEntities())
            {
                device matchOne = db.device.Where(m => m.slaveid == slaveID && m.servicecode == serialCode && m.port == servicePort).ToList().First();
                db.device.Attach(matchOne);
                db.Entry(matchOne).State = System.Data.Entity.EntityState.Deleted;
                await db.SaveChangesAsync();

                //通知客户端已经移除;
                MvcApplication.Client.Refresh(slaveID, false);
            }
            return(RedirectToAction("Index", "Device"));
        }
Ejemplo n.º 13
0
        public void saveChanges()
        {
            using (var db = new PlanningContext())
            {
                device data = null;

                if (!this._isCreateMode)
                {
                    var id = Convert.ToInt32(this.device_id.Text);
                    data = db.devices.Where(d => d.device_id == id).FirstOrDefault();
                    if (data == null)
                    {
                        this._mainInterface.statusText = $"ERROR: ID '{this.device_id.Text}' does not exist.";
                        return;
                    }
                }
                else
                {
                    data = new device();
                }

                data.device_id          = Convert.ToInt32(this.device_id.Text);
                data.name               = /**/ (this.name.Text);
                data.description        = /**/ (this.description.Text);
                data.location           = /**/ (this.location.Text);
                data.min_value          = Convert.ToDouble(this.min_value.Text);
                data.max_value          = Convert.ToDouble(this.max_value.Text);
                data.accuracy           = Convert.ToDouble(this.accuracy.Text);
                data.serial_number      = /**/ (this.serial_number.Text);
                data.cost               = Convert.ToDecimal(this.cost.Text);
                data.reliability        = Convert.ToInt32(this.reliability.Text);
                data.strikes            = Convert.ToInt32(this.strikes.Text);
                data.is_active          = (bool)this.is_active.IsChecked;
                data.comment            = /**/ (this.comment.Text);
                data.is_allowed_for_use = (bool)this.is_allowed_for_use.IsChecked;
                data.device2            = new Func <device>(() => { foreach (var v in db.devices)
                                                                    {
                                                                        if (v.device_id == (this.device2.item as device).device_id)
                                                                        {
                                                                            return(v);
                                                                        }
                                                                    }
                                                                    return(null); })();
                data.device_type = new Func <device_type>(() => { foreach (var v in db.device_type)
                                                                  {
                                                                      if (v.device_type_id == (this.device_type.item as device_type).device_type_id)
                                                                      {
                                                                          return(v);
                                                                      }
                                                                  }
                                                                  return(null); })();


                if (this._isCreateMode)
                {
                    db.devices.Add(data);
                }
                db.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        public async Task <IHttpActionResult> PostDevice(device device)
        {
            using (DMSEntities dbContext = new DMSEntities())
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                dbContext.devices.Add(device);
                await dbContext.SaveChangesAsync();

                // New code:
                // Load author name


                var dto = new DeviceDto()
                {
                    device_id    = device.device_id,
                    name         = device.name,
                    manufacturer = device.manufacturer,
                    model        = device.model,
                    OS           = device.OS,
                    OS_version   = device.OS_version,
                    CPU          = device.CPU,
                    RAM          = device.RAM
                };

                return(CreatedAtRoute("DefaultApi", new { id = device.device_id }, dto));
            }
        }
Ejemplo n.º 15
0
 public IHttpActionResult AddDevice([FromBody] device device)
 {
     device.GenerateDeviceid();
     device.user_id = user.id;
     db.Add(device);
     return(Json(device));
 }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            device my_device = new device();

            my_device.get_data();
            Console.ReadKey();
        }
Ejemplo n.º 17
0
        private void Header_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Threading.Thread.Sleep(500);             //delay to make dataset more reliable
            Console.WriteLine("Writing header for job");

            string slot = e.Argument.ToString();

            Int32.TryParse(slot, out int slot_num);

            var    name     = iface.current_job.board_names[slot_num];
            string filename = iface.current_job.LogFileName.Replace(".rlog", "_" + name + ".rlog.csv");

            using (StreamWriter writer = File.AppendText(iface.current_job.LogFilePath + filename))
            {
                /*
                 * foreach (string content in iface.current_job.file_contents)
                 *  writer.WriteLine(content);
                 */
                string line = "Timestamp,";
                for (int i = 0; i < iface.current_job.device_adds.Count; i++)
                {
                    device add = iface.current_job.device_adds[i];
                    for (int j = 0; j < iface.current_job.Sites; j++)
                    {
                        line += ("S" + (j + 1) + " - " + add.Name + ',');
                    }
                    if (add.LogOrder == 0) //in the case of header item, write it into file before full header
                    {
                        writer.WriteLine(line);
                        line = "Timestamp,"; //reset the string to remove the header item (already been written)
                    }
                }
                writer.WriteLine(line); //these should be all the headers
            }
        }
Ejemplo n.º 18
0
        //Get device info in xml format
        private device get_ic_xml(DevStruct devstruct)
        {
            devstruct.type &= 0xff;
            device xml_chip = new device();

            xml_chip.icname            = devstruct.name;
            xml_chip.protocol          = "0x" + devstruct.protocol_id.ToString("x2");
            xml_chip.type              = "0x" + devstruct.type.ToString("x2");
            xml_chip.read_buffer_size  = "0x" + devstruct.read_buffer_size.ToString("x2");
            xml_chip.write_buffer_size = "0x" + devstruct.write_buffer_size.ToString("x2");
            xml_chip.code_memory_size  = "0x" + devstruct.code_memory_size.ToString("x2");
            xml_chip.data_memory_size  = "0x" + devstruct.data_memory_size.ToString("x2");
            xml_chip.data_memory2_size = "0x" + devstruct.data_memory2_size.ToString("x2");
            xml_chip.chip_id           = "0x" + devstruct.chip_id.ToString("x4");
            xml_chip.chip_id_size      = "0x" + devstruct.chip_id_bytes_count.ToString("x2");
            xml_chip.opts1             = "0x" + devstruct.opts1.ToString("x2");
            xml_chip.opts2             = "0x" + devstruct.opts2.ToString("x2");
            xml_chip.opts3             = "0x" + devstruct.opts3.ToString("x2");
            xml_chip.opts4             = "0x" + devstruct.opts4.ToString("x2");
            xml_chip.opts5             = "0x" + devstruct.opts5.ToString("x2");
            xml_chip.opts6             = "0x" + devstruct.opts6.ToString("x2");
            xml_chip.opts7             = "0x" + devstruct.opts7.ToString("x2");
            xml_chip.package_details   = "0x" + devstruct.package_details.ToString("x8");
            xml_chip.fuses             = get_fuse_name(devstruct);
            return(xml_chip);
        }
Ejemplo n.º 19
0
        public void LoadAllDevices()
        {
            fb_con.Open();
            string    sql = "SELECT * FROM DEVICES ORDER BY ID";
            FbCommand cmd = new FbCommand(sql, fb_con);
            device    onedevice;
            DateTime  datetemp = new DateTime();

            using (FbDataReader r = cmd.ExecuteReader())
            {
                int i;
                while (r.Read())
                {
                    i                 = 0;
                    onedevice         = new device();
                    onedevice.ID      = r.GetInt32(i++);
                    onedevice.DEVICE  = r.GetString(i++);
                    onedevice.VERSION = r.GetString(i++);
                    if (DateTime.TryParse(r.GetString(i++), out datetemp))
                    {
                        onedevice.LASTREAD = datetemp;
                    }
                    onedevice.CREATEWHO   = r.GetString(i++);
                    onedevice.CREATEWHEN  = r.GetString(i++);
                    onedevice.CHANGEWHO   = r.GetString(i++);
                    onedevice.CHANGEWHEN  = r.GetString(i++);
                    onedevice.NOTES       = r.GetString(i++);
                    onedevice.LASTREADWHO = r.GetString(i++);
                    devices.Add(onedevice);
                }
            }
            fb_con.Close();
        }
Ejemplo n.º 20
0
        public ActionResult DeleteConfirmed(int id)
        {
            device device = db.devices.Find(id);

            db.devices.Remove(device);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 21
0
        public static device getDeviceFromFile(string fileName)
        {
            string          base64Device = System.IO.File.ReadAllText(fileName);
            MemoryStream    deviceStream = new MemoryStream(Convert.FromBase64String(base64Device));
            BinaryFormatter deviceBinary = new BinaryFormatter();
            device          outputDevice = (device)deviceBinary.Deserialize(deviceStream);

            return(outputDevice);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取设备详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public device GetDeviceDetail(int id)
        {
            device recv = new device();
            string path = "api/devices/" + id;
            string url  = BaseUri + path;

            recv = GetEntityDetail <device>(url);
            return(recv);
        }
Ejemplo n.º 23
0
 public hidWrapper(int vid, int pid)
 {
     string[] path = getFilteredPath(vid, pid);
     length  = path.Length;
     devices = new device[length];
     for (int i = 0; i < length; i++)
     {
         devices[i] = new device(path[i]);
     }
 }
Ejemplo n.º 24
0
 public ActionResult Edit([Bind(Include = "id,device_name,uie")] device device)
 {
     if (ModelState.IsValid)
     {
         db.Entry(device).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(device));
 }
Ejemplo n.º 25
0
        public ActionResult Create([Bind(Include = "id,device_name,uie")] device device)
        {
            if (ModelState.IsValid)
            {
                db.devices.Add(device);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(device));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取单个设备信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public device GetSingleDeviceInfo(int id)
        {
            device recv  = new device();
            string strId = Convert.ToString(id);

            try
            {
                string path = "api/devices/" + strId;
                string url  = BaseUri + path;
                recv = GetEntityDetail <device>(url);

                DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.KKS == recv.kksCode).FirstOrDefault();
                int     nFlag   = 0;
                if (devinfo == null)
                {
                    devinfo = new DevInfo();
                    nFlag   = 1;
                }

                devinfo.Abutment_Id    = recv.id;
                devinfo.Code           = recv.code;
                devinfo.KKS            = recv.kksCode;
                devinfo.Name           = recv.name;
                devinfo.Abutment_Type  = (Abutment_DevTypes)recv.type;
                devinfo.Status         = (Abutment_Status)recv.state;
                devinfo.RunStatus      = (Abutment_RunStatus)recv.running_state;
                devinfo.Placed         = recv.placed;
                devinfo.Abutment_DevID = recv.raw_id;

                if (nFlag == 1)
                {
                    devinfo.CreateTime = DateTime.Now;
                    devinfo.ModifyTime = DateTime.Now;

                    devinfo.CreateTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.CreateTime);
                    devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                    bll.DevInfos.Add(devinfo);
                }
                else
                {
                    devinfo.ModifyTime      = DateTime.Now;
                    devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                    bll.DevInfos.Edit(devinfo);
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }

            return(recv);
        }
Ejemplo n.º 27
0
        public IHttpActionResult Getdevice(int id)
        {
            device device = db.devices.Find(id);

            if (device == null)
            {
                return(NotFound());
            }

            return(Ok(device));
        }
Ejemplo n.º 28
0
        private void StartWebServer()
        {
            int count_running = 0;

            //Start listening
            boolListening = true;
            timer1.Start();
            dataGridView1.Enabled        = false;
            buttonRegisterDevice.Enabled = false;
            buttonStartServer.Text       = "&Stop Server";
            toolStripStatusLabel1.Text   = "Listening...";
            done = false;

            devices         = new Dictionary <int, device>();
            listOfListeners = new List <HttpListener>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells["ID"].Value != null)
                {
                    String strName = row.Cells[COLUMN_NAME].Value.ToString();
                    Int32  intPort;
                    Int32.TryParse(row.Cells[COLUMN_PORT].Value.ToString(), out intPort);
                    String strActionOn  = row.Cells[COLUMN_ACTION_ON].Value.ToString();
                    String strActionOff = row.Cells[COLUMN_ACTION_OFF].Value.ToString();
                    String strStateURL  = row.Cells[COLUMN_STATE_URL].Value.ToString();

                    if (intPort > 0 && !String.IsNullOrEmpty(strName) && !String.IsNullOrEmpty(strActionOff) && !String.IsNullOrEmpty(strActionOn))
                    {
                        device dev = new device();
                        dev.name       = strName;
                        dev.port       = intPort;
                        dev.action_on  = strActionOn;
                        dev.action_off = strActionOff;
                        dev.state_url  = strStateURL;

                        if (!devices.ContainsKey(intPort))
                        {
                            devices.Add(intPort, dev);
                            //start a listener on the port
                            Debug.WriteLine(devices[intPort].action_off);
                            WebServer(intPort);
                            count_running++;
                        }
                    }
                }
            }

            if (count_running == 0)
            {
                StopWebServer();
            }
        }
Ejemplo n.º 29
0
        public async Task <ActionResult <device> > Postdevice(device device)
        {
            _context.devices.Add(device);
            await _context.SaveChangesAsync();

            return(new OkObjectResult(new
            {
                Success = true,
                Message = "Nhập dữ liệu thành công",
                Data = CreatedAtAction("Getdevice", new { id = device.device_id }, device)
            }));
        }
Ejemplo n.º 30
0
        public IHttpActionResult Postdevice(device device)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.devices.Add(device);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = device.ID }, device));
        }
Ejemplo n.º 31
0
    public static device openPicture(string FileName)
    {
        //string _Filename = Application.persistentDataPath + "/" + FileName;
        string _Filename = "myMovie2.pcm";

        //string _Filename = "2018-03-22T01_45_52.763+0000.pcm";
        //string _Filename = "2018-03-02T02_45_35.849+0000.pcm";

        if (File.Exists(_Filename))
        {
            using (StreamReader sr = new StreamReader(new FileStream(_Filename, FileMode.Open)))
            {
                string test = "";
                try
                {
                    string   picture   = sr.ReadToEnd();
                    char     delimiter = '\n';
                    string[] frames    = picture.Split(delimiter);
                    int      numFrames = chk(frames);

                    if (numFrames < 1)  ////make sure numFrames is not 0
                    {
                        throw new Exception("No Data in File...");
                    }

                    CloudFrame[] cloudFrames = new CloudFrame[numFrames];
                    //delimiter = ' ';
                    //string[] deviceParams = frames[0].Split(delimiter);

                    //cycle through frames  -- REMEMBER THE FIRST FRAME IS JUST CAMERA PARAMS
                    for (int j = 0; j < numFrames; j++) //j indexes the frames array
                    {
                        test = frames[j];

                        cloudFrames[j] = JsonUtility.FromJson <CloudFrame>(test);
                        //cloudFrames[j-1] = parseJSONofJSON(test, cloudFrames[j - 1]);
                    }
                    device attachedCamera = new device();
                    attachedCamera.cloudFrames = cloudFrames;
                    return(attachedCamera);
                }
                catch (Exception e)
                {
                    e.Source = test;
                    throw e;
                }
            }
        }
        else
        {
            throw new Exception("File Not Found");
        }
    }
Ejemplo n.º 32
0
 private void buttonRobot_Click(object sender, RoutedEventArgs e)
 {
     if (selectedDevice == device.Robot)
         selectedDevice = device.None;
     else
         selectedDevice = device.Robot;
 }
Ejemplo n.º 33
0
 private void buttonSensor_Click(object sender, RoutedEventArgs e)
 {
     if (selectedDevice == device.Sensor)
         selectedDevice = device.None;
     else
         selectedDevice = device.Sensor;
 }
Ejemplo n.º 34
0
 private void buttonWorkpiece_Click(object sender, RoutedEventArgs e)
 {
     if (selectedDevice == device.Workpiece)
         selectedDevice = device.None;
     else
         selectedDevice = device.Workpiece;
 }
Ejemplo n.º 35
0
 private void buttonPump_Click(object sender, RoutedEventArgs e)
 {
     if (selectedDevice == device.Pump)
         selectedDevice = device.None;
     else
         selectedDevice = device.Pump;
 }
Ejemplo n.º 36
0
 public void LoadAllDevices()
 {
     fb_con.Open();
     string sql = "SELECT * FROM DEVICES ORDER BY ID";
     FbCommand cmd = new FbCommand(sql, fb_con);
     device onedevice;
     DateTime datetemp = new DateTime();
     using (FbDataReader r = cmd.ExecuteReader())
     {
         int i;
         while (r.Read())
         {
             i = 0;
             onedevice = new device();
             onedevice.ID = r.GetInt32(i++);
             onedevice.DEVICE = r.GetString(i++);
             onedevice.VERSION = r.GetString(i++);
             if(DateTime.TryParse(r.GetString(i++), out datetemp))
                 onedevice.LASTREAD = datetemp;
             onedevice.CREATEWHO = r.GetString(i++);
             onedevice.CREATEWHEN = r.GetString(i++);
             onedevice.CHANGEWHO = r.GetString(i++);
             onedevice.CHANGEWHEN = r.GetString(i++);
             onedevice.NOTES = r.GetString(i++);
             onedevice.LASTREADWHO = r.GetString(i++);
             devices.Add(onedevice);
         }
     }
     fb_con.Close();
 }
Ejemplo n.º 37
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    downloadedURLs.Clear();
                    mimeTypes.Clear();
                    actions.Clear();
                    actionDataTypes.Clear();
                    requestActions.Clear();

                    string deviceURL = (string)checkedListBox1.Items[i];
                    string deviceName = "";
                    List<String> servceTypes = new List<String>();
                    string deviceUDN = "";

                    string sep = "--------------------------------------------------------------------------------------------------------------------------------\r\n";

                    deviceDescString = deviceDescString + sep + "Device:\r\n " + deviceURL + "\r\n" + sep + "\r\n"; 

                    foreach (Form1.Target Target in Targets)
                    {
                        if (Target.targetService.Device.DocumentURL == deviceURL)
                        {
                            deviceDescString = deviceDescString + "Action: " + Target.actionDesc.Name + "\r\n\r\n";
                            deviceDescString = deviceDescString + "Base SOAP Response:\r\n"+Target.soapResponse + "\r\n\r\n";
                            if (!actions.ContainsKey(Target.actionDesc.Name))
                            {
                                actions.Add(Target.actionDesc.Name, Target.soapResponse);
                            }
                            if (!actionDataTypes.ContainsKey(Target.actionDesc.Name))
                            {
                                actionDataTypes.Add(Target.actionDesc.Name, Target.dataTypes);
                            }
                            if (!requestActions.ContainsKey(Target.actionDesc.Name))
                            {
                                requestActions.Add(Target.actionDesc.Name, Target.soapRequest);
                            }
                            deviceName = Target.targetService.Device.FriendlyName;
                            deviceUDN = Target.targetService.Device.UniqueDeviceName;
                            servceTypes.Add(Target.targetService.Device.Type);
                        }
                    }

                    localResourceReplacements.Clear();


                    XmlDocument desc = new XmlDocument();
                    string newDeviceDesc = "";


                    try
                    {
                        WebRequest r = HttpWebRequest.Create(deviceURL);
                        r.Timeout = 10000;
                        WebResponse wres = r.GetResponse();
                        Stream ress = wres.GetResponseStream();
                        desc.Load(ress);
                        XmlElement root = desc.DocumentElement;
                        XmlNodeList nodes = root.SelectNodes("*");
                        TraverseNodes(nodes,deviceURL);

                        newDeviceDesc = desc.InnerXml.ToString();

                        foreach(KeyValuePair<string, string> entry in localResourceReplacements)
                        {
                            newDeviceDesc = newDeviceDesc.Replace(entry.Key,entry.Value);
                        }
                        deviceDescString = deviceDescString + newDeviceDesc;
                    }
                    catch(Exception err)
                    {
                        MessageBox.Show(err.ToString());
                    }

                    device learnedDevice = new device();
                    learnedDevice.deviceDescription = newDeviceDesc;
                    learnedDevice.downloadedURLs = downloadedURLs;
                    learnedDevice.mimeTypes = mimeTypes;
                    learnedDevice.actions = actions;
                    learnedDevice.actionDataTypes = actionDataTypes;
                    learnedDevice.deviceName = deviceName;
                    learnedDevice.serviceTypes = servceTypes;
                    learnedDevice.UDN = deviceUDN;

                    
                    bw.ReportProgress(1, learnedDevice);
                    waitUntilSave = true;
                    while (waitUntilSave == true)
                    {
                        System.Threading.Thread.Sleep(100);
                    }

                    deviceDescString = deviceDescString + "\r\n";
                }

            }
        }
Ejemplo n.º 38
0
        public static void saveDeviceToFile(string fileName, device saveDevice)
        {
            MemoryStream memoryStream = new MemoryStream();
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, saveDevice);
            memoryStream.Flush();
            memoryStream.Position = 0;
            string base64Device = Convert.ToBase64String(memoryStream.ToArray());
            System.IO.StreamWriter resultsFile = new System.IO.StreamWriter(fileName);
            resultsFile.WriteLine(base64Device);
            resultsFile.Close();

        }