コード例 #1
0
        public void EdgeTrackingTest()
        {
            var drive = new Drive(Path.Combine(Dir.CarusoTestDirectory, Dir.EdgeTrackingDirectory), Drive.Reason.Read);
            var image = new Bitmap(drive.Files("simple").First());
            var left = EdgeDetector.EdgePoints(image, Direction.FromLeft);

            Assert.IsTrue(left[0] == -1);
            Assert.IsTrue(left[75] == 46);
            Assert.IsTrue(left[363] == 46);
            Assert.IsTrue(left[364] == 6);
            Assert.IsTrue(left[405] == 6);
            Assert.IsTrue(left[406] == 46);
            Assert.IsTrue(left[424] == 46);
            Assert.IsTrue(left[425] == -1);
            Assert.IsTrue(left[499] == -1);

            var right = EdgeDetector.EdgePoints(image, Direction.FromRight);

            Assert.IsTrue(right[0] == -1);
            Assert.IsTrue(right[75] == 154);
            Assert.IsTrue(right[218] == 154);
            Assert.IsTrue(right[219] == 188);
            Assert.IsTrue(right[294] == 188);
            Assert.IsTrue(right[295] == 154);
            Assert.IsTrue(right[424] == 154);
            Assert.IsTrue(right[425] == -1);
            Assert.IsTrue(right[499] == -1);
        }
コード例 #2
0
        public void AspectRatioTest()
        {
            var passFolder = "PicassoUnitTest/PreprocessingTest/AspectRatioTest";
            var failFolder = "PicassoUnitTest/PreprocessingTest/AspectRatioFailTest";

            var passFolderPath = Path.Combine(Drive.GetDriveRoot(), passFolder);
            var failFolderPath = Path.Combine(Drive.GetDriveRoot(), failFolder);

            var passDrive = new Drive(passFolderPath, Drive.Reason.Read);
            var failDrive = new Drive(failFolderPath, Drive.Reason.Read);

            var pass = passDrive.GetAllMatching("image");
            var fail = failDrive.GetAllMatching("image");

            foreach (var image in pass)
            {
                Bitmap mask = new Bitmap(image);
                Assert.IsTrue(Preprocessing.AspectRatioFilter(mask));
            }

            foreach (var image in fail)
            {
                Bitmap mask = new Bitmap(image);
                Assert.IsFalse(Preprocessing.AspectRatioFilter(mask));
            }
        }
