コード例 #1
0
        public static void Main()
        {
            MikeLab.PhysicalMassMemory.PhysicalDrive.Init();

            while (PhysicalDrive.ReadyRead != true)
            {
                Thread.Sleep(222);
            }

            string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
            string configuration = rootDirectory + @"\neuralnet.conf";

            Debug.Print("Read Bytes from SD Card: " + PhysicalDrive.ReadFileOnSDCardAsString(configuration, out configuration).ToString());

            var jdom = (JObject)JsonHelpers.Parse(configuration);

            NeuralNetwork neuralnet = new NeuralNetwork(jdom);

            neuralnet.Inputs(new double[] { 0.0, 0.0 });
            Debug.Print("Value for 0 0 is " + neuralnet.NeuronValue[0].ToString());

            neuralnet.Inputs(new double[] { 1.0, 0.0 });
            Debug.Print("Value for 1 0 is " + neuralnet.NeuronValue[0].ToString());

            neuralnet.Inputs(new double[] { 0.0, 1.0 });
            Debug.Print("Value for 0 1 is " + neuralnet.NeuronValue[0].ToString());

            neuralnet.Inputs(new double[] { 1.0, 1.0 });
            Debug.Print("Value for 1 1 is " + neuralnet.NeuronValue[0].ToString());
        }
コード例 #2
0
ファイル: PageDevice.cs プロジェクト: t00/TestCrypt
        /// <summary>
        /// Refresh the disk selection by (re-)enumerating the available devices of the system.
        /// </summary>
        private void RefreshPage()
        {
            // store the currently selected device (if any)
            Device selectedDevice = SelectedDevice;

            // clear the devices already enumerated in the list-view
            lsvDevices.Items.Clear();

            // enumerating the devices can take quite a time if a harddisk has to spin up: use progress dialog
            FormProgress dlg = new FormProgress();

            dlg.DoWork += backgroundWorker_DoWork;
            dlg.ShowDialog(this);

            // the devices have been enumerated
            foreach (PhysicalDrive.DriveInfo drive in drives)
            {
                ListViewItem item = new ListViewItem(string.Format("{0} {1}:", PageContext.GetInstance().GetResourceString("Disk"), drive.DriveNumber));
                item.Font = new Font(item.Font, FontStyle.Bold);
                item.Tag  = new Device(drive);
                item.SubItems.Add("");
                item.SubItems.Add(PhysicalDrive.GetAsBestFitSizeUnit(drive.Size));
                item.SubItems.Add("");
                lsvDevices.Items.Add(item);



                foreach (PhysicalDrive.PARTITION_INFORMATION_EX partition in drive.Partitions)
                {
                    PhysicalDrive.VolumeInfo volumeInfo = null;
                    foreach (PhysicalDrive.VolumeInfo volume in volumes)
                    {
                        if ((volume.DeviceInfo.DeviceNumber == drive.DriveNumber) && (volume.DeviceInfo.PartitionNumber == partition.PartitionNumber))
                        {
                            volumeInfo = volume;
                            break;
                        }
                    }
                    item     = new ListViewItem(string.Format(@"\Device\Harddisk{0}\Partition{1}", drive.DriveNumber, partition.PartitionNumber));
                    item.Tag = new Device(drive, partition.PartitionNumber);
                    item.SubItems.Add((volumeInfo != null) ? volumeInfo.RootPath : string.Empty);
                    item.SubItems.Add(PhysicalDrive.GetAsBestFitSizeUnit(partition.PartitionLength));
                    item.SubItems.Add((volumeInfo != null) ? volumeInfo.Label : string.Empty);
                    lsvDevices.Items.Add(item);

                    // re-select the previously selected device if it still exists
                    if ((selectedDevice != null) && selectedDevice.Partition.HasValue &&
                        (drive.DriveNumber == selectedDevice.Drive.DriveNumber) && (partition.PartitionNumber == selectedDevice.Partition.Value))
                    {
                        item.Focused  = true;
                        item.Selected = true;
                    }
                }
            }

            // the ready state of the wizard page might have changed
            lsvPhysicalDrives_SelectedIndexChanged(this, new EventArgs());
        }
