Exemplo n.º 1
0
        private static DevicePartSpeed GetPart(DeviceManager manager, string query)
        {
            object o = DeviceHelper.FindDevice(manager, query);

            Device device = o as Device;

            if (device != null)
            {
                if (device.Parts.Count != 0)
                {
                    Logger.Instance.WriteWarning("Found device, unable to match with package specifier, selecting default package '{0}'", device.Parts[0].Package.Name);
                    o = device.Parts[0];
                }
            }

            DevicePart part = o as DevicePart;

            if (part != null)
            {
                if (part.Speeds.Count != 0)
                {
                    Logger.Instance.WriteWarning("Found device, unable to match with speed specifier, selecting default speed '{0}'", part.Speeds[0].Speed.Name);
                    o = part.Speeds[0];
                }
            }

            return(o as DevicePartSpeed);
        }
Exemplo n.º 2
0
 public static void DisplayDevicePart(DevicePart part, bool forward, bool backward)
 {
     if (backward)
     {
         DisplayDevice(part.Parent, false, true);
     }
     Logger.Instance.WriteInfo("      + {0} ({1})", part.Name, part.Package.Name);
     if (forward)
     {
         foreach (DevicePartSpeed partSpeed in part.Speeds)
         {
             DisplayDevicePartSpeed(partSpeed, true, false);
         }
     }
 }
Exemplo n.º 3
0
 private static void ParseSpeedDetails(DeviceFamily family, DevicePart part, string speedDetails)
 {
     if (!string.IsNullOrEmpty(speedDetails))
     {
         string[] splitUpSpeeds = speedDetails.Split(new string[] { "    " }, StringSplitOptions.RemoveEmptyEntries);
         foreach (string speed in splitUpSpeeds)
         {
             // Shouldn't start with "("
             if (!speed.StartsWith("("))
             {
                 DeviceSpeed     familySpeed = family.CreateSpeed(speed);
                 DevicePartSpeed partSpeed   = part.CreateSpeed(familySpeed);
             }
         }
     }
 }
Exemplo n.º 4
0
        public static object FindDevice(DeviceManager manager, string query)
        {
            IEnumerable <object> parts = manager.FindPart(query);

            Logger.Instance.WriteDebug("Found {0} matching parts", parts.Count());

            Device          topDevice          = null;
            DevicePart      topDevicePart      = null;
            DevicePartSpeed topDevicePartSpeed = null;

            foreach (object o in parts)
            {
                if (o is Device)
                {
                    topDevice = o as Device;
                }
                else if (o is DevicePart)
                {
                    topDevicePart = o as DevicePart;
                }
                else if (o is DevicePartSpeed)
                {
                    topDevicePartSpeed = o as DevicePartSpeed;
                    // pick the first one of these
                    break;
                }
            }

            if (topDevicePartSpeed != null)
            {
                return(topDevicePartSpeed);
            }
            if (topDevicePart != null)
            {
                return(topDevicePart);
            }
            if (topDevice != null)
            {
                return(topDevice);
            }
            return(null);
        }
Exemplo n.º 5
0
    //public List<string>[] Select()
    public List <DevicePart> SelectPart(string partsn)
    {
        string query = "";

        if (String.IsNullOrEmpty(partsn))
        {
            query = "SELECT * FROM deviceparts";
        }
        else
        {
            query = "SELECT * FROM deviceparts WHERE deviceparts.sn = '" + partsn + "'";
        }

        List <DevicePart> list = new List <DevicePart>();

        if (OpenConnection() == true)
        {
            MySqlCommand    command    = new MySqlCommand(query, connection);
            MySqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                DevicePart dp = new DevicePart();
                dp.serialnumber = dataReader["sn"].ToString();
                dp.brand        = dataReader["brand"].ToString();
                dp.description  = dataReader["description"].ToString();
                dp.availability = dataReader["available"].ToString();
                dp.partid       = Convert.ToInt32(dataReader["partid"]); //casten werkt niet
                dp.price        = (float)dataReader["price"];
                list.Add(dp);
            }

            dataReader.Close();
            CloseConnection();
            return(list);
        }
        else
        {
            return(list);
        }
    }
Exemplo n.º 6
0
    public List <DevicePart> getParts(string devicesn)
    {
        string query = @"SELECT
                deviceparts.sn AS 'partSN',
                deviceparts.available,
                deviceparts.price,
                deviceparts.description
            FROM
                devices
            INNER JOIN deviceparts
            ON devices.mainboard = deviceparts.sn
            OR devices.tconboard = deviceparts.sn
            OR devices.powerboard = deviceparts.sn
            WHERE devices.sn = '" + devicesn + "'";

        List <DevicePart> list = new List <DevicePart>();

        if (OpenConnection() == true)
        {
            MySqlCommand    command    = new MySqlCommand(query, connection);
            MySqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                DevicePart dp = new DevicePart();
                dp.serialnumber = dataReader["partSN"].ToString();
                dp.description  = dataReader["description"].ToString();
                dp.price        = (float)dataReader["price"];
                dp.availability = dataReader["available"].ToString();
                list.Add(dp);
            }

            dataReader.Close();
            CloseConnection();
            return(list);
        }
        else
        {
            return(list);
        }
    }
Exemplo n.º 7
0
 public DevicePartTreeItemViewModel(DevicePart part)
 {
     _part = part;
 }
Exemplo n.º 8
0
        public static DeviceFamily LoadFamily(DeviceManufacture manufacture, string familyName)
        {
            DeviceFamily family = null;

            List <string> arguments = new List <string>();

            arguments.Add("-intstyle silent");
            arguments.Add("-arch " + familyName);
            ProcessHelper.ProcessExecutionResult result = XilinxProcess.ExecuteProcess(Environment.CurrentDirectory, "partgen", arguments);

            bool   startedList    = false;
            string realFamilyName = familyName;
            string defaultSpeeds  = null;
            Device currentDevice  = null;

            using (StringReader reader = new StringReader(result.StandardOutput))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (!startedList)
                    {
                        startedList    = true;
                        realFamilyName = line.Trim();                         // Picked up name
                        family         = new DeviceFamily(manufacture, realFamilyName, familyName);
                    }
                    else if (family != null)
                    {
                        // The first line i the part + speeds, lines afterwards are packages
                        string cleanup = line.Trim();
                        if (line.StartsWith("    "))
                        {
                            if (currentDevice != null)
                            {
                                // Device
                                string[] splitUp = cleanup.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                                if (splitUp.Length >= 1 && !string.IsNullOrEmpty(splitUp[0]))
                                {
                                    // Package specifier
                                    Logger.Instance.WriteDebug("Create/Find Package '{0}'", splitUp[0]);
                                    DevicePackage partPackage = family.CreatePackage(splitUp[0]);
                                    Logger.Instance.WriteDebug("Create/Find part with package '{0}'", partPackage.Name);
                                    DevicePart part = currentDevice.CreatePart(partPackage);

                                    // Can have an exclusive set of speeds
                                    ParseSpeedDetails(family, part, (splitUp.Length > 1) ? splitUp[1] : defaultSpeeds);
                                }
                            }
                        }
                        else
                        {
                            string[] splitUp = cleanup.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                            if (splitUp.Length >= 3 && !string.IsNullOrEmpty(splitUp[0]))
                            {
                                Logger.Instance.WriteDebug("Create/Find Device '{0}'", splitUp[0]);
                                currentDevice = family.CreateDevice(splitUp[0]);
                                defaultSpeeds = splitUp[2];                                 // Set default speed for devices
                            }
                        }
                    }
                }
            }
            return(family);
        }