From 02b9981681161f7eccee4385f30e2d7ec05c42a5 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 28 Apr 2018 13:16:53 +0100 Subject: [PATCH] Update DB to version 15: Machines can have an arbitrary number of processors, so use an interconnection table, `processors_by_machine`. --- Cicm.Database/Operations/Init.cs | 52 +- Cicm.Database/Operations/Machine.cs | 126 ++-- Cicm.Database/Operations/Operations.cs | 2 +- .../Operations/ProcessorByMachine.cs | 154 ++++ Cicm.Database/Operations/Update.cs | 130 +++- Cicm.Database/Schemas/Machine.cs | 8 - Cicm.Database/Schemas/ProcessorByMachine.cs | 43 ++ Cicm.Database/Schemas/Sql/V15.cs | 141 ++++ cicm_web/Models/Machine.cs | 64 +- cicm_web/Models/ProcessorByMachine.cs | 59 ++ cicm_web/Views/Machine/View.cshtml | 671 ++++++------------ cicm_web/cicm_web.csproj | 2 +- 12 files changed, 853 insertions(+), 599 deletions(-) create mode 100644 Cicm.Database/Operations/ProcessorByMachine.cs create mode 100644 Cicm.Database/Schemas/ProcessorByMachine.cs create mode 100644 Cicm.Database/Schemas/Sql/V15.cs create mode 100644 cicm_web/Models/ProcessorByMachine.cs diff --git a/Cicm.Database/Operations/Init.cs b/Cicm.Database/Operations/Init.cs index 1dd806a3..2ed2e347 100644 --- a/Cicm.Database/Operations/Init.cs +++ b/Cicm.Database/Operations/Init.cs @@ -49,99 +49,103 @@ namespace Cicm.Database IDbCommand dbCmd = dbCon.CreateCommand(); Console.WriteLine("Creating table `admins`"); - dbCmd.CommandText = V14.Admins; + dbCmd.CommandText = V15.Admins; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `browser_tests`"); - dbCmd.CommandText = V14.BrowserTests; + dbCmd.CommandText = V15.BrowserTests; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `cicm_db`"); - dbCmd.CommandText = V14.CicmDb; + dbCmd.CommandText = V15.CicmDb; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `companies`"); - dbCmd.CommandText = V14.Companies; + dbCmd.CommandText = V15.Companies; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `machines`"); - dbCmd.CommandText = V14.Machines; + dbCmd.CommandText = V15.Machines; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `disk_formats`"); - dbCmd.CommandText = V14.DiskFormats; + dbCmd.CommandText = V15.DiskFormats; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `forbidden`"); - dbCmd.CommandText = V14.Forbidden; + dbCmd.CommandText = V15.Forbidden; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `gpus`"); - dbCmd.CommandText = V14.Gpus; + dbCmd.CommandText = V15.Gpus; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `log`"); - dbCmd.CommandText = V14.Logs; + dbCmd.CommandText = V15.Logs; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `money_donations`"); - dbCmd.CommandText = V14.MoneyDonations; + dbCmd.CommandText = V15.MoneyDonations; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `news`"); - dbCmd.CommandText = V14.News; + dbCmd.CommandText = V15.News; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `owned_computers`"); - dbCmd.CommandText = V14.OwnedComputers; + dbCmd.CommandText = V15.OwnedComputers; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `owned_consoles`"); - dbCmd.CommandText = V14.OwnedConsoles; + dbCmd.CommandText = V15.OwnedConsoles; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `instruction_sets`"); - dbCmd.CommandText = V14.InstructionSets; + dbCmd.CommandText = V15.InstructionSets; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `instruction_set_extensions`"); - dbCmd.CommandText = V14.InstructionSetExtensions; + dbCmd.CommandText = V15.InstructionSetExtensions; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `processors`"); - dbCmd.CommandText = V14.Processors; + dbCmd.CommandText = V15.Processors; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `instruction_set_extensions_by_processor`"); - dbCmd.CommandText = V14.InstructionSetExtensionsByProcessor; + dbCmd.CommandText = V15.InstructionSetExtensionsByProcessor; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `sound_synths`"); - dbCmd.CommandText = V14.SoundSynths; + dbCmd.CommandText = V15.SoundSynths; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `iso3166_1_numeric`"); - dbCmd.CommandText = V14.Iso3166Numeric; + dbCmd.CommandText = V15.Iso3166Numeric; dbCmd.ExecuteNonQuery(); Console.WriteLine("Filling table `iso3166_1_numeric`"); - dbCmd.CommandText = V14.Iso3166NumericValues; + dbCmd.CommandText = V15.Iso3166NumericValues; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `companies`"); - dbCmd.CommandText = V14.CompaniesForeignKeys; + dbCmd.CommandText = V15.CompaniesForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `machines`"); - dbCmd.CommandText = V14.MachinesForeignKeys; + dbCmd.CommandText = V15.MachinesForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `company_logos`"); - dbCmd.CommandText = V14.CompanyLogos; + dbCmd.CommandText = V15.CompanyLogos; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `company_descriptions`"); - dbCmd.CommandText = V14.CompanyDescriptions; + dbCmd.CommandText = V15.CompanyDescriptions; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Creating table `processors_by_machine`"); + dbCmd.CommandText = V15.ProcessorsByMachine; dbCmd.ExecuteNonQuery(); return true; diff --git a/Cicm.Database/Operations/Machine.cs b/Cicm.Database/Operations/Machine.cs index 01833661..6f0a200c 100644 --- a/Cicm.Database/Operations/Machine.cs +++ b/Cicm.Database/Operations/Machine.cs @@ -86,11 +86,11 @@ namespace Cicm.Database try { - const string SQL = "SELECT * from machines WHERE company = '{id}'"; + string sql = $"SELECT * from machines WHERE company = '{company}'"; IDbCommand dbCmd = dbCon.CreateCommand(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = SQL; + dbCmd.CommandText = sql; DataSet dataSet = new DataSet(); dataAdapter.SelectCommand = dbCmd; dataAdapter.Fill(dataSet); @@ -214,8 +214,10 @@ namespace Cicm.Database dbcmd.Transaction = trans; const string SQL = - "INSERT INTO machines (company, year, model, cpu1, mhz1, cpu2, mhz2, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, type)" + - " VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @type)"; + "INSERT INTO machines (company, year, model, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, " + + "sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, type)" + + " VALUES (@company, @year, @model, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, " + + "@sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @type)"; dbcmd.CommandText = SQL; @@ -248,9 +250,11 @@ namespace Cicm.Database dbcmd.Transaction = trans; string sql = - "UPDATE machines SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " + - "mhz2 = @mhz2, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, music_synth = @music_synth " + - "sound_channels = @sound_channels, music_channels = @music_channels, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, type = @type " + + "UPDATE machines SET company = @company, year = @year, model = @model, ram = @ram, rom = @rom, " + + "gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, " + + "music_synth = @music_synth, sound_channels = @sound_channels, music_channels = @music_channels, " + + "hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, " + + "type = @type " + $"WHERE id = {entry.Id}"; dbcmd.CommandText = sql; @@ -313,88 +317,72 @@ namespace Cicm.Database IDbDataParameter param19 = dbcmd.CreateParameter(); IDbDataParameter param20 = dbcmd.CreateParameter(); IDbDataParameter param21 = dbcmd.CreateParameter(); - IDbDataParameter param22 = dbcmd.CreateParameter(); - IDbDataParameter param23 = dbcmd.CreateParameter(); - IDbDataParameter param24 = dbcmd.CreateParameter(); - IDbDataParameter param25 = dbcmd.CreateParameter(); param1.ParameterName = "@company"; param2.ParameterName = "@year"; param3.ParameterName = "@model"; - param4.ParameterName = "@cpu1"; - param5.ParameterName = "@mhz1"; - param6.ParameterName = "@cpu2"; - param7.ParameterName = "@mhz2"; - param8.ParameterName = "@ram"; - param9.ParameterName = "@rom"; - param10.ParameterName = "@gpu"; - param11.ParameterName = "@vram"; - param12.ParameterName = "@colors"; - param13.ParameterName = "@res"; - param14.ParameterName = "@sound_synth"; - param15.ParameterName = "@music_synth"; - param16.ParameterName = "@sound_channels"; - param17.ParameterName = "@music_channels"; - param18.ParameterName = "@hdd1"; - param19.ParameterName = "@hdd2"; - param20.ParameterName = "@hdd3"; - param21.ParameterName = "@disk1"; - param22.ParameterName = "@cap1"; - param23.ParameterName = "@disk2"; - param24.ParameterName = "@cap2"; - param25.ParameterName = "@type"; + param4.ParameterName = "@ram"; + param5.ParameterName = "@rom"; + param6.ParameterName = "@gpu"; + param7.ParameterName = "@vram"; + param8.ParameterName = "@colors"; + param9.ParameterName = "@res"; + param10.ParameterName = "@sound_synth"; + param11.ParameterName = "@music_synth"; + param12.ParameterName = "@sound_channels"; + param13.ParameterName = "@music_channels"; + param14.ParameterName = "@hdd1"; + param15.ParameterName = "@hdd2"; + param16.ParameterName = "@hdd3"; + param17.ParameterName = "@disk1"; + param17.ParameterName = "@cap1"; + param19.ParameterName = "@disk2"; + param20.ParameterName = "@cap2"; + param21.ParameterName = "@type"; param1.DbType = DbType.Int32; param2.DbType = DbType.Int32; param3.DbType = DbType.String; param4.DbType = DbType.Int32; - param5.DbType = DbType.Double; + param5.DbType = DbType.Int32; param6.DbType = DbType.Int32; - param7.DbType = DbType.Double; + param7.DbType = DbType.Int32; param8.DbType = DbType.Int32; - param9.DbType = DbType.Int32; + param9.DbType = DbType.String; param10.DbType = DbType.Int32; param11.DbType = DbType.Int32; param12.DbType = DbType.Int32; - param13.DbType = DbType.String; + param13.DbType = DbType.Int32; param14.DbType = DbType.Int32; param15.DbType = DbType.Int32; param16.DbType = DbType.Int32; param17.DbType = DbType.Int32; - param18.DbType = DbType.Int32; + param18.DbType = DbType.String; param19.DbType = DbType.Int32; - param20.DbType = DbType.Int32; + param20.DbType = DbType.String; param21.DbType = DbType.Int32; - param22.DbType = DbType.String; - param23.DbType = DbType.Int32; - param24.DbType = DbType.String; - param25.DbType = DbType.Int32; param1.Value = entry.Company; param2.Value = entry.Year; param3.Value = entry.Model; - param4.Value = entry.Cpu1; - param5.Value = entry.Mhz1; - param6.Value = entry.Cpu2; - param7.Value = entry.Mhz2; - param8.Value = entry.Ram; - param9.Value = entry.Rom; - param10.Value = entry.Gpu; - param11.Value = entry.Vram; - param12.Value = entry.Colors; - param13.Value = entry.Resolution; - param14.Value = entry.SoundSynth; - param15.Value = entry.MusicSynth; - param16.Value = entry.SoundChannels; - param17.Value = entry.MusicChannels; - param18.Value = entry.Hdd1; - param19.Value = entry.Hdd2; - param20.Value = entry.Hdd3; - param21.Value = entry.Disk1; - param22.Value = entry.Cap1; - param23.Value = entry.Disk2; - param24.Value = entry.Cap2; - param25.Value = entry.Type; + param4.Value = entry.Ram; + param5.Value = entry.Rom; + param6.Value = entry.Gpu; + param7.Value = entry.Vram; + param8.Value = entry.Colors; + param9.Value = entry.Resolution; + param10.Value = entry.SoundSynth; + param11.Value = entry.MusicSynth; + param12.Value = entry.SoundChannels; + param13.Value = entry.MusicChannels; + param14.Value = entry.Hdd1; + param15.Value = entry.Hdd2; + param16.Value = entry.Hdd3; + param17.Value = entry.Disk1; + param18.Value = entry.Cap1; + param19.Value = entry.Disk2; + param20.Value = entry.Cap2; + param21.Value = entry.Type; dbcmd.Parameters.Add(param1); dbcmd.Parameters.Add(param2); @@ -417,10 +405,6 @@ namespace Cicm.Database dbcmd.Parameters.Add(param19); dbcmd.Parameters.Add(param20); dbcmd.Parameters.Add(param21); - dbcmd.Parameters.Add(param22); - dbcmd.Parameters.Add(param23); - dbcmd.Parameters.Add(param24); - dbcmd.Parameters.Add(param25); return dbcmd; } @@ -437,10 +421,6 @@ namespace Cicm.Database Company = (int)dataRow["company"], Year = (int)dataRow["year"], Model = (string)dataRow["model"], - Cpu1 = dataRow["cpu1"] == DBNull.Value ? 0 : (int)dataRow["cpu1"], - Mhz1 = dataRow["mhz1"] == DBNull.Value ? 0 : float.Parse(dataRow["mhz1"].ToString()), - Cpu2 = dataRow["cpu2"] == DBNull.Value ? 0 : (int)dataRow["cpu2"], - Mhz2 = dataRow["mhz2"] == DBNull.Value ? 0 : float.Parse(dataRow["mhz2"].ToString()), Ram = (int)dataRow["ram"], Rom = (int)dataRow["rom"], Gpu = dataRow["gpu"] == DBNull.Value ? 0 : (int)dataRow["gpu"], diff --git a/Cicm.Database/Operations/Operations.cs b/Cicm.Database/Operations/Operations.cs index 7077e5f2..0315b0f4 100644 --- a/Cicm.Database/Operations/Operations.cs +++ b/Cicm.Database/Operations/Operations.cs @@ -35,7 +35,7 @@ namespace Cicm.Database public partial class Operations { /// Last known database version - const int DB_VERSION = 14; + const int DB_VERSION = 15; /// The column with this value indicates there is no item of this type. public const int DB_NONE = -1; /// This value indicates there's no GPU, but a direct memory->display connection (a framebuffer). diff --git a/Cicm.Database/Operations/ProcessorByMachine.cs b/Cicm.Database/Operations/ProcessorByMachine.cs new file mode 100644 index 00000000..c1b2c3b7 --- /dev/null +++ b/Cicm.Database/Operations/ProcessorByMachine.cs @@ -0,0 +1,154 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : ProcessorByMachine.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains operations to manage processors. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Data; +using Cicm.Database.Schemas; + +namespace Cicm.Database +{ + public partial class Operations + { + /// + /// Gets all processors in machine + /// + /// All CPUs + /// true if is correct, false otherwise + public bool GetProcessorsByMachines(out List entries, int machineId) + { + #if DEBUG + Console.WriteLine("Getting all processors for machine {0}...", machineId); + #endif + + try + { + string sql = $"SELECT * FROM processors_by_machine WHERE machine = {machineId}"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = ProcessorByMachinesFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting processors by machine."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets all machines with specified processor + /// + /// All CPUs + /// true if is correct, false otherwise + public bool GetMachinesByProcessor(out List entries, int processorId) + { + #if DEBUG + Console.WriteLine("Getting all machines with processor {0}...", processorId); + #endif + + try + { + string sql = $"SELECT * FROM processors_by_machine WHERE processor = {processorId}"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = ProcessorByMachinesFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting machines by processor."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + IDbCommand GetCommandProcessorByMachine(ProcessorByMachine entry) + { + IDbCommand dbcmd = dbCon.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + + param1.ParameterName = "@processor"; + param2.ParameterName = "@machine"; + param3.ParameterName = "@speed"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.Single; + + param1.Value = entry.Processor; + param2.Value = entry.Machine; + param3.Value = entry.Speed <= 0 ? (object)null : entry.Speed; + + dbcmd.Parameters.Add(param1); + + return dbcmd; + } + + static List ProcessorByMachinesFromDataTable(DataTable dataTable) + { + List entries = new List(); + + foreach(DataRow dataRow in dataTable.Rows) + { + ProcessorByMachine entry = new ProcessorByMachine + { + Machine = (int)dataRow["machine"], + Processor = (int)dataRow["processor"], + Speed = dataRow["speed"] == DBNull.Value ? 0 : (float)dataRow["speed"] + }; + + entries.Add(entry); + } + + return entries; + } + } +} \ No newline at end of file diff --git a/Cicm.Database/Operations/Update.cs b/Cicm.Database/Operations/Update.cs index ed9c790f..d04d4c49 100644 --- a/Cicm.Database/Operations/Update.cs +++ b/Cicm.Database/Operations/Update.cs @@ -139,6 +139,11 @@ namespace Cicm.Database UpdateDatabaseToV14(); break; } + case 14: + { + UpdateDatabaseToV15(); + break; + } } OptimizeDatabase(); @@ -1495,13 +1500,17 @@ namespace Cicm.Database param20.DbType = DbType.Int32; param21.DbType = DbType.Int32; - param1.Value = (int)dataRow["company"]; - param2.Value = (int)dataRow["year"]; - param3.Value = (string)dataRow["model"]; - param4.Value = dataRow["cpu1"] == DBNull.Value ? (object)null : (int)dataRow["cpu1"]; - param5.Value = dataRow["mhz1"] == DBNull.Value ? (object)null : float.Parse(dataRow["mhz1"].ToString()); - param6.Value = dataRow["cpu2"] == DBNull.Value ? (object)null : (int)dataRow["cpu2"]; - param7.Value = dataRow["mhz2"] == DBNull.Value ? (object)null : float.Parse(dataRow["mhz2"].ToString()); + param1.Value = (int)dataRow["company"]; + param2.Value = (int)dataRow["year"]; + param3.Value = (string)dataRow["model"]; + param4.Value = dataRow["cpu1"] == DBNull.Value ? (object)null : (int)dataRow["cpu1"]; + param5.Value = dataRow["mhz1"] == DBNull.Value + ? (object)null + : float.Parse(dataRow["mhz1"].ToString()); + param6.Value = dataRow["cpu2"] == DBNull.Value ? (object)null : (int)dataRow["cpu2"]; + param7.Value = dataRow["mhz2"] == DBNull.Value + ? (object)null + : float.Parse(dataRow["mhz2"].ToString()); param8.Value = (int)dataRow["ram"]; param9.Value = (int)dataRow["rom"]; param10.Value = dataRow["gpu"] == DBNull.Value ? (object)null : (int)dataRow["gpu"]; @@ -1571,6 +1580,113 @@ namespace Cicm.Database dbCmd.Dispose(); } + void UpdateDatabaseToV15() + { + Console.WriteLine("Updating database to version 15"); + + Console.WriteLine("Creating table `processors_by_machine`"); + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V15.ProcessorsByMachine; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = dbCon.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + + param1.ParameterName = "@machine"; + param2.ParameterName = "@processor"; + param3.ParameterName = "@speed"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.Double; + + param1.Value = (int)dataRow["id"]; + + const string SQL = + "INSERT INTO processors_by_machine (machine, processor, speed) VALUES (@machine, @processor, @speed)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + dbcmd.Parameters.Add(param3); + + if(dataRow["cpu1"] != DBNull.Value) + { + param2.Value = (int)dataRow["cpu1"]; + param3.Value = dataRow["mhz1"] == DBNull.Value + ? (object)null + : float.Parse(dataRow["mhz1"].ToString()); + + trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding processor {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = SQL; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + if(dataRow["cpu2"] != DBNull.Value) + { + param2.Value = (int)dataRow["cpu2"]; + param3.Value = dataRow["mhz2"] == DBNull.Value + ? (object)null + : float.Parse(dataRow["mhz2"].ToString()); + + trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding processor {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = SQL; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing processor columns from table `machines`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_cpu1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_cpu2`;\n" + + "ALTER TABLE `machines` DROP COLUMN `cpu1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `cpu2`;\n" + + "ALTER TABLE `machines` DROP COLUMN `mhz1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `mhz2`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 15..."); + dbCmd = dbCon.CreateCommand(); + dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('15')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + void OptimizeDatabase() { IDbCommand dbCmd = dbCon.CreateCommand(); diff --git a/Cicm.Database/Schemas/Machine.cs b/Cicm.Database/Schemas/Machine.cs index b9946db0..95b855a8 100644 --- a/Cicm.Database/Schemas/Machine.cs +++ b/Cicm.Database/Schemas/Machine.cs @@ -41,10 +41,6 @@ namespace Cicm.Database.Schemas public int Colors; /// Manufacturer's company ID public int Company; - /// Primary CPU - public int Cpu1; - /// Secondary CPU - public int Cpu2; /// ID of first removable disk format public int Disk1; /// ID of second removable disk format @@ -59,10 +55,6 @@ namespace Cicm.Database.Schemas public int Hdd3; /// ID public int Id; - /// Frequency in MHz of primary CPU - public float Mhz1; - /// Frequency in MHz of secondary CPU - public float Mhz2; /// Model name public string Model; /// Audio channels supported by the MPU diff --git a/Cicm.Database/Schemas/ProcessorByMachine.cs b/Cicm.Database/Schemas/ProcessorByMachine.cs new file mode 100644 index 00000000..817dd934 --- /dev/null +++ b/Cicm.Database/Schemas/ProcessorByMachine.cs @@ -0,0 +1,43 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Computer.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// High level representation of a computer. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +namespace Cicm.Database.Schemas +{ + /// Computer + public class ProcessorByMachine + { + /// Machine ID + public int Machine; + /// Processor ID + public int Processor; + /// Processor speed in MHz + public float Speed; + } +} \ No newline at end of file diff --git a/Cicm.Database/Schemas/Sql/V15.cs b/Cicm.Database/Schemas/Sql/V15.cs new file mode 100644 index 00000000..219fa73f --- /dev/null +++ b/Cicm.Database/Schemas/Sql/V15.cs @@ -0,0 +1,141 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : V15.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains SQL queries to create the database version 7. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +namespace Cicm.Database.Schemas.Sql +{ + public static class V15 + { + public static readonly string Admins = V14.Admins; + + public static readonly string BrowserTests = V14.BrowserTests; + + public static readonly string CicmDb = "CREATE TABLE `cicm_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + ");\n" + + "INSERT INTO cicm_db (version) VALUES ('15');"; + + public static readonly string Companies = V14.Companies; + + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`ram` int(11) NOT NULL DEFAULT '0',;\n" + + "`rom` int(11) NOT NULL DEFAULT '0',;\n" + + "`gpu` int(11) DEFAULT NULL,;\n" + + "`vram` int(11) NOT NULL DEFAULT '0',;\n" + + "`colors` int(11) NOT NULL DEFAULT '0',;\n" + + "`res` char(10) NOT NULL DEFAULT '',;\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_ram` (`ram`),;\n" + + "KEY `idx_machines_rom` (`rom`),;\n" + + "KEY `idx_machines_gpu` (`gpu`),;\n" + + "KEY `idx_machines_vram` (`vram`),;\n" + + "KEY `idx_machines_colors` (`colors`),;\n" + + "KEY `idx_machines_res` (`res`),;\n" + + "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + + "KEY `idx_machines_music_synth` (`music_synth`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; + + public static readonly string DiskFormats = V14.DiskFormats; + + public static readonly string Forbidden = V14.Forbidden; + + public static readonly string Gpus = V14.Gpus; + + public static readonly string Logs = V14.Logs; + + public static readonly string MoneyDonations = V14.MoneyDonations; + + public static readonly string News = V14.News; + + public static readonly string OwnedComputers = V14.OwnedComputers; + + public static readonly string OwnedConsoles = V14.OwnedConsoles; + + public static readonly string Processors = V14.Processors; + + public static readonly string SoundSynths = V14.SoundSynths; + + public static readonly string MachinesForeignKeys = V14.MachinesForeignKeys; + + public static readonly string Iso3166Numeric = V14.Iso3166Numeric; + + public static readonly string Iso3166NumericValues = V14.Iso3166NumericValues; + + public static readonly string CompaniesForeignKeys = V14.CompaniesForeignKeys; + + public static readonly string CompanyLogos = V14.CompanyLogos; + + public static readonly string CompanyDescriptions = V14.CompanyDescriptions; + + public static readonly string InstructionSets = V14.InstructionSets; + + public static readonly string InstructionSetExtensions = V14.InstructionSetExtensions; + + public static readonly string InstructionSetExtensionsByProcessor = V14.InstructionSetExtensionsByProcessor; + + public static readonly string ProcessorsByMachine = + "CREATE TABLE `processors_by_machine` (\n" + + "`processor` INT NOT NULL, \n" + + "`machine` INT NOT NULL,\n" + + "`speed` FLOAT DEFAULT NULL, \n" + + "KEY `idx_processors_by_machine_processor` (`processor`),\n" + + "KEY `idx_processors_by_machine_machine` (`machine`),\n" + + "KEY `idx_processors_by_machine_speed` (`speed`),\n" + + "CONSTRAINT `fk_processors_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + + "CONSTRAINT `fk_processors_by_machine_processor` FOREIGN KEY (`processor`) REFERENCES `processors` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; + } +} \ No newline at end of file diff --git a/cicm_web/Models/Machine.cs b/cicm_web/Models/Machine.cs index 5d7a38ca..ea0455d5 100644 --- a/cicm_web/Models/Machine.cs +++ b/cicm_web/Models/Machine.cs @@ -37,32 +37,29 @@ namespace cicm_web.Models { public class Machine { - public string Cap1; - public string Cap2; - public int Colors; - public Company Company; - public Processor Cpu1; - public Processor Cpu2; - public DiskFormat Disk1; - public DiskFormat Disk2; - public Gpu Gpu; - public DiskFormat Hdd1; - public DiskFormat Hdd2; - public DiskFormat Hdd3; - public int Id; - public float Mhz1; - public float Mhz2; - public string Model; - public int MusicChannels; - public SoundSynth MusicSynth; - public int Ram; - public string Resolution; - public int Rom; - public int SoundChannels; - public SoundSynth SoundSynth; - public MachineType Type; - public int Vram; - public int Year; + public string Cap1; + public string Cap2; + public int Colors; + public Company Company; + public DiskFormat Disk1; + public DiskFormat Disk2; + public Gpu Gpu; + public DiskFormat Hdd1; + public DiskFormat Hdd2; + public DiskFormat Hdd3; + public int Id; + public string Model; + public int MusicChannels; + public SoundSynth MusicSynth; + public ProcessorByMachine[] Processors; + public int Ram; + public string Resolution; + public int Rom; + public int SoundChannels; + public SoundSynth SoundSynth; + public MachineType Type; + public int Vram; + public int Year; public static Machine[] GetAllItems() { @@ -108,7 +105,8 @@ namespace cicm_web.Models Rom = dbItem.Rom, Vram = dbItem.Vram, Year = dbItem.Year, - Type = dbItem.Type + Type = dbItem.Type, + Processors = ProcessorByMachine.GetAllItems(dbItem.Id) }; if(dbItem.Disk1 > 0) @@ -123,18 +121,6 @@ namespace cicm_web.Models item.Disk2 = DiskFormat.GetItem(dbItem.Disk2); } - if(dbItem.Cpu1 > 0) - { - item.Cpu1 = Processor.GetItem(dbItem.Cpu1); - item.Mhz1 = dbItem.Mhz1; - } - - if(dbItem.Cpu2 > 0) - { - item.Cpu2 = Processor.GetItem(dbItem.Cpu2); - item.Mhz2 = dbItem.Mhz2; - } - if(dbItem.MusicSynth > 0) { item.MusicSynth = SoundSynth.GetItem(dbItem.MusicSynth); diff --git a/cicm_web/Models/ProcessorByMachine.cs b/cicm_web/Models/ProcessorByMachine.cs new file mode 100644 index 00000000..a697e9c2 --- /dev/null +++ b/cicm_web/Models/ProcessorByMachine.cs @@ -0,0 +1,59 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : ProcessorByMachine.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Processor by machine model +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +using System.Collections.Generic; + +namespace cicm_web.Models +{ + public class ProcessorByMachine + { + public Processor Processor; + public float Speed; + + public static ProcessorByMachine[] GetAllItems(int machineId) + { + List dbItems = null; + bool? result = + Program.Database?.Operations.GetProcessorsByMachines(out dbItems, machineId); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.ProcessorByMachine dbItem in dbItems) + items.Add(new ProcessorByMachine + { + Processor = Processor.GetItem(dbItem.Processor), + Speed = dbItem.Speed + }); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Views/Machine/View.cshtml b/cicm_web/Views/Machine/View.cshtml index 7490a8c9..817cbae4 100644 --- a/cicm_web/Views/Machine/View.cshtml +++ b/cicm_web/Views/Machine/View.cshtml @@ -87,466 +87,245 @@ } - - -
- Primary processor -
- -@if(Model.Cpu1 != null) -{ - - @if(Model.Mhz1 > 0) { @(Model.Cpu1.GprSize > 0 ? $"{Model.Cpu1.Name} @ {Model.Mhz1}Mhz ({Model.Cpu1.GprSize} bits)" : $"{Model.Cpu1.Name} @ {Model.Mhz1}Mhz") } - else - { @($"{Model.Cpu1.Name}") } - -
-
- - @if(Model.Cpu1.ModelCode != null && Model.Cpu1.ModelCode != Model.Cpu1.Name) - { - - - - - } - - - - - @if(Model.Cpu1.Introduced != DateTime.MinValue) - { - - - - - } - @if(Model.Cpu1.InstructionSet != null) - { - - - - - } - @if(Model.Cpu1.Speed > 0) - { - - - - - } - @if(Model.Cpu1.Gpr > 0 || Model.Cpu1.Fpr > 0 || Model.Cpu1.Simd > 0) - { - - - - - } - @if(Model.Cpu1.Cores > 1) - { - - - - - } - @if(Model.Cpu1.Cores > 1) - { - - - - - } - @if(Model.Cpu1.DataBus > 0 || Model.Cpu1.AddressBus > 0) - { - - - - - } - - @if(Model.Cpu1.L1Instruction > 0 || Model.Cpu1.L1Data > 0 || Model.Cpu1.L2 > 0 || Model.Cpu1.L2 > 0) - { - - - - - } - @if(Model.Cpu1.Package != null) - { - - - - - } - @if(Model.Cpu1.Process != null || Model.Cpu1.ProcessNm > 0) - { - - - - - } - @if(Model.Cpu1.DieSize > 0) - { - - - - - } - @if(Model.Cpu1.Transistors > 0) - { - - - - - } -
Model@Model.Cpu1.ModelCode
Manufacturer - - @Model.Cpu1.Company.Name -
Introduction date@($"{Model.Cpu1.Introduced:yyyy}")
Instruction set@Model.Cpu1.InstructionSet.Name
Nominal speed@Model.Cpu1.Speed MHz
Registers - - @if(Model.Cpu1.Gpr > 0) - { - - - - } - @if(Model.Cpu1.Fpr > 0) - { - - - - } - @if(Model.Cpu1.Simd > 0) - { - - - - } -
- @Model.Cpu1.Gpr general purpose registers of @Model.Cpu1.GprSize bits - @if(Model.Cpu1.FprSize > 0 && Model.Cpu1.Fpr == 0) { @($", that can be used as floating point registers of {Model.Cpu1.FprSize}") } - @if(Model.Cpu1.SimdSize > 0 && Model.Cpu1.Simd == 0) { @($", that can be used as SIMD registers of {Model.Cpu1.FprSize}") } -
- @Model.Cpu1.Fpr floating-point registers of @Model.Cpu1.FprSize bits - @if(Model.Cpu1.SimdSize > 0 && Model.Cpu1.Simd == 0) { @($", that can be used as SIMD registers of {Model.Cpu1.FprSize}") } -
- @Model.Cpu1.Simd SIMDregisters of @Model.Cpu1.SimdSize bits -
-
Multi-core@Model.Cpu1.Cores cores
- SMT - - @Model.Cpu1.ThreadsPerCore threads - @if(Model.Cpu1.Cores > 1) { @(" per core") } -
Bus - - @if(Model.Cpu1.DataBus > 0) - { - - - - } - @if(Model.Cpu1.AddressBus > 0) - { - - - - } -
- @Model.Cpu1.DataBus-bit data -
- @Model.Cpu1.AddressBus-bit address -
-
Cache - - @if(Model.Cpu1.L1Instruction > 0) - { - - - - } - @if(Model.Cpu1.L1Data > 0) - { - - - - } - @if(Model.Cpu1.L2 > 0) - { - - - - } - @if(Model.Cpu1.L3 > 0) - { - - - - } -
- @(Model.Cpu1.L1Data < 0 ? $"{Model.Cpu1.L1Instruction}KiB combined instruction-data L1" : $"{Model.Cpu1.L1Instruction}KiB instruction L1") -
- @($"{Model.Cpu1.L1Data}KiB data L1") -
- @($"{Model.Cpu1.L2}KiB L2") -
- @($"{Model.Cpu1.L3}KiB L3") -
-
Package@Model.Cpu1.Package
Manufacturing process - @if(Model.Cpu1.Process != null && Model.Cpu1.ProcessNm > 0) - { - @Model.Cpu1.Process - @("@") - @(Model.Cpu1.ProcessNm > 100 ? $"{Model.Cpu1.ProcessNm / 100}µm" : $"{Model.Cpu1.ProcessNm}nm") - } - else if(Model.Cpu1.ProcessNm > 0) { @(Model.Cpu1.ProcessNm > 100 ? $"{Model.Cpu1.ProcessNm / 100}µm" : $"{Model.Cpu1.ProcessNm}nm") } - else - { @Model.Cpu1.Process } -
Die size@Model.Cpu1.DieSize mm²
Transistors@Model.Cpu1.Transistors
-
-
- -} -else -{ - Unknown data -} - - -@if(Model.Cpu2 != null) +@if(Model.Processors != null && Model.Processors.Length > 0) {
- Secondary processor + Processors
- @if(Model.Mhz1 > 0) { @(Model.Cpu2.GprSize > 0 ? $"{Model.Cpu2.Name} @ {Model.Mhz1}Mhz ({Model.Cpu2.GprSize} bits)" : $"{Model.Cpu2.Name} @ {Model.Mhz1}Mhz") } - else - { @($"{Model.Cpu2.Name}") } - -
-
- @if(Model.Cpu2.ModelCode != null && Model.Cpu2.ModelCode != Model.Cpu2.Name) + @for(int i = 0; i < Model.Processors.Length; i++) { - - - - - } - - - - - @if(Model.Cpu2.Introduced != DateTime.MinValue) - { - - - - - } - @if(Model.Cpu2.InstructionSet != null) - { - - - - - } - @if(Model.Cpu2.Speed > 0) - { - - - - - } - @if(Model.Cpu2.Gpr > 0 || Model.Cpu2.Fpr > 0 || Model.Cpu2.Simd > 0) - { - - + if(Model.Processors[i] != null) + { + - - } - @if(Model.Cpu2.Cores > 1) - { - - - - - } - @if(Model.Cpu2.Cores > 1) - { - - - - - } - @if(Model.Cpu2.DataBus > 0 || Model.Cpu2.AddressBus > 0) - { - - - - - } + @if(Model.Processors[i].Speed > 0) { @(Model.Processors[i].Processor.GprSize > 0 ? $"{Model.Processors[i].Processor.Name} @ {Model.Processors[i].Speed}Mhz ({Model.Processors[i].Processor.GprSize} bits)" : $"{Model.Processors[i].Processor.Name} @ {Model.Processors[i].Speed}Mhz") } + else + { @($"{Model.Processors[i].Processor.Name}") } + +
+
+
Model@Model.Cpu2.ModelCode
Manufacturer - - @Model.Cpu2.Company.Name -
Introduction date@($"{Model.Cpu2.Introduced:yyyy}")
Instruction set@Model.Cpu2.InstructionSet.Name
Nominal speed@Model.Cpu2.Speed MHz
Registers
- - @if(Model.Cpu2.Gpr > 0) - { - - - - } - @if(Model.Cpu2.Fpr > 0) - { - - - - } - @if(Model.Cpu2.Simd > 0) - { - - - - } -
- @Model.Cpu2.Gpr general purpose registers of @Model.Cpu2.GprSize bits - @if(Model.Cpu2.FprSize > 0 && Model.Cpu2.Fpr == 0) { @($", that can be used as floating point registers of {Model.Cpu2.FprSize}") } - @if(Model.Cpu2.SimdSize > 0 && Model.Cpu2.Simd == 0) { @($", that can be used as SIMD registers of {Model.Cpu2.FprSize}") } -
- @Model.Cpu2.Fpr floating-point registers of @Model.Cpu2.FprSize bits - @if(Model.Cpu2.SimdSize > 0 && Model.Cpu2.Simd == 0) { @($", that can be used as SIMD registers of {Model.Cpu2.FprSize}") } -
- @Model.Cpu2.Simd SIMDregisters of @Model.Cpu2.SimdSize bits -
-
Multi-core@Model.Cpu2.Cores cores
- SMT - - @Model.Cpu2.ThreadsPerCore threads - @if(Model.Cpu2.Cores > 1) { @(" per core") } -
Bus - - @if(Model.Cpu2.DataBus > 0) - { - - - - } - @if(Model.Cpu2.AddressBus > 0) - { - - - - } -
- @Model.Cpu2.DataBus-bit data -
- @Model.Cpu2.AddressBus-bit address -
-
+ @if(Model.Processors[i].Processor.ModelCode != null && Model.Processors[i].Processor.ModelCode != Model.Processors[i].Processor.Name) + { + + + + + } + + + + + @if(Model.Processors[i].Processor.Introduced != DateTime.MinValue) + { + + + + + } + @if(Model.Processors[i].Processor.InstructionSet != null) + { + + + + + } + @if(Model.Processors[i].Processor.Speed > 0) + { + + + + + } + @if(Model.Processors[i].Processor.Gpr > 0 || Model.Processors[i].Processor.Fpr > 0 || Model.Processors[i].Processor.Simd > 0) + { + + + + + } + @if(Model.Processors[i].Processor.Cores > 1) + { + + + + + } + @if(Model.Processors[i].Processor.Cores > 1) + { + + + + + } + @if(Model.Processors[i].Processor.DataBus > 0 || Model.Processors[i].Processor.AddressBus > 0) + { + + + + + } - @if(Model.Cpu2.L1Instruction > 0 || Model.Cpu2.L1Data > 0 || Model.Cpu2.L2 > 0 || Model.Cpu2.L2 > 0) - { - - - + + + + } + @if(Model.Processors[i].Processor.Package != null) + { + + + + + } + @if(Model.Processors[i].Processor.Process != null || Model.Processors[i].Processor.ProcessNm > 0) + { + + + + + } + @if(Model.Processors[i].Processor.DieSize > 0) + { + + + + + } + @if(Model.Processors[i].Processor.Transistors > 0) + { + + + + + } +
Model@Model.Processors[i].Processor.ModelCode
Manufacturer + + @Model.Processors[i].Processor.Company.Name +
Introduction date@($"{Model.Processors[i].Processor.Introduced:yyyy}")
Instruction set@Model.Processors[i].Processor.InstructionSet.Name
Nominal speed@Model.Processors[i].Processor.Speed MHz
Registers + + @if(Model.Processors[i].Processor.Gpr > 0) + { + + + + } + @if(Model.Processors[i].Processor.Fpr > 0) + { + + + + } + @if(Model.Processors[i].Processor.Simd > 0) + { + + + + } +
+ @Model.Processors[i].Processor.Gpr general purpose registers of @Model.Processors[i].Processor.GprSize bits + @if(Model.Processors[i].Processor.FprSize > 0 && Model.Processors[i].Processor.Fpr == 0) { @($", that can be used as floating point registers of {Model.Processors[i].Processor.FprSize}") } + @if(Model.Processors[i].Processor.SimdSize > 0 && Model.Processors[i].Processor.Simd == 0) { @($", that can be used as SIMD registers of {Model.Processors[i].Processor.FprSize}") } +
+ @Model.Processors[i].Processor.Fpr floating-point registers of @Model.Processors[i].Processor.FprSize bits + @if(Model.Processors[i].Processor.SimdSize > 0 && Model.Processors[i].Processor.Simd == 0) { @($", that can be used as SIMD registers of {Model.Processors[i].Processor.FprSize}") } +
+ @Model.Processors[i].Processor.Simd SIMDregisters of @Model.Processors[i].Processor.SimdSize bits +
+
Multi-core@Model.Processors[i].Processor.Cores cores
+ SMT + + @Model.Processors[i].Processor.ThreadsPerCore threads + @if(Model.Processors[i].Processor.Cores > 1) { @(" per core") } +
Bus + + @if(Model.Processors[i].Processor.DataBus > 0) + { + + + + } + @if(Model.Processors[i].Processor.AddressBus > 0) + { + + + + } +
+ @Model.Processors[i].Processor.DataBus-bit data +
+ @Model.Processors[i].Processor.AddressBus-bit address +
+
Cache - - @if(Model.Cpu2.L1Instruction > 0) - { - - - - } - @if(Model.Cpu2.L1Data > 0) - { - - - - } - @if(Model.Cpu2.L2 > 0) - { - - - - } - @if(Model.Cpu2.L3 > 0) - { - - - - } -
- @(Model.Cpu2.L1Data < 0 ? $"{Model.Cpu2.L1Instruction}KiB combined instruction-data L1" : $"{Model.Cpu2.L1Instruction}KiB instruction L1") -
- @($"{Model.Cpu2.L1Data}KiB data L1") -
- @($"{Model.Cpu2.L2}KiB L2") -
- @($"{Model.Cpu2.L3}KiB L3") -
+ @if(Model.Processors[i].Processor.L1Instruction > 0 || Model.Processors[i].Processor.L1Data > 0 || Model.Processors[i].Processor.L2 > 0 || Model.Processors[i].Processor.L2 > 0) + { +
Cache + + @if(Model.Processors[i].Processor.L1Instruction > 0) + { + + + + } + @if(Model.Processors[i].Processor.L1Data > 0) + { + + + + } + @if(Model.Processors[i].Processor.L2 > 0) + { + + + + } + @if(Model.Processors[i].Processor.L3 > 0) + { + + + + } +
+ @(Model.Processors[i].Processor.L1Data < 0 ? $"{Model.Processors[i].Processor.L1Instruction}KiB combined instruction-data L1" : $"{Model.Processors[i].Processor.L1Instruction}KiB instruction L1") +
+ @($"{Model.Processors[i].Processor.L1Data}KiB data L1") +
+ @($"{Model.Processors[i].Processor.L2}KiB L2") +
+ @($"{Model.Processors[i].Processor.L3}KiB L3") +
+
Package@Model.Processors[i].Processor.Package
Manufacturing process + @if(Model.Processors[i].Processor.Process != null && Model.Processors[i].Processor.ProcessNm > 0) + { + @Model.Processors[i].Processor.Process + @("@") + @(Model.Processors[i].Processor.ProcessNm > 100 ? $"{Model.Processors[i].Processor.ProcessNm / 100}µm" : $"{Model.Processors[i].Processor.ProcessNm}nm") + } + else if(Model.Processors[i].Processor.ProcessNm > 0) { @(Model.Processors[i].Processor.ProcessNm > 100 ? $"{Model.Processors[i].Processor.ProcessNm / 100}µm" : $"{Model.Processors[i].Processor.ProcessNm}nm") } + else + { @Model.Processors[i].Processor.Process } +
Die size@Model.Processors[i].Processor.DieSize mm²
Transistors@Model.Processors[i].Processor.Transistors
+
+
- - } - @if(Model.Cpu2.Package != null) - { - - Package - @Model.Cpu2.Package - - } - @if(Model.Cpu2.Process != null || Model.Cpu2.ProcessNm > 0) - { - - Manufacturing process - - @if(Model.Cpu2.Process != null && Model.Cpu2.ProcessNm > 0) - { - @Model.Cpu2.Process - @("@") - @(Model.Cpu2.ProcessNm > 100 ? $"{Model.Cpu2.ProcessNm / 100}µm" : $"{Model.Cpu2.ProcessNm}nm") - } - else if(Model.Cpu2.ProcessNm > 0) { @(Model.Cpu2.ProcessNm > 100 ? $"{Model.Cpu2.ProcessNm / 100}µm" : $"{Model.Cpu2.ProcessNm}nm") } - else - { @Model.Cpu2.Process } - - - } - @if(Model.Cpu2.DieSize > 0) - { - - Die size - @Model.Cpu2.DieSize mm² - - } - @if(Model.Cpu2.Transistors > 0) - { - - Transistors - @Model.Cpu2.Transistors - + + + } } - - } diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 98e4da11..807b6693 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.202 + 3.0.99.206 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website