コード例 #3
0
ファイル: PageDisk.cs プロジェクト: t00/TestCrypt
        /// <summary>
        /// Refresh the disk selection by (re-)enumerating the available disks of the system.
        /// </summary>
        private void RefreshPage()
        {
            // store the currently selected physical drive (if any)
            Device selectedDisk = SelectedDisk;

            // clear the physical drives already enumerated in the list-view
            lsvPhysicalDrives.Items.Clear();

            // enumerating the physical drives can take quite a time if a harddisk has to spin up: use progress dialog
            FormProgress dlg = new FormProgress();

            dlg.DoWork += backgroundWorker_DoWork;
            dlg.ShowDialog(this);

            // the physical drives have been enumerated
            foreach (PhysicalDrive.DriveInfo drive in drives)
            {
                ListViewItem item = new ListViewItem(string.Format("{0} {1}", PageContext.GetInstance().GetResourceString("Disk"), drive.DriveNumber));
                item.Tag = new Device(drive);

                string type;
                switch (drive.PartitionStyle)
                {
                case PhysicalDrive.PARTITION_STYLE.PARTITION_STYLE_MBR:
                    type = "MBR";
                    break;

                case PhysicalDrive.PARTITION_STYLE.PARTITION_STYLE_GPT:
                    type = "GPT";
                    break;

                default:
                    type = "RAW";
                    break;
                }
                item.SubItems.Add(type);
                item.SubItems.Add(PhysicalDrive.GetAsBestFitSizeUnit(drive.Size));
                item.SubItems.Add((drive.Size / drive.Geometry.BytesPerSector).ToString());
                item.SubItems.Add(string.Format("{0}/{1}/{2}", drive.Geometry.Cylinders, drive.Geometry.TracksPerCylinder, drive.Geometry.SectorsPerTrack));
                lsvPhysicalDrives.Items.Add(item);

                // re-select the previously selected physical drive if it still exists
                if ((selectedDisk != null) && (drive.DriveNumber == selectedDisk.Drive.DriveNumber))
                {
                    item.Focused  = true;
                    item.Selected = true;
                }
            }

            // the ready state of the wizard page might have changed
            lsvPhysicalDrives_SelectedIndexChanged(this, new EventArgs());
        }
コード例 #4
0
 /// <summary>
 /// Gets a string representing the volume boundaries for an embedded backup volume header.
 /// </summary>
 /// <param name="drive">The information about the drive containing the volume.</param>
 /// <returns>A string representing the volume boundaries for an embedded backup volume header.</returns>
 public string ToBackupHeaderString(PhysicalDrive.DriveInfo drive)
 {
     if (IsPossibleBackupHeader(drive.Size))
     {
         long startSector = backupStart / drive.Geometry.BytesPerSector;
         long endSector   = (backupEnd - 1) / drive.Geometry.BytesPerSector;
         PhysicalDrive.CylinderHeadSector chsStartOffset = PhysicalDrive.LbaToChs(startSector, drive.Geometry);
         PhysicalDrive.CylinderHeadSector chsEndOffset   = PhysicalDrive.LbaToChs(endSector, drive.Geometry);
         return(string.Format("{0} - {1}", chsStartOffset, chsEndOffset));
     }
     else
     {
         return("n/a");
     }
 }
コード例 #5
0
 /// <summary>
 /// Gets a string representing the volume boundaries for a normal volume header.
 /// </summary>
 /// <param name="drive">The information about the drive containing the volume.</param>
 /// <returns>A string representing the volume boundaries for a normal volume header.</returns>
 public string ToNormalHeaderString(PhysicalDrive.DriveInfo drive)
 {
     if ((normalStart >= 0) && (normalEnd <= drive.Size))
     {
         long startSector = normalStart / drive.Geometry.BytesPerSector;
         long endSector   = (normalEnd - 1) / drive.Geometry.BytesPerSector;
         PhysicalDrive.CylinderHeadSector chsStartOffset = PhysicalDrive.LbaToChs(startSector, drive.Geometry);
         PhysicalDrive.CylinderHeadSector chsEndOffset   = PhysicalDrive.LbaToChs(endSector, drive.Geometry);
         if ((header.CryptoInfo.HeaderVersion == 3) && (header.CryptoInfo.hiddenVolume))
         {
             return(string.Format("?/?/? - {0}", chsEndOffset));
         }
         else
         {
             return(string.Format("{0} - {1}", chsStartOffset, chsEndOffset));
         }
     }
     else
     {
         return("n/a");
     }
 }