コード例 #3
0
 public async Task<DriveFile> UploadFileAsync(Drive drive)
 {
     var token = CancellationTokenSource.Token;
     var bestFile = GetBestFile();
     using (var stream = await bestFile.Drive.ReadFileAsync(bestFile, token))
     {
         var folder = await File.Parent.GetFileAndCreateIfFolderIsNotExistsAsync(drive, token);
         return await drive.UploadFileAsync(stream, File.Name, folder, bestFile.StorageFileId, token);
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: forger/MountFTP
        static void Main(string[] args)
        {
            var drive = new Drive(Configuration.Configure<Options>().CreateAndBind(args));
            drive.FtpCommand += new LogEventHandler(OnFtpCommand);
            drive.FtpServerReply += new LogEventHandler(OnFtpServerReply);
            drive.FtpClientMethodCall += new LogEventHandler(OnFtpClientMethodCall);
            drive.FtpClientDebug += new LogEventHandler(OnFtpClientDebug);

            Console.WriteLine(drive.Mount());
            Console.ReadKey();
        }
コード例 #5
0
ファイル: tests.cs プロジェクト: Algorithmix/Papyrus
 public void TestGetAllMatching()
 {
     const string dir = "TestRecursiveMatching";
     RemoveDirectory(Path.Combine(Drive.GetDriveRoot(), UnitTestFolder, dir));
     var expected = new List<string>();
     BuildNestedDirectory(Path.Combine(Drive.GetDriveRoot(), UnitTestFolder, dir), expected);
     var drive = new Drive(Path.Combine(UnitTestFolder, dir), Drive.Reason.Read);
     var actual = drive.GetAllMatching("image");
     expected.Sort();
     actual.Sort();
     var same = expected.Zip(actual, (first, second) => first == second).All(x => x);
     Assert.IsTrue(same);
 }
コード例 #6
0
		public void PrintDrive (Drive d)
		{
			Console.WriteLine ("Drive:");
			Console.WriteLine ("  ActivationUri:  {0}", d.ActivationUri);
			Console.WriteLine ("  DevicePath:     {0}", d.DevicePath);
			Console.WriteLine ("  DeviceType:     {0}", d.DeviceType);
			Console.WriteLine ("  DisplayName:    {0}", d.DisplayName);
			Console.WriteLine ("  Icon:           {0}", d.Icon);
			Console.WriteLine ("  Id:             {0}", d.Id);
			Console.WriteLine ("  IsConnected:    {0}", d.IsConnected);
			Console.WriteLine ("  IsMounted:      {0}", d.IsMounted);
			Console.WriteLine ("  IsUserVisible:  {0}", d.IsUserVisible);
		}
コード例 #7
0
ファイル: OCRSample.cs プロジェクト: Algorithmix/Papyrus
        public static void run()
        {
            var drive = new Drive(path, Drive.Reason.Read);
            var files = drive.Files("image6");
            var first = files.First();
            var bitmap = new Bitmap(first);
            var image = new Image<Bgra, byte>(bitmap);

            // tesseract.SetVariable("save_best_choices", "True");
            Filter(image);
            var filtered = Filter(image);
            var result = DoOcr(filtered);
        }
コード例 #8
0
 public RunWorkPlan(
     DataSet dataSet,
     Cardinality cardinality,
     IndexType indexType,
     ReservationBufferSize reservationBufferSize,
     CacheSize cacheSize,
     Drive drive,
     CacheType cacheType,
     WorkPlan workPlan)
     : base(dataSet, cardinality, indexType, reservationBufferSize, cacheType, cacheSize)
 {
     Drive = drive;
     WorkPlan = workPlan;
 }
コード例 #9
0
ファイル: IOCheck.cs プロジェクト: surgicalcoder/Tether
        /// <summary>
        /// Initializes a new instance of the IOCheck class and set up the performance monitors we need
        /// </summary>
        public IOCheck()
        {
            this.drivesToCheck = new List<Drive>();

            var perfCategory = new PerformanceCounterCategory("PhysicalDisk");

            logger.Trace("Getting instance Names");
            // string[] instanceNames = perfCategory.GetInstanceNames();

            var searcher = new ManagementObjectSearcher("root\\cimv2", "SELECT * FROM Win32_PerfFormattedData_PerfDisk_PhysicalDisk");
            var instanceNames = searcher.Get().Cast<ManagementObject>().Select(e => e["Name"].ToString()).ToArray();

            logger.Trace("Instance Names populated");

            foreach (var instance in instanceNames)
            {
                // ignore _Total and other system categories
                if (instance.StartsWith("_", StringComparison.Ordinal))
                {
                    continue;
                }
                logger.Trace("Instance = " + instance);

                var drive = new Drive();

                drive.DriveName = GetDriveNameForMountPoint(instance);

                drive.InstanceName = instance;
                drive.Metrics = new List<DriveMetric>();

                drive.Metrics.Add(new DriveMetric() { MetricName = "rkB/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Read Bytes/sec", instance), Divisor = 1024 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "wkB/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", instance), Divisor = 1024 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "%util", Counter = new PerformanceCounter("PhysicalDisk", "% Disk Time", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "avgqu-sz", Counter = new PerformanceCounter("PhysicalDisk", "Avg. Disk Queue Length", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "r/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Reads/sec", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "w/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Writes/sec", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "svctm", Counter = new PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Transfer", instance), Divisor = 1 });

                // take the first readings
                //foreach (var c in drive.Metrics)
                //{
                //    c.Counter.NextValue();
                //}
                this.drivesToCheck.Add(drive);
            }

            counterThread = new Thread(GetNextCounterValueToIgnore);
            counterThread.Start();
        }
コード例 #10
0
        public void Setup()
        {
            _fileSystem = new MemoryFileSystem().WithDrives("c:", "d:");

            _emptyDrive = _fileSystem.DriveDescribing("d:");
            _nonExistingDrive = _fileSystem.DriveDescribing("e:");
            _nonExistingDirectory = _fileSystem.DirectoryDescribing(@"c:\nonExistingDirectory");

            var populate = new FileSystemBuilder(_fileSystem);
            _emptyDirectory = populate.WithDir(@"c:\emptyDirectory");
            _nonEmptyDirectory = populate.WithDir(@"c:\crowdedDirectory");
            populate.WithDir(@"c:\crowdedDirectory\first");
            populate.WithDir(@"c:\crowdedDirectory\first\first");
            populate.WithDir(@"c:\crowdedDirectory\second");
        }
コード例 #11
0
ファイル: OCRTest.cs プロジェクト: Algorithmix/Papyrus
        public void OcrFullOrientationTest()
        {
            const string docRev = @"Documents\EnergyInfrastructure\Full2";
            const string docReg = @"Documents\IncomeTax_Ingalls\Full1";
            var driveRev = new Drive(docRev, Drive.Reason.Read);
            var driveReg = new Drive(docReg, Drive.Reason.Read);

            var revs = Shred.Factory(driveRev.Files("image").ToList(), true);
            var regs = Shred.Factory(driveReg.Files("image").ToList(), true);

            var resV = revs.Select(shred =>
                {
                    Console.Write(" | Expected:" + Orientation.Reversed);
                    Console.Write(" | Actual: " + (shred.TrueOrienation.ToString()));
                    Console.Write(" | Orientation Confidence: " + shred.OrientationConfidence);
                    if (shred.TrueOrienation == null)
                    {
                        Console.WriteLine(" | Empty? =" + shred.IsEmpty);
                        Console.WriteLine("Correct? Indeterminable");
                        return true;
                    }

                    var passed = (Orientation.Reversed == shred.TrueOrienation || shred.IsEmpty);
                    Console.WriteLine(" | Empty? =" + shred.IsEmpty);
                    Console.WriteLine("Correct? = " + passed);
                    return passed;
                }).ToList();
            var resG = regs.Select(shred =>
                {
                    Console.Write(" | Expected:" + Orientation.Regular);
                    Console.Write(" | Actual: " + (shred.TrueOrienation.ToString()));
                    Console.Write(" | Orientation Confidence: " + shred.OrientationConfidence);
                    if (shred.TrueOrienation == null)
                    {
                        Console.WriteLine(" | Empty? =" + shred.IsEmpty);
                        Console.WriteLine("Correct? Indeterminable");
                        return true;
                    }

                    var passed = Orientation.Regular == shred.TrueOrienation || shred.IsEmpty;
                    Console.WriteLine(" | Empty? =" + shred.IsEmpty);
                    Console.WriteLine("Correct? = " + passed);
                    return passed;
                }).ToList();
            Assert.IsTrue(resV.All(item => item));
            Assert.IsTrue(resG.All(item => item));
        }
コード例 #12
0
        public SmartDrive()
        {
            turnPID = new SWave_PID(Constants.Drive_TurnP, 0, Constants.Drive_TurnD, -0.5, 0.5);
            frontBackPID = new SWave_PID(Constants.Drive_AlignBackP, 0, Constants.Drive_AlignBackD, -0.25, 0.25);
            sidePID = new SWave_PID(Constants.Drive_AlignSideP, 0, Constants.Drive_AlignSideD, -0.5, 0.5);
            drive = new Drive();
            frontBack = new SWave_AnalogueUltrasonic(Constants.ChannelAnalogue_BackUltrasonic, Constants.UltraScaling);
            side = new SWave_AnalogueUltrasonic(Constants.ChannelAnalogue_SideUltrasonic, Constants.UltraScaling);
            gyro = new Gyro(Constants.ChannelAnalogue_Gyro);
            rotateTrigger = new SWave_EdgeTrigger(true, true);
            fieldCentricToggle = new SWave_Toggle();

            DriveSpeeds = new point(0, 0);
            TurnSetpoint = 0; Rotation = 0;
            FieldCentric = true; StrafeBackButton = false; StrafeLeftButton = false; StrafeForwardButton = false; StrafeRightButton = false;
            AlignNoodle = false; AlignLoad = false; AlignOutput = false;
        }
コード例 #13
0
ファイル: CBM1541.cs プロジェクト: RonFields72/C64Emulator
        public CBM1541(C64Interfaces.IFile kernel, IO.SerialPort serial)
        {
            _driveCpu = new CPU.MOS6502(_memory, 0);
            _driveClock.OpFactory = _driveCpu.OpFactory;

            _driveVias = new VIA[2]
            {
                new VIA((ushort)Map.Via1RegistersAddress, (ushort)Map.Via1RegistersSize, _driveCpu.IRQ),
                new VIA((ushort)Map.Via2RegistersAddress, (ushort)Map.Via2RegistersSize, _driveCpu.IRQ)
            };

            _drive = new DiskDrive.Drive(_driveVias[1]);
            _drive.OnDataReady += new DiskDrive.Drive.DateReadyDelegate(drive_OnDataReady);

            _ram = new Memory.RAM((ushort)Map.RamAddress, (ushort)Map.RamSize);
            _rom = new Memory.ROM((ushort)Map.RomAddress, (ushort)Map.RomSize, kernel);

            _rom.Patch(IDLE_TRAP_ADDRES, IDLE_TRAP_OPCODE);
            for (int i = 0; i < PATCH_MAP.Length; i++)
                _rom.Patch(PATCH_MAP[i], NOP_OPCODE);

            _memory.Map(_ram, true);
            _memory.Map(_driveVias[0], true);
            _memory.Map(_driveVias[1], true);
            _memory.Map(_rom, Memory.MemoryMapEntry.AccessType.Read, true);

            _serial = serial;

            _sAtnaConn = new IO.SerialPort.BusLineConnection(_serial.DataLine);
            _sDataConn = new IO.SerialPort.BusLineConnection(_serial.DataLine);
            _sClockConn = new IO.SerialPort.BusLineConnection(_serial.ClockLine);

            _serial.OnAtnLineChanged += new IO.SerialPort.LineChangedDelegate(serial_OnAtnLineChanged);
            _serial.ClockLine.OnLineChanged += new IO.SerialPort.LineChangedDelegate(ClockLine_OnLineChanged);
            _serial.DataLine.OnLineChanged += new IO.SerialPort.LineChangedDelegate(DataLine_OnLineChanged);

            _driveVias[0].PortB.OnPortOut += new IO.IOPort.PortOutDelegate(PortB_OnPortOut);

            _driveCpu.Restart(_driveClock, 0);
            _driveClock.QueueOpsStart(_driveVias[0].CreateOps(), 1);
            _driveClock.QueueOpsStart(_driveVias[1].CreateOps(), 2);
            _driveClock.QueueOpsStart(_drive.CreateOps(), 3);
        }
コード例 #14
0
        public KeyValuePair <bool, string> ReserveSeat(int driveId, int userId)
        {
            Require.ThatIntIsPositive(driveId);
            Require.ThatIntIsPositive(userId);

            Drive drive = this.drives.GetByIdQueryable(driveId)
                          .Include(d => d.DrivesPassengers)
                          .FirstOrDefault();

            if (drive == null)
            {
                return(new KeyValuePair <bool, string>(false, "This drive does not exist."));
            }

            if (!this.usersService.CheckIfUserExists(userId))
            {
                return(new KeyValuePair <bool, string>(false, "This user does not exist."));
            }

            if (drive.DrivesPassengers.Any(x => x.PassengerId == userId))
            {
                return(new KeyValuePair <bool, string>(false, "You already have a reservation for the drive."));
            }

            if (drive.DrivesPassengers.Count == drive.DeclaredSeats)
            {
                return(new KeyValuePair <bool, string>(false, "All seats for the drive are taken."));
            }

            DrivesPassengers pair = new DrivesPassengers()
            {
                DriveId     = driveId,
                PassengerId = userId
            };

            drive.DrivesPassengers.Add(pair);

            this.drives.UpdateAsync(drive);

            return(new KeyValuePair <bool, string>(true, "You made a reservation! Have a safe drive."));
        }
コード例 #15
0
        protected virtual void OnFileChanged()
        {
            // Adds tabs for new drives
            foreach (var f in file.DriveFiles)
            {
                if (toolStrip1.Items.Find(f.Drive.Id, false).SingleOrDefault() != null)
                {
                    continue; // tab already exists
                }
                ToolStripButton item = new ToolStripButton(f.Drive.ShortName, null, toolStrip1_ButtonClick, name: f.Drive.Id);
                item.DisplayStyle = ToolStripItemDisplayStyle.Text;
                item.Margin       = new Padding(1);
                toolStrip1.Items.Add(item);
            }

            // Destroys unused tabs. Selected tab can be deleted. So we need check selected tab.
            // And if selected tab isn't exists, select first tab.
            bool hasSelectedItem = false;

            for (int i = toolStrip1.Items.Count - 1; i >= 0; i--)
            {
                ToolStripButton item = (ToolStripButton)toolStrip1.Items[i];
                if (file.GetDriveFile(item.Name) == null)
                {
                    toolStrip1.Items.RemoveAt(i);
                }
                else
                {
                    if (item.Checked)
                    {
                        hasSelectedItem = true;
                    }
                }
            }
            if (!hasSelectedItem)
            {
                ((ToolStripButton)toolStrip1.Items[0]).Checked = true;
                selectedDrive = File.Account.Drives.FindById(toolStrip1.Items[0].Name);
            }
            OnSelectedDriveChanged();
        }
コード例 #16
0
        public void Setup(ExecutionContext context, string name)
        {
            Context = context;
            Drive.Setup(controller);
            ParseConfigs();

            var blockGroup = Context.Terminal.GetBlockGroupWithName(blockGroupName);

            if (blockGroup == null)
            {
                throw new Exception("Could not find block group with name '" + blockGroupName + "'");
            }

            controllerCache.Clear();
            context.Terminal.GetBlocksOfType(controllerCache);
            if (controllerCache.Count == 0)
            {
                throw new Exception("Ship must have at least one ship controller");
            }
            SelectController();

            gyroCache.Clear();
            blockGroup.GetBlocksOfType(gyroCache);
            if (gyroCache.Count == 0)
            {
                throw new Exception("Ship must have atleast one gyroscope");
            }

            thrustCache.Clear();
            blockGroup.GetBlocksOfType(thrustCache);
            if (thrustCache.Count == 0)
            {
                throw new Exception("Ship must have atleast one thruster");
            }

            Drive.thrustController.Update(controller, thrustCache);

            Drive.gyroController.Update(controller, gyroCache);

            AutoSelectMode();
        }
コード例 #17
0
        public List <string> ProcessDrive([FromBody] KomentarVozacPrenos k)
        {
            Drive             por         = new Drive();
            string            ss1         = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drives.xml");
            string            drv         = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drivers.xml");
            string            adm         = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Admins.xml");
            List <Dispatcher> dispatchers = xml.ReadDispatcher(adm);
            List <Drive>      drives      = xml.ReadDrives(ss1);
            List <Driver>     drivers     = xml.ReadDrivers(drv);

            ClosestDistance cd = new ClosestDistance();

            Driver     driver   = new Driver();
            Dispatcher dispacer = new Dispatcher();

            List <Tuple <Point, string> > proslediListu = new List <Tuple <Point, string> >();


            foreach (Driver d in drivers)
            {
                if (!d.Blocked && !d.Zauzet && (d.Car.CarType == k.voz.CarType))
                {
                    Point poi = new Point();
                    poi.X = Double.Parse(d.Location.X);
                    poi.Y = Double.Parse(d.Location.Y);
                    proslediListu.Add(new Tuple <Point, string>(poi, d.UserName));
                }
            }

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

            if (proslediListu.Any())
            {
                Point ip = new Point();
                ip.X     = Double.Parse(k.voz.Arrival.X);
                ip.Y     = Double.Parse(k.voz.Arrival.Y);
                najblizi = cd.OrderByDistance(proslediListu, ip);
            }

            return(najblizi);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: andrueastman/BatchSample
        /// <summary>
        /// Run the request in the normal fashion.
        /// </summary>
        /// <param name="graphClient"></param>
        /// <returns></returns>
        public static async Task Run0(GraphServiceClient graphClient)
        {
            /* Request version 0 */
            /* Uses the normal way type */
            _globalStopwatch = Stopwatch.StartNew();
            User user = await graphClient.Me.Request().GetAsync();

            Calendar calendar = await graphClient.Me.Calendar.Request().GetAsync();

            Drive drive = await graphClient.Me.Drive.Request().GetAsync();

            Console.WriteLine("Version 0 : Normal async/await fashion");
            Console.WriteLine("Display Name user: "******"Calendar Owner Address: " + calendar.Owner.Address);
            Console.WriteLine("Display Drive Type: " + drive.DriveType);
            _globalStopwatch.Stop();
            var elapsedMs = _globalStopwatch.ElapsedMilliseconds;

            Console.WriteLine($"Elapsed Time {elapsedMs}");
            Console.WriteLine("\r\n\r\n");
        }
コード例 #19
0
 public bool Load()
 {
     try {
         if (!HasLoaded)
         {
             Drive drive = App.Loader.GetDrive(Computer.Name, Name);
             Load(drive);
             if (_isLocalDrive && (LocalDriveLoaded != null))
             {
                 LocalDriveLoaded(this, EventArgs.Empty);
             }
         }
         return(true);
     }
     catch (DirectoryNotFoundException) {
         return(false);
     }
     catch (FileNotFoundException) {
         return(false);
     }
 }
コード例 #20
0
 public EntryAction(string[] FilePaths, Drive Drive, Method method)
 {
     InitializeComponent();
     if (Environment.OSVersion.Version.Build >= 7600)
     {
         Windows7 = true;
     }
     if (Environment.OSVersion.Version.Build >= 6000)
     {
         Aero = true;
     }
     if (Windows7)
     {
         tm = TaskbarManager.Instance;
     }
     this.HandleCreated += new EventHandler(EntryAction_HandleCreated);
     this.FormClosing   += new FormClosingEventHandler(EntryAction_FormClosing);
     mMethod             = method;
     this.Paths          = FilePaths;
     xDrive              = Drive;
 }
コード例 #21
0
ファイル: Driver.cs プロジェクト: dalvx/SpectrumArchiveReader
        public static unsafe IntPtr Open(DataRate dataRate, Drive drive)
        {
            string fileName = drive == Drive.A ? "\\\\.\\fdraw0" : "\\\\.\\fdraw1";
            IntPtr handle   = CreateFile(fileName, EFileAccess.GenericRead | EFileAccess.GenericWrite, 0, IntPtr.Zero, ECreationDisposition.OpenExisting, 0, IntPtr.Zero);

            if ((int)handle == INVALID_HANDLE_VALUE)
            {
                int lastError = Marshal.GetLastWin32Error();
                Log.Error?.Out($"Не удалось открыть драйвер: {lastError} {WinErrors.GetSystemMessage(lastError)} {(lastError == 2 ? $"(Drive {drive}: is not installed)" : "")}");
                return(handle);
            }
            uint dwRet;
            bool r = DeviceIoControl(handle, IOCTL_FD_SET_DATA_RATE, (IntPtr)(&dataRate), sizeof(byte), IntPtr.Zero, 0, out dwRet, IntPtr.Zero);

            if (!r)
            {
                int lastError = Marshal.GetLastWin32Error();
                Log.Error?.Out($"Ошибка при установке DataRate: {lastError} {WinErrors.GetSystemMessage(lastError)}");
            }
            return(handle);
        }
コード例 #22
0
ファイル: CollectInfo.cs プロジェクト: philcoder/rat
        private List <Drive> GetDrivesInstalled()
        {
            List <Drive> drives = new List <Drive>(3);

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo driveInfo in allDrives)
            {
                Drive drive = new Drive();
                drive.Name = driveInfo.Name;

                if (driveInfo.IsReady == true)
                {
                    drive.AvailableSpace = driveInfo.TotalFreeSpace;
                    drive.TotalSpace     = driveInfo.TotalSize;
                }

                drives.Add(drive);
            }

            return(drives);
        }
コード例 #23
0
    public static float FindRealSolutionSmallestT(InterceptDriveAccel drive, Drive targetDrive)
    {
        if (drive == null || targetDrive == null)
        {
            return(float.PositiveInfinity);
        }

        Vector3 rv = targetDrive.rb.velocity - drive.rb.velocity;
        Vector3 rp = targetDrive.rb.position - drive.rb.position;

        double[] coefficients =
        {
            4d * rp.sqrMagnitude,
            8d * Vector3.Dot(rv,                   rp),
            4d * (Vector3.Dot(targetDrive.accelVec,rp) + rv.sqrMagnitude),
            4d * Vector3.Dot(targetDrive.accelVec, rv),
            targetDrive.accelVec.sqrMagnitude - drive.accel * drive.accel
        };

        return(InterceptSolver.FindRealSolutionSmallestT(coefficients));
    }
コード例 #24
0
        /// <summary>
        /// Upload un fichier sur un drive
        /// </summary>
        /// <param name="drive"></param>
        /// <param name="UploadfolderPath"></param>
        /// <param name="UploadfileName"></param>
        /// <param name="SourceFilePath"></param>
        /// <returns></returns>
        public bool Upload(Drive drive, string UploadfolderPath, string UploadfileName, string SourceFilePath, string type)
        {
            bool result = false;

            try
            {
                if (drive == Drive.DP)
                {
                    result = DBB.Upload(UploadfolderPath, UploadfileName, SourceFilePath);
                }
                else
                {
                    result = Google.Upload(UploadfileName, type, SourceFilePath);
                }
            }
            catch (Exception ex)
            {
                //
            }
            return(result);
        }
コード例 #25
0
        /// <summary>
        /// Creer un dossier sur un cloud
        /// </summary>
        /// <param name="drive"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public bool CreateFolder(Drive drive, string path, string nameFolder)
        {
            try
            {
                switch (drive)
                {
                case Drive.DP:
                    DBB.CreateFolder(path);
                    break;

                case Drive.GG:
                    Google.CreateFolder(nameFolder);
                    break;
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #26
0
        public IEnumerable <DriveItem> GetDriveItems(Drive drive)
        {
            IDriveItemChildrenCollectionPage items = null;

            try
            {
                items = graphClient.Drives[drive.Id].Root.Children.Request().GetAsync().Result;
            }
            catch
            {
                log.Error("Could not get items for Drive " + drive.Name);
            }

            if (items != null)
            {
                foreach (var item in items)
                {
                    yield return(item);
                }
            }
        }
コード例 #27
0
ファイル: AIController.cs プロジェクト: PaulSolheim/KodeKarts
    // Start is called before the first frame update
    void Start()
    {
        if (circuit == null)
        {
            circuit = GameObject.FindGameObjectWithTag("circuit").GetComponent <Circuit>();
        }

        ds                    = this.GetComponent <Drive>();
        target                = circuit.waypoints[currentWP].transform.position;
        nextTarget            = circuit.waypoints[currentWP + 1].transform.position;
        totalDistanceToTarget = Vector3.Distance(target, ds.rb.gameObject.transform.position);

        tracker = GameObject.CreatePrimitive(PrimitiveType.Capsule);
        DestroyImmediate(tracker.GetComponent <Collider>());
        tracker.GetComponent <MeshRenderer>().enabled = false;
        tracker.transform.position = ds.rb.gameObject.transform.position;
        tracker.transform.rotation = ds.rb.gameObject.transform.rotation;

        this.GetComponent <Ghost>().enabled = false;
        finishSteer = Random.Range(-1.0f, 1.0f);
    }
コード例 #28
0
 /// <summary>
 /// Set up the Drive instance in the class which can access the user information.
 /// </summary>
 private async Task SetDriveAsync()
 {
     try
     {
         drive = await oneDriveClient?.Drive
                 ?.Request()
                 .GetAsync();
     }
     catch (AggregateException ae)
     {
         ae.Handle((x) =>
         {
             if (x is ServiceException)
             {
                 Debug.WriteLine(x.StackTrace);
                 return(true);
             }
             return(false);
         });
     }
 }
コード例 #29
0
 public EntryAction(Drive xDrive, Method method, string Path)
 {
     InitializeComponent();
     if (Environment.OSVersion.Version.Build >= 7600)
     {
         Windows7 = true;
     }
     if (Environment.OSVersion.Version.Build >= 6000)
     {
         Aero = true;
     }
     if (Windows7)
     {
         tm = TaskbarManager.Instance;
     }
     this.HandleCreated += new EventHandler(EntryAction_HandleCreated);
     this.FormClosing   += new FormClosingEventHandler(EntryAction_FormClosing);
     m           = method;
     OutPath     = Path;
     this.xDrive = xDrive;
 }
コード例 #30
0
        public HttpResponseMessage QuitDrive([FromBody] JToken jToken)
        {
            string id      = jToken.Value <string>("quitId");
            Guid   driveId = Guid.Parse(id);
            Drive  quit    = null;

            quit = DataRepository._driveRepo.RetriveDriveById(driveId);

            if (quit != null)
            {
                quit.State = Enums.Status.Canceled;

                DataRepository._driveRepo.UpdateState(quit);

                return(Request.CreateResponse(HttpStatusCode.OK, quit));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
        }
コード例 #31
0
 public async Task <List <Drive> > GetAllDrives()
 {
     return(await Task.Run(async() =>
     {
         var DrivesList = new List <Drive>();
         DriveInfo[] allDrives = DriveInfo.GetDrives();
         foreach (var drive in allDrives)
         {
             if (drive.IsReady)
             {
                 try
                 {
                     Drive hardDisk = await GetDrive(drive);
                     DrivesList.Add(hardDisk);
                 }
                 catch (Exception ex) { }
             }
         }
         return DrivesList;
     }));
 }
コード例 #32
0
        /// <summary>
        /// Configurates the system for a console application.
        /// </summary>
        public void ConfigurateSystem()
        {
            // Create file system with initial root directory
            // and read any persistent information.
            IDrive drive = new Drive("C");

            drive.Restore();

            // Create all commands and invoker
            var factory        = new CommandFactory(drive);
            var commandInvoker = new CommandInvoker();

            commandInvoker.SetCommands(factory.CommandList);
            IExecuteCommand invoker = commandInvoker;

            // Setup console for input and output
            var console = new ConsoleEx(invoker, drive);

            // Start console
            console.ProcessInput();
        }
コード例 #33
0
        private async Task ScanAsync(string path, bool scanDrive, DriveModel drive, Computer computer)
        {
            string folderName = scanDrive ? path : Path.GetFileName(path);

            await BusyWithAsync("Scanning {0} ...".FormatWith(folderName), Task.Run(() => {
                if (scanDrive)
                {
                    Drive d = App.Scanner.Scan(path);
                    drive.Load(d);
                }
                else
                {
                    Folder parent = drive.GetDrive(path);
                    App.Scanner.ScanUpdate(path, drive);
                    drive.HasLoaded = true;
                    parent.RaiseItemChanges();
                }
                drive.IsChanged = true;
                return(true);
            }));
        }
コード例 #34
0
        void AutoSelectMode()
        {
            if (autoEnableWithDampener)
            {
                Drive.SwitchToMode(controller.DampenersOverride ? "flight" : "shutdown");
            }
            else if (autoEnableWithThruster)
            {
                bool AnyThrusterEnabled = false;
                foreach (var thruster in Drive.thrustController.allThrusters)
                {
                    if (thruster.IsFunctional && thruster.Enabled)
                    {
                        AnyThrusterEnabled = true;
                        break;
                    }
                }

                Drive.SwitchToMode(AnyThrusterEnabled ? "flight" : "shutdown");
            }
        }
コード例 #35
0
        public HttpResponseMessage UnsuccessfulDrive([FromBody] Comment comment)
        {
            comment.Id = Data.NewCommentId();
            comment.CreatedDateTime = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
            comment.Grade           = 0;

            Data.commentData.AddComment(comment);

            Drive commentedDrive = Data.driveData.GetDriveById(comment.Drive.Id);

            commentedDrive.Comment = new Comment
            {
                Id = comment.Id
            };
            commentedDrive.State = Enums.State.Unsuccessful;
            Data.driveData.UnsuccessfulDrive(commentedDrive);

            Drive driveFound = Data.driveData.GetDriveById(commentedDrive.Id);

            driveFound.Comment = comment;
            if (driveFound.Customer.Id != 0)
            {
                Customer customer = Data.customerData.GetCustomerById(driveFound.Customer.Id);
                driveFound.Customer = customer;
            }
            if (driveFound.Dispatcher.Id != 0)
            {
                Dispatcher dispatcher = Data.dispatcherData.GetDispatcherById(driveFound.Dispatcher.Id);
                driveFound.Dispatcher = dispatcher;
            }
            if (driveFound.Driver.Id != 0)
            {
                Driver driver = Data.driverData.GetDriverById(driveFound.Driver.Id);
                driver.Occupied = false;
                Data.driverData.FreeDriver(driver);
                driveFound.Driver = driver;
            }

            return(Request.CreateResponse(HttpStatusCode.Created, driveFound));
        }
コード例 #36
0
ファイル: Car.cs プロジェクト: piekaa/offroad
    void Awake()
    {
        CarHolder.Car = this;
        Drive         = GetComponentInChildren <Drive>();
        Engine        = GetComponentInChildren <Engine>();
        Drive.SetFrontWheel(FrontWheel);
        Drive.SetRearWheel(RearWheel);

        var joints = GetComponentsInChildren <WheelJoint2D>();

        if (joints.Length != 2)
        {
            Debug.Log("Car has wrong number of WheelJoints2D: " + joints.Length);
        }

        foreach (var joint in joints)
        {
            if (joint.connectedBody == FrontWheel.GetComponent <Rigidbody2D>())
            {
                frontWheelJoint = joint;
            }

            if (joint.connectedBody == RearWheel.GetComponent <Rigidbody2D>())
            {
                rearWheelJoint = joint;
            }
        }

        Drive.SetJoints(frontWheelJoint, rearWheelJoint);

        FrontPartRigidbody = FrontPart.GetComponent <Rigidbody2D>();

        colliders = GetComponentsInChildren <Collider2D>();

        FrontWheelCollider = FrontWheel.GetComponent <Collider2D>();
        RearWheelCollider  = RearWheel.GetComponent <Collider2D>();

        FrontWheelSpriteRenderer = FrontWheel.GetComponent <SpriteRenderer>();
        RearWheelSpriteRenderer  = RearWheel.GetComponent <SpriteRenderer>();
    }
コード例 #37
0
        public HttpResponseMessage CreateDrive([FromBody] JObject data)
        {
            Drive newDrive             = new Drive();
            IEnumerable <Drive> drives = Data.driveServices.RetriveAllDrives();

            if (drives == null)
            {
                newDrive.Id = 0;
            }
            else
            {
                if (drives.Count() == 1)
                {
                    newDrive.Id = drives.Count();
                }

                newDrive.Id = drives.Count() + 1;
            }

            newDrive.Address = new Location()
            {
                X       = Double.Parse(data.GetValue("X").ToString()),
                Y       = Double.Parse(data.GetValue("Y").ToString()),
                Address = data.GetValue("Address").ToString()
            };

            newDrive.Destination = new Location();
            newDrive.ApprovedBy  = new Dispatcher();
            newDrive.Comments    = new Comment();
            newDrive.DrivedBy    = new Driver();
            newDrive.Price       = 0;
            string s = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt");

            newDrive.CarType   = (CarTypes)Enum.Parse(typeof(CarTypes), data.GetValue("Type").ToString());
            newDrive.OrderDate = DateTime.ParseExact(s, "dd-MM-yyyy hh:mm tt", CultureInfo.InvariantCulture);
            newDrive.OrderedBy = Data.customerService.RetriveCustomerByUserName(Data.loggedUser.Username);
            newDrive.State     = Enums.Status.Created;
            Data.driveServices.NewDrive(newDrive);
            return(Request.CreateResponse(HttpStatusCode.Created, newDrive));
        }
コード例 #38
0
    // Use this for initialization
    void Start()
    {
        startTime = Time.time;
        PlayerPrefs.SetString(PlayerPrefKeys.LAST_LEVEL, UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
        player = FindObjectOfType <Drive>();
        snaps  = new List <SnapShot>();
        FadeToBlack ftb = FindObjectOfType <FadeToBlack>();

        if (ftb)
        {
            ftb.UnFade();
        }

        if (checkPoints > TagManager.CHECKPOINTS.Length)
        {
            Debug.LogError("You are trying to use more checkpoints than created, please create more checkpoint objects and tags");
        }

        checkpointsCrossed = new bool[checkPoints];
        checkpointObjects  = new GameObject[checkPoints];
        for (int index = 0; index < checkPoints; ++index)
        {
            checkpointsCrossed[index] = false;
            checkpointObjects[index]  = GameObject.FindGameObjectWithTag(TagManager.CHECKPOINTS[index]);
        }

        stars = new GameObject[TagManager.STARS.Length];
        for (int index = 0; index < stars.Length; ++index)
        {
            stars[index] = GameObject.FindGameObjectWithTag(TagManager.STARS[index]);
        }

        GameObject[] mushHaveInViewObjects = new GameObject[mustHaveInViewCheckpoints];
        for (int index = 0; index < mustHaveInViewCheckpoints; ++index)
        {
            mushHaveInViewObjects[index] = checkpointObjects[index];
        }

        cameraControl.mustHaveInView = mushHaveInViewObjects;
    }
コード例 #39
0
        static void Main(string[] args)
        {
            string clientId     = "e0cefc2xxxxxxxxxxxx1063112";
            string clientSecret = @"1kQxxxxxxxxxxxxxm05-qZ";
            string tenantID     = "8a400dxxxxxxxxxxxxxxxxc6872cfeef";

            var host = "abc.sharepoint.com";

            IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                                                                           .Create(clientId)
                                                                           .WithTenantId(tenantID)
                                                                           .WithClientSecret(clientSecret)
                                                                           .Build();

            ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
            GraphServiceClient       graphClient  = new GraphServiceClient(authProvider);

            var siteid = graphClient.Sites[host].Request().GetAsync().Result.Id;

            Console.WriteLine(siteid);

            ISiteDrivesCollectionPage drives = graphClient.Sites[host].Drives.Request().GetAsync().Result;

            Drive     driveIT  = drives.CurrentPage.Where(d => d.DriveType == "documentLibrary" && d.Name == "IT").FirstOrDefault();
            DriveItem testfile = graphClient.Sites[host].Drives[driveIT.Id].Root.ItemWithPath("test.txt").Request().GetAsync().Result;

            // this cause the error
            Stream streamtest = graphClient.Sites[siteid]
                                .Drives[driveIT.Id].Root.ItemWithPath("test.txt").Content
                                .Request()
                                .GetAsync().Result;

            StreamReader sr = new StreamReader(streamtest);

            Console.WriteLine(sr.ReadToEnd());



            Console.ReadKey();
        }
コード例 #40
0
        public bool AddDriveCustomer([FromBody] DriveR k)
        {
            string ss  = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Users.xml");
            string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Drives.xml");

            List <Customer> users  = xml.ReadUsers(ss);
            List <Drive>    drives = xml.ReadDrives(ss1);

            User  c     = new Customer();
            Drive drive = new Drive();

            foreach (Customer u in users)
            {
                if (u.UserName == k.korisnicko)
                {
                    c = u;
                    Address  a = new Address(k.Street);
                    Location l = new Location(k.XCoord, k.YCoord, a);
                    drive.Customer = (Customer)c;
                    drive.Arrival  = l;
                    if (k.tipAuta != "")
                    {
                        drive.CarType = (Enums.CarType) int.Parse(k.tipAuta);
                    }
                    drive.Amount      = 0;
                    drive.Comment     = new Comment();
                    drive.DataAndTime = String.Format("{0:F}", DateTime.Now);
                    drive.Destination = new Location();
                    drive.Dispatcher  = new Dispatcher();
                    drive.Driver      = new Driver();
                    drive.Status      = Enums.DriveStatus.Created_Waiting;
                }
            }

            drives.Add(drive);
            xml.WriteDrives(drives, ss1);

            return(true);
        }
コード例 #41
0
        public static IPrimitive Create(PrimitiveTypes primitiveType)
        {
            IPrimitive p;

            switch (primitiveType)
            {
            case PrimitiveTypes.Blocker: p = new Blocker(); break;

            case PrimitiveTypes.Drive: p = new Drive(); break;

            case PrimitiveTypes.Processor: p = new Processor(); break;

            case PrimitiveTypes.Generator: p = new Generator(); break;

            case PrimitiveTypes.Terminal: p = new Terminal(); break;

            default: p = Prototype.Create(); break;
            }

            Owner.Instance.AddObject(p);
            return(p);
        }
コード例 #42
0
        public void StartGame()
        {
            int tempIndex = -1;

            RaceCondition?.Invoke("Race has been started!");
            while (!IsFinished)
            {
                ShowCarsCondition();
                foreach (var car in _cars)
                {
                    Drive drive = car.Drive;
                    tempIndex = drive();
                    if (tempIndex != -1)
                    {
                        break;
                    }
                }
                Thread.Sleep(1000);
                Console.Clear();
            }
            FinishRace(tempIndex - 1);
        }
コード例 #43
0
        public override void Initialize(object navigationData)
        {
            try
            {
                IsBusy = true;

                var drive = navigationData as Drive;

                _selectedDrive = drive;

                Address     = drive.Address.Address;
                Destination = drive.Destination.Address;
                Price       = drive.Price;
                CarType     = drive.CarType.ToString();
                Date        = drive.Date.ToLongDateString();

                if (drive.DrivedBy != null)
                {
                    Driver = drive.DrivedBy.Name + " " + drive.DrivedBy.Surname;
                }

                if (drive.Comments != null)
                {
                    CommentText = drive.Comments.Description;
                    CommentBy   = drive.Comments.CreatedBy.Name + " " + drive.Comments.CreatedBy.Surname + " - " + drive.Comments.CreatedBy.Role.ToString();
                    CommentDate = drive.Comments.CreatedOn.ToLongDateString();
                }

                _driveId = drive.DriveId;
            }
            catch (Exception ex)
            {
                Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #44
0
ファイル: tests.cs プロジェクト: Algorithmix/Papyrus
        public void TestSaveAndLoad()
        {
            const string saveDirectory = "TestSaving";
            RemoveDirectory(Path.Combine(Drive.GetDriveRoot(), UnitTestFolder, saveDirectory));
            var saveFolder = new Drive(Path.Combine(UnitTestFolder, saveDirectory), Drive.Reason.Save);
            Assert.IsTrue(saveFolder.FileCount() == 0);

            var loadFolder = new Drive(Path.Combine(UnitTestFolder, TestMaterialFolder), Drive.Reason.Read);
            var totalFileCount = loadFolder.FileCount();
            Assert.IsTrue(totalFileCount > 0);

            var bitmaps = new List<Bitmap>(totalFileCount);
            foreach (string filepath in loadFolder.FullFilePaths())
            {
                var bitmap = new Bitmap(filepath);
                bitmaps.Add(bitmap);
            }
            Assert.IsTrue(bitmaps.Count == totalFileCount);

            saveFolder.Save(bitmaps, "unittest");
            Assert.IsTrue(saveFolder.FileCount("unittest") == totalFileCount);
            Assert.IsTrue(saveFolder.FileCount() == totalFileCount);
        }
コード例 #45
0
        /// <summary>
        /// Initializes a new instance of the IOCheck class and set up the performance monitors we need
        /// </summary>
        public IOCheck()
        {
            this.drivesToCheck = new List<Drive>();

            var perfCategory = new PerformanceCounterCategory("PhysicalDisk");
            string[] instanceNames = perfCategory.GetInstanceNames();

            foreach (var instance in instanceNames)
            {
                // ignore _Total and other system categories
                if (instance.StartsWith("_", StringComparison.Ordinal))
                {
                    continue;
                }

                var drive = new Drive();
                drive.DriveName = instance.Split(new char[1] { ' ' }, 2)[1];
                drive.InstanceName = instance;
                drive.Metrics = new List<DriveMetric>();

                drive.Metrics.Add(new DriveMetric() { MetricName = "rkB/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Read Bytes/sec", instance), Divisor = 1024 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "wkB/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", instance), Divisor = 1024 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "%util", Counter = new PerformanceCounter("PhysicalDisk", "% Disk Time", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "avgqu-sz", Counter = new PerformanceCounter("PhysicalDisk", "Avg. Disk Queue Length", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "r/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Reads/sec", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "w/s", Counter = new PerformanceCounter("PhysicalDisk", "Disk Writes/sec", instance), Divisor = 1 });
                drive.Metrics.Add(new DriveMetric() { MetricName = "svctm", Counter = new PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Transfer", instance), Divisor = 1 });

                // take the first readings
                foreach (var c in drive.Metrics)
                {
                    c.Counter.NextValue();
                }

                this.drivesToCheck.Add(drive);
            }
        }
コード例 #46
0
ファイル: DriveStrip.cs プロジェクト: fiftin/oblqo
        protected virtual void OnFileChanged()
        {
            // Adds tabs for new drives
            foreach (var f in file.DriveFiles)
            {
                if (toolStrip1.Items.Find(f.Drive.Id, false).SingleOrDefault() != null)
                {
                    continue; // tab already exists
                }
                ToolStripButton item = new ToolStripButton(f.Drive.ShortName, null, toolStrip1_ButtonClick, name: f.Drive.Id);
                item.DisplayStyle = ToolStripItemDisplayStyle.Text;
                item.Margin = new Padding(1);
                toolStrip1.Items.Add(item);
            }

            // Destroys unused tabs. Selected tab can be deleted. So we need check selected tab. 
            // And if selected tab isn't exists, select first tab.
            bool hasSelectedItem = false;
            for (int i = toolStrip1.Items.Count - 1; i >= 0; i--)
            {
                ToolStripButton item = (ToolStripButton)toolStrip1.Items[i];
                if (file.GetDriveFile(item.Name) == null)
                {
                    toolStrip1.Items.RemoveAt(i);
                }else
                {
                    if (item.Checked)
                    {
                        hasSelectedItem = true;
                    }
                }
            }
            if (!hasSelectedItem)
            {
                ((ToolStripButton)toolStrip1.Items[0]).Checked = true;
                selectedDrive = File.Account.Drives.FindById(toolStrip1.Items[0].Name);
            }
            OnSelectedDriveChanged();
        }
コード例 #47
0
 public GioDriveMetadetaSource (Drive drive)
 {
     Drive = drive;
 }
コード例 #48
0
ファイル: IEC.cs プロジェクト: rosc77/vita64
        byte listen(int device)
        {
            if ((device >= 8) && (device <= 11))
            {
                if ((listener = drive[device - 8]) != null && listener.Ready)
                {
                    listener_active = true;
                    return (byte)C64StatusCode.ST_OK;
                }
            }

            listener_active = false;
            return (byte)C64StatusCode.ST_NOTPRESENT;
        }
コード例 #49
0
ファイル: IEC.cs プロジェクト: rosc77/vita64
        byte talk(int device)
        {
            if ((device >= 8) && (device <= 11))
            {
                if ((talker = drive[device - 8]) != null && talker.Ready)
                {
                    talker_active = true;
                    return (byte)C64StatusCode.ST_OK;
                }
            }

            talker_active = false;
            return (byte)C64StatusCode.ST_NOTPRESENT;
        }
コード例 #50
0
ファイル: DriveStrip.cs プロジェクト: fiftin/oblqo
 /// <summary>
 /// Marks clicked item as checked. Other items marks as unchecked.
 /// </summary>
 private void toolStrip1_ButtonClick(object sender, EventArgs e)
 {
     ToolStripButton item = (ToolStripButton)sender;
     foreach (ToolStripButton x in toolStrip1.Items)
     {
         if (x == item)
         {
             continue;
         }
         x.Checked = false;
     }
     item.Checked = true;
     selectedDrive = File.Account.Drives.FindById(item.Name);
     OnSelectedDriveChanged();
 }
コード例 #51
0
ファイル: DJsIO.cs プロジェクト: VictorOverX/X360
 void driveset(ref Drive xIn, bool BigEndian)
 {
     try
     {
         IsBigEndian = BigEndian;
         xIn.MakeHandle();
         xStream = new FileStream(xIn.Handle, FileAccess.ReadWrite);
         xThisData = DataType.Drive;
         xDrive = xIn;
     }
     catch (Exception x) { xStream = null; throw x; }
 }
コード例 #52
0
        public void TransparencyFilterTest()
        {
            var passFolder = "PicassoUnitTest/PreprocessingTest/TransparencyFilterTest";
            var failFolder = "PicassoUnitTest/PreprocessingTest/TransparencyFilterFailTest";

            var passFolderPath = Path.Combine(Drive.GetDriveRoot(), passFolder);
            var failFolderPath = Path.Combine(Drive.GetDriveRoot(), failFolder);

            var passDrive = new Drive(passFolderPath, Drive.Reason.Read);
            var failDrive = new Drive(failFolderPath, Drive.Reason.Read);

            var pass = passDrive.GetAllMatching("image");
            var fail = failDrive.GetAllMatching("image");

            foreach (var image in pass)
            {
                Bitmap shred = new Bitmap(image);
                Assert.IsTrue(Preprocessing.TransparencyFilter(shred));
            }

            foreach (var image in fail)
            {
                Bitmap shred = new Bitmap(image);
                Assert.IsFalse(Preprocessing.TransparencyFilter(shred));
            }
        }
コード例 #53
0
ファイル: Program.cs プロジェクト: faysaldemir/sharprecorder
        /// <summary>
        /// Sets the recording device to use in this session
        /// </summary>
        public static void setRecordingDrive()
        {
            Program.drive_selector.Logger = Program.logger;
            Program.drive_selector.InitializeDeviceList(false);

            if (Program.drive != null)
            {
                Program.drive.Dispose();
                Program.drive = null;
            }

            if (Program.device != null)
            {
                Program.device.Dispose();
                Program.device = null;
            }

            string dname = (string)Program.drive_selector.SelectedItem;
            Program.device = new Device(Program.logger);
            
            if (!Program.device.Open(dname[0]))
            {
                Program.device = null;
                return;
            }

            Program.drive = new Drive(Program.device);
            DiskOperationError status = Program.drive.Initialize();
            if (status != null)
            {
                Program.drive.Dispose();
                Program.device.Dispose();
                Program.device = null;
                Program.drive = null;
                return;
            }

            SpeedInfo[] speeds;
            if (Program.drive.GetWriteSpeeds(out speeds) == null && speeds.GetLength(0) != 0)
                Program.burn_speed = speeds[0];
            else
                Program.burn_speed = null;
        }
コード例 #54
0
ファイル: ShredTest.cs プロジェクト: Algorithmix/Papyrus
        public void ShredFactoryTest()
        {
            Console.WriteLine("Loading File from TestDrive And From Factory Independently");
            var relativeDirectory = Path.Combine(CarusoTestDirectory, CarusoTestMaterialsFolder);
            var fullDirectory = Path.Combine(Drive.GetDriveRoot(), relativeDirectory);
            var mydrive = new Drive(relativeDirectory, Drive.Reason.Read);
            var shreds = Shred.Factory("image", fullDirectory);
            Assert.IsTrue(shreds.Count == mydrive.FileCount("image"));

            foreach (Shred shred in shreds)
            {
                Assert.IsTrue(File.Exists(shred.Filepath));
            }

            Console.WriteLine("Factory Test Successful");
        }
コード例 #55
0
ファイル: ViewModel.cs プロジェクト: WinerTan/WPFTree
        public ViewModel()
        {
            Drive c_Drive = new Drive("C Drive");
            Drive d_Drive = new Drive("D Drive");

            Entity folder1 = new Entity("Folder1", RandomDay());
            Entity folder2 = new Entity("Folder2", RandomDay());
            Entity folder3 = new Entity("Folder3", RandomDay());
            Entity folder4 = new Entity("Folder4", RandomDay());
            Entity folder5 = new Entity("Folder5", RandomDay());
            Entity folder6 = new Entity("Folder6", RandomDay());

            Entity file1 = new Entity("file 1", RandomDay());
            Entity file2 = new Entity("file 2", RandomDay());
            Entity file3 = new Entity("file 3", RandomDay());
            Entity file4 = new Entity("file 4", RandomDay());
            Entity file5 = new Entity("file 5", RandomDay());
            Entity file6 = new Entity("file 6", RandomDay());
            Entity file7 = new Entity("file 7", RandomDay());
            Entity file8 = new Entity("file 8", RandomDay());

            folder1.Children.Add(file1);
            folder1.Children.Add(file2);
            folder1.Children.Add(file3);

            folder2.Children.Add(file4);
            folder2.Children.Add(file2);
            folder2.Children.Add(file1);

            folder3.Children.Add(file2);
            folder3.Children.Add(file3);
            folder3.Children.Add(file4);

            folder4.Children.Add(file6);
            folder4.Children.Add(file5);
            folder4.Children.Add(file3);

            folder5.Children.Add(file5);

            folder6.Children.Add(file1);
            folder6.Children.Add(file3);

            file3.Children.Add(new Entity("File", DateTime.Now));

            c_Drive.Entities.Add(folder1);
            c_Drive.Entities.Add(folder2);
            c_Drive.Entities.Add(folder3);
            d_Drive.Entities.Add(folder4);
            d_Drive.Entities.Add(folder5);
            d_Drive.Entities.Add(folder6);

            Computer com1 = new Computer("Com1");
            Computer com2 = new Computer("Com2");

            com1.Drives.Add(c_Drive);
            com1.Drives.Add(d_Drive);

            com2.Drives.Add(c_Drive);
            com2.Drives.Add(d_Drive);

            Computers.Add(com1);
            Computers.Add(com2);
        }
コード例 #56
0
ファイル: Xbox.cs プロジェクト: nolenfelten/Blam_BSP
        /// <summary>
        /// Dont use this, higher-level methods are available.  Use GetDriveFreeSpace or GetDriveSize instead.
        /// </summary>
        /// <param name="drive"></param>
        /// <param name="freeBytes"></param>
        /// <param name="driveSize"></param>
        /// <param name="totalFreeBytes"></param>
        private void GetDriveInformation(Drive drive, out ulong freeBytes, out ulong driveSize, out ulong totalFreeBytes)
        {
            freeBytes = 0; driveSize = 0; totalFreeBytes = 0;
            SendCommand("drivefreespace name=\"{0}\"", drive.ToString() + ":\\");

            string msg = ReceiveMultilineResponse();
            freeBytes = Convert.ToUInt64(msg.Substring(msg.IndexOf("freetocallerlo") + 17, 8), 16);
            freeBytes |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("freetocallerhi") + 17, 8), 16) << 32);

            driveSize = Convert.ToUInt64(msg.Substring(msg.IndexOf("totalbyteslo") + 15, 8), 16);
            driveSize |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("totalbyteshi") + 15, 8), 16) << 32);

            totalFreeBytes = Convert.ToUInt64(msg.Substring(msg.IndexOf("totalfreebyteslo") + 19, 8), 16);
            totalFreeBytes |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("totalfreebyteshi") + 19, 8), 16) << 32);
        }
コード例 #57
0
ファイル: Xbox.cs プロジェクト: nolenfelten/Blam_BSP
        /// <summary>
        /// Unmounts the specified drive.
        /// </summary>
        /// <param name="drive">Drive letter.</param>
        public void UnMountDevice(Drive drive)
        {
            string driveName = "\\??\\" + drive.ToString() + ":";

            // send unmounting info to xbox
            SetMemory(scratchBuffer, (ushort)driveName.Length, (ushort)(driveName.Length + 1),
                (uint)(scratchBuffer + 8), driveName);

            // attempt to unmount device
            uint error = CallAddressEx(Kernel.IoDeleteSymbolicLink, null, true, scratchBuffer);
            if (error != 0) throw new ApiException("Failed to unmount the device");
        }
コード例 #58
0
ファイル: Xbox.cs プロジェクト: nolenfelten/Blam_BSP
        /// <summary>
        /// Mounts the specified device to the specified drive letter.
        /// </summary>
        /// <param name="device">Device name</param>
        /// <param name="drive">Drive letter</param>
        public void MountDevice(Device device, Drive drive)
        {
            string driveName = "\\??\\" + drive.ToString() + ":";
            string deviceName = string.Empty;
            switch (device)
            {
                case Device.CDRom: deviceName = "\\Device\\CdRom0"; break;
                case Device.DriveC: deviceName = "\\Device\\Harddisk0\\Partition2"; break;
                case Device.DriveE: deviceName = "\\Device\\Harddisk0\\Partition1"; break;
                case Device.DriveF: deviceName = "\\Device\\Harddisk0\\Partition6"; break;
                //case Device.DriveG: deviceName = "\\Device\\Harddisk0\\Partition7"; break;    // seems to be disabled in debug bios
                //case Device.DriveH: deviceName = "\\Device\\Harddisk0\\Partition8"; break;    // seems to be disabled in debug bios
                case Device.DriveX: deviceName = "\\Device\\Harddisk0\\Partition3"; break;
                case Device.DriveY: deviceName = "\\Device\\Harddisk0\\Partition4"; break;
                case Device.DriveZ: deviceName = "\\Device\\Harddisk0\\Partition5"; break;
            }

            // send mounting info to xbox
            SetMemory(scratchBuffer, (ushort)driveName.Length, (ushort)(driveName.Length + 1),
                (uint)(scratchBuffer + 16), (ushort)deviceName.Length, (ushort)(deviceName.Length + 1),
                (uint)(scratchBuffer + 16 + driveName.Length + 1), driveName, deviceName);

            // attempt to mount device
            uint error = CallAddressEx(Kernel.IoCreateSymbolicLink, null, true, scratchBuffer, scratchBuffer + 8);
            if (error != 0) throw new ApiException("Failed to mount the device");
        }
コード例 #59
0
ファイル: Xbox.cs プロジェクト: nolenfelten/Blam_BSP
 /// <summary>
 /// Retrieves xbox drive size.
 /// </summary>
 /// <param name="drive">Drive name.</param>
 /// <returns>Total space available.</returns>
 public ulong GetDriveSize(Drive drive)
 {
     ulong FreeBytes = 0, DriveSize = 0, TotalFreeBytes = 0;
     GetDriveInformation(drive, out FreeBytes, out DriveSize, out TotalFreeBytes);
     return DriveSize;
 }
コード例 #60
-2
    protected virtual void Awake()
    {
        m_hForward = false;
        m_hBackward = false;
        m_hRight = false;
        m_hLeft = false;

        m_hWheels = new List<Wheel>();
        m_hRigidbody = this.GetComponent<Rigidbody>();
        m_hRigidbody.interpolation = RigidbodyInterpolation.None;
        //Initialize effective wheels
        List<Transform> gfxPos = this.GetComponentsInChildren<Transform>().Where(hT => hT.GetComponent<WheelCollider>() == null).ToList();
        this.GetComponentsInChildren<WheelCollider>().ToList().ForEach(hW => m_hWheels.Add(new Wheel(hW, gfxPos.OrderBy(hP => Vector3.Distance(hP.position, hW.transform.position)).First().gameObject)));
        m_hWheels = m_hWheels.OrderByDescending(hW => hW.Collider.transform.localPosition.z).ToList();

        //Initialize extra wheels
        m_hFakeWheels = GetComponentsInChildren<FakeWheel>().ToList();

        //Initialize VehicleTurret
        m_hTurret = GetComponentInChildren<VehicleTurret>();

        //Initialize IWeapon
        m_hCurrentWeapon = GetComponentInChildren<IWeapon>();

        m_hActor = GetComponent<Actor>();

        //Initialize Drive/Brake System
        switch (DriveType)
        {
            case DriveType.AWD:
                m_hEngine = new AwdDrive(Hp, m_hWheels);
                break;
            case DriveType.RWD:
                m_hEngine = new RearDrive(Hp, m_hWheels);
                break;
            case DriveType.FWD:
                m_hEngine = new ForwardDrive(Hp, m_hWheels);
                break;
            default:
                break;
        }


        m_hConstanForce = this.GetComponent<ConstantForce>();
        m_hReverseCOM = new Vector3(0.0f, -2.0f, 0.0f);

        m_hOriginalCOM = m_hRigidbody.centerOfMass;


        GroundState hGroundState = new GroundState(this);
        FlyState hFlyState = new FlyState(this);
        TurnedState hTurned = new TurnedState(this, m_hReverseCOM);

        hGroundState.Next = hFlyState;
        hFlyState.Grounded = hGroundState;
        hFlyState.Turned = hTurned;
        hTurned.Next = hFlyState;
        m_hFlyState = hFlyState;
    }