コード例 #6
0
ファイル: ResultPage.cs プロジェクト: t00/TestCrypt
 /// <summary>
 /// Gets a string representing the volume boundaries for a normal volume header.
 /// </summary>
 /// <param name="drive">The information about the drive containing the volume.</param>
 /// <returns>A string representing the volume boundaries for a normal volume header.</returns>
 public string ToNormalHeaderString(PhysicalDrive.DriveInfo drive)
 {
     if ((normalStart >= 0) && (normalEnd <= drive.Size))
     {
         long startSector = normalStart / drive.Geometry.BytesPerSector;
         long endSector = (normalEnd - 1) / drive.Geometry.BytesPerSector;
         PhysicalDrive.CylinderHeadSector chsStartOffset = PhysicalDrive.LbaToChs(startSector, drive.Geometry);
         PhysicalDrive.CylinderHeadSector chsEndOffset = PhysicalDrive.LbaToChs(endSector, drive.Geometry);
         if ((header.CryptoInfo.HeaderVersion == 3) && (header.CryptoInfo.hiddenVolume))
         {
             return string.Format("?/?/? - {0}", chsEndOffset);
         }
         else
         {
             return string.Format("{0} - {1}", chsStartOffset, chsEndOffset);
         }
     }
     else
     {
         return "n/a";
     }
 }
コード例 #7
0
ファイル: ResultPage.cs プロジェクト: t00/TestCrypt
 /// <summary>
 /// Gets a string representing the volume boundaries for an embedded backup volume header.
 /// </summary>
 /// <param name="drive">The information about the drive containing the volume.</param>
 /// <returns>A string representing the volume boundaries for an embedded backup volume header.</returns>
 public string ToBackupHeaderString(PhysicalDrive.DriveInfo drive)
 {
     if (IsPossibleBackupHeader(drive.Size))
     {
         long startSector = backupStart / drive.Geometry.BytesPerSector;
         long endSector = (backupEnd - 1) / drive.Geometry.BytesPerSector;
         PhysicalDrive.CylinderHeadSector chsStartOffset = PhysicalDrive.LbaToChs(startSector, drive.Geometry);
         PhysicalDrive.CylinderHeadSector chsEndOffset = PhysicalDrive.LbaToChs(endSector, drive.Geometry);
         return string.Format("{0} - {1}", chsStartOffset, chsEndOffset);
     }
     else
     {
         return "n/a";
     }
 }
コード例 #8
0
        String getPhysicalDriveInfo()
        {
            var proc = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = settings.StorcliFilePath,
                    Arguments              = $"\\call \\eall \\sall show all",
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                }
            };
            String output = "";

            proc.Start();
            PhysicalDrive        currentDrive = null;
            List <PhysicalDrive> drives       = new List <PhysicalDrive>();

            string sn_pattern = @"SN\s=\s+([0-9A-Z]+)\s*$";

            while (!proc.StandardOutput.EndOfStream)
            {
                string line = proc.StandardOutput.ReadLine();
                output += line;
                var sn_match = Regex.Match(line, sn_pattern);
                if (line.Contains("Drive /c") && line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries).Length == 3)
                {
                    if (currentDrive != null)
                    {
                        drives.Add(currentDrive);
                    }
                    var driveInfo = (line.Split(' ')[1]).Split('/');

                    int ctrl      = int.Parse(driveInfo[1].Remove(0, 1));
                    int enclosure = int.Parse(driveInfo[2].Remove(0, 1));
                    int slot      = int.Parse(driveInfo[3].Remove(0, 1));
                    currentDrive = new PhysicalDrive(slot, enclosure, ctrl);
                }
                if (currentDrive != null)
                {
                    if (line.Contains($"{currentDrive.EnclosureId}:{currentDrive.Slot}"))
                    {
                        var driveInfo = line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                        //string pattern = @"(\s)Size";
                        //Match match = Regex.Match(line, pattern);
                        //if (match.Success)
                        //{
                        //    currentDrive.Size = line.Substring(match.Index, match.Length).Trim();
                        //}
                        currentDrive.State        = driveInfo[2];
                        currentDrive.DigitalGroup = driveInfo[3];
                        currentDrive.Size         = driveInfo[4] + " " + driveInfo[5];
                        currentDrive.Model        = driveInfo[11];
                    }
                    if (line.Contains("Media Error Count "))
                    {
                        currentDrive.MediaErrorCount = int.Parse(line.Split(new string[] { "= " }, StringSplitOptions.None)[1]);
                    }
                    else if (line.Contains("Predictive Failure Count "))
                    {
                        currentDrive.PredictiveFailureCount = int.Parse(line.Split(new string[] { "= " }, StringSplitOptions.None)[1]);
                    }
                    else if (sn_match.Success)
                    {
                        currentDrive.SerialNumber = sn_match.Groups[1].Value;
                    }
                    else if (line.Contains("Manufacturer Id"))
                    {
                        currentDrive.ProducerId = line.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)[3];
                    }
                }
            }
            drives.Add(currentDrive);
            Server.PhysicalDrives = drives;
            return(output);
        }