public static IWebDriver GetDriver(string driver, Devices device)
 {
     DeviceModel model = Device.Get(device);
     IWebDriver webDriver;
     switch (driver.ToLower())
     {
         case "safari":
             webDriver = new SafariDriver();
             break;
         case "chrome":
             webDriver = new ChromeDriver();
             break;
         case "ie":
             webDriver = new InternetExplorerDriver();
             break;
         //case "firefox":
         default:
             var profile = new FirefoxProfile();
             profile.SetPreference("general.useragent.override", model.UserAgent);
             webDriver = new FirefoxDriver(profile);
             webDriver.Manage().Window.Size = model.ScreenSize;
             break;
     }
     return webDriver;
 }
Exemple #2
0
 public static System.String Argument(Devices e)
 {
     switch (e) {
         case Devices.Unknown:    return "";
         case Devices.PS:         return "-sDEVICE=pswrite";
         case Devices.EPS:        return "-sDEVICE=epswrite";
         case Devices.PDF:        return "-sDEVICE=pdfwrite";
         case Devices.PDF_Opt:    return ""; // 特殊デバイス
         case Devices.SVG:        return "-sDEVICE=svg";
         case Devices.JPEG:       return "-sDEVICE=jpeg";
         case Devices.JPEG_Gray:  return "-sDEVICE=jpeggray";
         case Devices.PNG:        return "-sDEVICE=png16m";
         case Devices.PNG_16:     return "-sDEVICE=png16";
         case Devices.PNG_256:    return "-sDEVICE=png256";
         case Devices.PNG_Gray:   return "-sDEVICE=pnggray";
         case Devices.PNG_Mono:   return "-sDEVICE=pngmono";
         case Devices.PNG_Alpha:  return "-sDEVICE=pngalpha";;
         case Devices.BMP:        return "-sDEVICE=bmp16m";
         case Devices.BMP_16:     return "-sDEVICE=bmp16";
         case Devices.BMP_256:    return "-sDEVICE=bmp256";
         case Devices.BMP_Gray:   return "-sDEVICE=bmpgray";
         case Devices.BMP_Mono:   return "-sDEVICE=bmpmono";
         case Devices.TIFF:       return "-sDEVICE=tiff24nc";
         case Devices.TIFF_Gray:  return "-sDEVICE=tiffgray";
         case Devices.TIFF_Mono:  return "-sDEVICE=tiffcrle";
         default: throw new ArgumentOutOfRangeException("e");
     }
 }
        public void ShouldNotFindDevicesByTypeWhenNoDevicesAreRegistered(
            Devices devices)
        {
            var foundDevices = devices.FindDevicesByType<Microphone>();

            foundDevices.ShouldBeEmpty();
        }
        public void ShouldNotRegisterAnAlreadyRegisteredDevice(
            Devices devices,
            Microphone newDevice)
        {
            devices.RegisterNewDevice(newDevice);

            devices.RegisterNewDevice(newDevice).ShouldBeFalse();
        }
        public void ShouldNotFindDeviceByIdWhenNoDevicesAreRegistered(
            Devices devices,
             DeviceId anyDeviceId)
        {
            Device notFoundDevice = null;

            devices.FindDeviceById(anyDeviceId, out notFoundDevice).ShouldBeFalse();
            notFoundDevice.ShouldBeNull();
        }
        public PhidgetServoOutputSettings(Devices dev, int neutral_val, PWMMapping pwm_map, PhidgetServoChannel channel)
        {
            if (pwm_map == null)
                throw new ArgumentNullException("pwm_map");

            this.device = dev;
            this.neutral_value = neutral_val;
            this.mapping = pwm_map;
            this.channel = channel;
        }
 public KeyboardKey(String text, Devices.DeviceKeys tag, bool linebreak = false, double fontsize = 12, double margin_left = 7, double margin_top = 0, double width = 30, double height = 30)
 {
     this.visualName = text;
     this.tag = tag;
     this.line_break = linebreak;
     this.width = width;
     this.height = height;
     this.font_size = fontsize;
     this.margin_left = margin_left;
     this.margin_top = margin_top;
 }
        public void ShouldNotFindDeviceByIdWhenDeviceIsNotRegistered(
            Devices devices,
            Microphone aDevice,
            DeviceId anyDeviceId)
        {
            devices.RegisterNewDevice(aDevice);
            Device notFoundDevice = null;

            devices.FindDeviceById(anyDeviceId, out notFoundDevice).ShouldBeFalse();
            notFoundDevice.ShouldBeNull();
        }
        public static Size GetSize(Devices device)
        {
            var attribute = device.GetAttribute<SizeAttribute>();

            if (attribute == null)
            {
                throw new DeviceSizeException(device);
            }

            return attribute.Size;
        }
Exemple #10
0
        /// <summary>
        /// Creates an instance of <see cref="DeviceUserControl"/> class.
        /// </summary>
        /// <param name="device"><see cref="Device"/> to be edited.</param>
        public DeviceUserControl(Device device)
        {
            InitializeComponent();
            Loaded += DeviceUserControl_Loaded;
            Unloaded += DeviceUserControl_Unloaded;

            if ((object)device == null)
                DataContext = new Devices(0, false);
            else
                DataContext = new Devices(0, false, device);
        }
        public void ShouldFindDeviceByIdWhenDeviceIsRegistered(
            Devices devices,
            Microphone aDevice,
            Device anotherDevice)
        {
            devices.RegisterNewDevice(aDevice);
            devices.RegisterNewDevice(anotherDevice);
            Device foundDevice = null;

            devices.FindDeviceById(aDevice.Id, out foundDevice).ShouldBeTrue();

            foundDevice.ShouldBe(aDevice);
        }
        public void ShouldFindDevicesByType(
            Devices devices,
            Microphone aDevice,
            Device anotherDevice)
        {
            devices.RegisterNewDevice(aDevice);
            devices.RegisterNewDevice(anotherDevice);

            var foundDevices = devices.FindDevicesByType<Microphone>();

            foundDevices.ShouldNotBeEmpty();
            foundDevices.ShouldContain(aDevice);
        }
 /// <summary>
 /// The DeviceTransform method returns the transform for a given Devices enum.
 /// </summary>
 /// <param name="device">The Devices enum to get the transform for.</param>
 /// <returns>The transform for the given Devices enum.</returns>
 public static Transform DeviceTransform(Devices device)
 {
     switch (device)
     {
         case Devices.Headset:
             return HeadsetTransform();
         case Devices.Left_Controller:
             return GetControllerLeftHand().transform;
         case Devices.Right_Controller:
             return GetControllerRightHand().transform;
     }
     return null;
 }
        public FormActualizarFirmware(Devices dev)
        {
            InitializeComponent();
            this.device = dev;

            if (me.Idioma == 0)
                TextSpanish();
            else
                TextEnglish();

            buscaCOMs();
            if (dev == Devices.AntTracker || dev == Devices.Uplink)
                comboBoxCOM.Items.Insert(0, "USB");
                CheckIfUSB();

        }
Exemple #15
0
        internal bool Start(Devices device)
        {
            if (Master == IntPtr.Zero || Slaves.Count == 0)
                return false;

            switch (device)
            {
                case Devices.Keyboard:
                    kbHook.Start();
                    LogCallback("Keyboard hook started", RichLogTextBox.OutputMode.Log);
                    break;
                case Devices.Mouse:
                    mHook.Start();
                    LogCallback("Mouse hook started", RichLogTextBox.OutputMode.Log);
                    break;
                case Devices.Both:
                    kbHook.Start();
                    mHook.Start();
                    LogCallback("Keyboard & Mouse hooks started", RichLogTextBox.OutputMode.Log);
                    break;
            }
            return true;
        }
Exemple #16
0
 public static ComputeDevice GetDeviceWithUuid(string uuid)
 {
     return(Devices.FirstOrDefault(dev => uuid == dev.Uuid));
 }
        public async Task CheckpointManagerPurgeCheck([Values] DeviceMode deviceMode)
        {
            ICheckpointManager checkpointManager;

            if (deviceMode == DeviceMode.Local)
            {
                checkpointManager = new DeviceLogCommitCheckpointManager(
                    new LocalStorageNamedDeviceFactory(),
                    new DefaultCheckpointNamingScheme(TestUtils.MethodTestDir +
                                                      "/checkpoints/"), false); // PurgeAll deletes this directory
            }
            else
            {
                TestUtils.IgnoreIfNotRunningAzureTests();
                checkpointManager = new DeviceLogCommitCheckpointManager(
                    new AzureStorageNamedDeviceFactory(TestUtils.AzureEmulatedStorageString),
                    new DefaultCheckpointNamingScheme(
                        $"{TestUtils.AzureTestContainer}/{TestUtils.AzureTestDirectory}"), false);
            }

            var path = TestUtils.MethodTestDir + "/";

            using (var log = Devices.CreateLogDevice(path + "hlog.log", deleteOnClose: true))
            {
                TestUtils.RecreateDirectory(path);

                using var fht = new FasterKV <long, long>
                                    (1 << 10,
                                    logSettings: new LogSettings
                        {
                        LogDevice         = log,
                        MutableFraction   = 1,
                        PageSizeBits      = 10,
                        MemorySizeBits    = 20,
                        ReadCacheSettings = null
                    },
                                    checkpointSettings: new CheckpointSettings { CheckpointManager = checkpointManager }
                                    );
                using var s = fht.NewSession(new SimpleFunctions <long, long>());

                var logCheckpoints   = new Dictionary <Guid, int>();
                var indexCheckpoints = new Dictionary <Guid, int>();
                var fullCheckpoints  = new Dictionary <Guid, int>();

                for (var i = 0; i < 10; i++)
                {
                    // Do some dummy update
                    s.Upsert(0, random.Next());

                    var  checkpointType = random.Next(5);
                    Guid result         = default;
                    switch (checkpointType)
                    {
                    case 0:
                        fht.TryInitiateHybridLogCheckpoint(out result, CheckpointType.FoldOver);
                        logCheckpoints.Add(result, 0);
                        break;

                    case 1:
                        fht.TryInitiateHybridLogCheckpoint(out result, CheckpointType.Snapshot);
                        logCheckpoints.Add(result, 0);
                        break;

                    case 2:
                        fht.TryInitiateIndexCheckpoint(out result);
                        indexCheckpoints.Add(result, 0);
                        break;

                    case 3:
                        fht.TryInitiateFullCheckpoint(out result, CheckpointType.FoldOver);
                        fullCheckpoints.Add(result, 0);
                        break;

                    case 4:
                        fht.TryInitiateFullCheckpoint(out result, CheckpointType.Snapshot);
                        fullCheckpoints.Add(result, 0);
                        break;

                    default:
                        Assert.True(false);
                        break;
                    }

                    await fht.CompleteCheckpointAsync();
                }

                Assert.AreEqual(checkpointManager.GetLogCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                logCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                Assert.AreEqual(checkpointManager.GetIndexCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                indexCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));

                if (logCheckpoints.Count != 0)
                {
                    var guid = logCheckpoints.First().Key;
                    checkpointManager.Purge(guid);
                    logCheckpoints.Remove(guid);
                    Assert.AreEqual(checkpointManager.GetLogCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                    logCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                    Assert.AreEqual(checkpointManager.GetIndexCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                    indexCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                }

                if (indexCheckpoints.Count != 0)
                {
                    var guid = indexCheckpoints.First().Key;
                    checkpointManager.Purge(guid);
                    indexCheckpoints.Remove(guid);
                    Assert.AreEqual(checkpointManager.GetLogCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                    logCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                    Assert.AreEqual(checkpointManager.GetIndexCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                    indexCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                }


                if (fullCheckpoints.Count != 0)
                {
                    var guid = fullCheckpoints.First().Key;
                    checkpointManager.Purge(guid);
                    fullCheckpoints.Remove(guid);
                    Assert.AreEqual(checkpointManager.GetLogCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                    logCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                    Assert.AreEqual(checkpointManager.GetIndexCheckpointTokens().ToDictionary(guid => guid, _ => 0),
                                    indexCheckpoints.Union(fullCheckpoints).ToDictionary(e => e.Key, e => e.Value));
                }

                checkpointManager.PurgeAll();
                Assert.IsEmpty(checkpointManager.GetLogCheckpointTokens());
                Assert.IsEmpty(checkpointManager.GetIndexCheckpointTokens());
            }
            checkpointManager.Dispose();
            TestUtils.DeleteDirectory(path, wait: true);
        }
Exemple #18
0
 public static int[] GetDockFromInside(int elevatorID)
 {
     return(elevatorID == 0 ? new int[] { } : Devices.Find(x => x.ID == elevatorID).PersonList.Select(x => x.ToFloor).OrderByDescending(x => x).ToArray());
 }
        public void TestDetectInteliGpu()
        {
            // list extracted from Intel ARK (https://ark.intel.com/content/www/us/en/ark.html#@Processors)
            string[] KnowniGpuNames = new string[]
            {
                "Intel(R) UHD Graphics P630",
                "Intel(R) UHD Graphics",
                "Intel(R) UHD Graphics 630",
                "Intel(R) UHD Graphics 620",
                "Intel(R) UHD Graphics 617",
                "Intel(R) UHD Graphics 615",
                "Intel(R) UHD Graphics 610",
                "Intel(R) UHD Graphics 605",
                "Intel(R) UHD Graphics 600",
                "Intel(R) Iris Xe Graphics",
                "Intel(R) Iris Pro Graphics P580",
                "Intel(R) Iris Pro Graphics 6200",
                "Intel(R) Iris Pro Graphics 580",
                "Intel(R) Iris Pro Graphics 5200",
                "Intel(R) Iris Plus Graphics 655",
                "Intel(R) Iris Plus Graphics 650",
                "Intel(R) Iris Plus Graphics 645",
                "Intel(R) Iris Plus Graphics 640",
                "Intel(R) Iris Plus Graphics",
                "Intel(R) Iris Graphics 6100",
                "Intel(R) Iris Graphics 550",
                "Intel(R) Iris Graphics 540",
                "Intel(R) Iris Graphics 5100",
                "Intel(R) HD Graphics P630",
                "Intel(R) HD Graphics P530",
                "Intel(R) HD Graphics",
                "Intel(R) HD Graphics 630",
                "Intel(R) HD Graphics 620",
                "Intel(R) HD Graphics 615",
                "Intel(R) HD Graphics 610",
                "Intel(R) HD Graphics 6000",
                "Intel(R) HD Graphics 5500",
                "Intel(R) HD Graphics 5300",
                "Intel(R) HD Graphics 530",
                "Intel(R) HD Graphics 520",
                "Intel(R) HD Graphics 515",
                "Intel(R) HD Graphics 510",
                "Intel(R) HD Graphics 5000",
                "Intel(R) HD Graphics 4600",
                "Intel(R) HD Graphics 4400",
                "Intel(R) HD Graphics 4200",
                "Intel(R) HD Graphics 4000",
                "Intel(R) HD Graphics 3000",
                "Intel(R) HD Graphics 2500",
                "Intel(R) HD Graphics 2000",
            };

            bool IsIntegratedGpu(string name)
            {
                return(Devices.QueryDeviceType(name, VendorId.Intel) == DeviceType.Igp);
            }

            foreach (var name in KnowniGpuNames)
            {
                Assert.IsTrue(IsIntegratedGpu(name), $"expected '{name}' to match");
            }
        }
Exemple #20
0
        public void SimpleReadAndUpdateInfoTest()
        {
            checkpointManager = new DeviceLogCommitCheckpointManager(new LocalStorageNamedDeviceFactory(), new DefaultCheckpointNamingScheme(TestUtils.MethodTestDir + "/checkpoints"), false);
            log = Devices.CreateLogDevice(TestUtils.MethodTestDir + "/SimpleReadAndUpdateInfoTest.log", deleteOnClose: true);

            fht1 = new FasterKV <AdId, NumClicks>(128,
                                                  logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                                                  checkpointSettings: new CheckpointSettings {
                CheckpointManager = checkpointManager
            }
                                                  );

            fht2 = new FasterKV <AdId, NumClicks>(128,
                                                  logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                                                  checkpointSettings: new CheckpointSettings {
                CheckpointManager = checkpointManager
            }
                                                  );


            NumClicks         value;
            AdInput           inputArg   = default;
            Output            output     = default;
            AdSimpleFunctions functions1 = new(1);
            AdSimpleFunctions functions2 = new(2);

            var session1 = fht1.NewSession(functions1);

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                if ((key & 1) > 0)
                {
                    session1.Upsert(ref inputArray[key], ref value, Empty.Default, 0);
                }
                else
                {
                    AdInput input = new() { adId = inputArray[key], numClicks = value };
                    session1.RMW(ref inputArray[key], ref input);
                }
            }
            fht1.TryInitiateFullCheckpoint(out Guid token, CheckpointType.FoldOver);
            fht1.CompleteCheckpointAsync().AsTask().GetAwaiter().GetResult();
            session1.Dispose();

            fht2.Recover(token);

            var session2 = fht2.NewSession(functions2);

            // Just need one operation here to verify readInfo/upsertInfo in the functions
            var lastKey = inputArray.Length - 1;
            var status  = session2.Read(ref inputArray[lastKey], ref inputArg, ref output, Empty.Default, 0);

            Assert.IsFalse(status.IsPending, status.ToString());

            value.numClicks = lastKey;
            status          = session2.Upsert(ref inputArray[lastKey], ref value, Empty.Default, 0);
            Assert.IsFalse(status.IsPending, status.ToString());

            inputArg = new() { adId = inputArray[lastKey], numClicks = new NumClicks {
                                   numClicks = 0
                               } };                                                                      // CopyUpdater adds, so make this 0
            status = session2.RMW(ref inputArray[lastKey], ref inputArg);
            Assert.IsFalse(status.IsPending, status.ToString());

            // Now verify Pending
            fht2.Log.FlushAndEvict(wait: true);

            output.value       = new() { numClicks = lastKey };
            inputArg.numClicks = new() { numClicks = lastKey };
            status             = session2.Read(ref inputArray[lastKey], ref inputArg, ref output, Empty.Default, 0);
            Assert.IsTrue(status.IsPending, status.ToString());
            session2.CompletePending(wait: true);

            // Upsert does not go pending so is skipped here

            --lastKey;
            output.value       = new() { numClicks = lastKey };
            inputArg.numClicks = new() { numClicks = lastKey };
            status             = session2.RMW(ref inputArray[lastKey], ref inputArg);
            Assert.IsTrue(status.IsPending, status.ToString());
            session2.CompletePending(wait: true);

            session2.Dispose();
        }
    }

    public class AdSimpleFunctions : FunctionsBase <AdId, NumClicks, AdInput, Output, Empty>
    {
        long expectedVersion;
Exemple #21
0
 public static int GetCountForType(DeviceType type)
 {
     return(Devices.Count(device => device.DeviceType == type));
 }
Exemple #22
0
        public void ShouldRecoverBeginAddress()
        {
            log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true);

            Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints6");

            fht1 = new FasterKV
                   <AdId, NumClicks>
                       (128,
                       logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints6", CheckPointType = CheckpointType.FoldOver
            }
                       );

            fht2 = new FasterKV
                   <AdId, NumClicks>
                       (128,
                       logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints6", CheckPointType = CheckpointType.FoldOver
            }
                       );


            int numOps     = 5000;
            var inputArray = new AdId[numOps];

            for (int i = 0; i < numOps; i++)
            {
                inputArray[i].adId = i;
            }

            NumClicks value;

            var session1 = fht1.NewSession(new SimpleFunctions());
            var address  = 0L;

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                session1.Upsert(ref inputArray[key], ref value, Empty.Default, 0);

                if (key == 2999)
                {
                    address = fht1.Log.TailAddress;
                }
            }

            fht1.Log.ShiftBeginAddress(address);

            fht1.TakeFullCheckpoint(out Guid token);
            fht1.CompleteCheckpointAsync().GetAwaiter().GetResult();
            session1.Dispose();

            fht2.Recover(token);

            Assert.AreEqual(address, fht2.Log.BeginAddress);

            log.Dispose();
            fht1.Dispose();
            fht2.Dispose();
            new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints6").Delete(true);
        }
Exemple #23
0
        public void SimpleRecoveryTest2(CheckpointType checkpointType)
        {
            var checkpointManager = new DeviceLogCommitCheckpointManager(new LocalStorageNamedDeviceFactory(), new DefaultCheckpointNamingScheme(TestContext.CurrentContext.TestDirectory + "\\checkpoints4"), false);

            log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true);

            // Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints4");

            fht1 = new FasterKV
                   <AdId, NumClicks>
                       (128,
                       logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointManager = checkpointManager, CheckPointType = checkpointType
            }
                       );

            fht2 = new FasterKV
                   <AdId, NumClicks>
                       (128,
                       logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointManager = checkpointManager, CheckPointType = checkpointType
            }
                       );


            int numOps     = 5000;
            var inputArray = new AdId[numOps];

            for (int i = 0; i < numOps; i++)
            {
                inputArray[i].adId = i;
            }

            NumClicks value;
            AdInput   inputArg = default;
            Output    output   = default;

            var session1 = fht1.NewSession(new SimpleFunctions());

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                session1.Upsert(ref inputArray[key], ref value, Empty.Default, 0);
            }
            fht1.TakeFullCheckpoint(out Guid token);
            fht1.CompleteCheckpointAsync().GetAwaiter().GetResult();
            session1.Dispose();

            fht2.Recover(token);

            var session2 = fht2.NewSession(new SimpleFunctions());

            for (int key = 0; key < numOps; key++)
            {
                var status = session2.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, 0);

                if (status == Status.PENDING)
                {
                    session2.CompletePending(true);
                }
                else
                {
                    Assert.IsTrue(output.value.numClicks == key);
                }
            }
            session2.Dispose();

            log.Dispose();
            fht1.Dispose();
            fht2.Dispose();
            checkpointManager.Dispose();

            new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints4").Delete(true);
        }
Exemple #24
0
        public async Task AsyncRecoveryTest1(CheckpointType checkpointType)
        {
            log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/SimpleRecoveryTest2.log", deleteOnClose: true);

            Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "/checkpoints4");

            fht1 = new FasterKV <AdId, NumClicks>
                       (128,
                       logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, PageSizeBits = 10, MemorySizeBits = 13
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints4", CheckPointType = checkpointType
            }
                       );

            fht2 = new FasterKV <AdId, NumClicks>
                       (128,
                       logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, PageSizeBits = 10, MemorySizeBits = 13
            },
                       checkpointSettings: new CheckpointSettings {
                CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints4", CheckPointType = checkpointType
            }
                       );

            int numOps     = 5000;
            var inputArray = new AdId[numOps];

            for (int i = 0; i < numOps; i++)
            {
                inputArray[i].adId = i;
            }

            NumClicks value;
            AdInput   inputArg = default;
            Output    output   = default;

            var s0 = fht1.For(functions).NewSession <SimpleFunctions>();
            var s1 = fht1.For(functions).NewSession <SimpleFunctions>();
            var s2 = fht1.For(functions).NewSession <SimpleFunctions>();

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                s1.Upsert(ref inputArray[key], ref value, Empty.Default, key);
            }

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                s2.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, key);
            }

            // does not require session
            fht1.TakeFullCheckpoint(out _);
            await fht1.CompleteCheckpointAsync();

            s2.CompletePending(true);

            fht1.TakeFullCheckpoint(out Guid token);
            await fht1.CompleteCheckpointAsync();

            s2.Dispose();
            s1.Dispose();
            s0.Dispose();
            fht1.Dispose();

            fht2.Recover(token); // sync, does not require session

            var guid = s1.ID;

            using (var s3 = fht2.For(functions).ResumeSession <SimpleFunctions>(guid, out CommitPoint lsn))
            {
                Assert.IsTrue(lsn.UntilSerialNo == numOps - 1);

                for (int key = 0; key < numOps; key++)
                {
                    var status = s3.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, s3.SerialNo);

                    if (status == Status.PENDING)
                    {
                        s3.CompletePending(true);
                    }
                    else
                    {
                        Assert.IsTrue(output.value.numClicks == key);
                    }
                }
            }

            fht2.Dispose();
            log.Dispose();
            new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "/checkpoints4").Delete(true);
        }
Exemple #25
0
 /// <summary>
 /// Adds a <see cref="Device"/> to the list of devices and saves the settings.
 /// </summary>
 /// <param name="device">The <see cref="Device"/> to be added.</param>
 public void AddDevice(Device device)
 {
     Devices.Add(device);
     SaveSettings();
 }
Exemple #26
0
        /// <summary>
        /// Init the repository from a given path
        /// </summary>
        public void Init(string path)
        {
            RepositoryPath = path;
            CheckFolders();
            //Data sources
            if (Sources.Count == 0)
            {
                foreach (var file in Directory.GetFiles(SourcesFolder, "*." + SealConfigurationFileExtension))
                {
                    try
                    {
                        var source = MetaSource.LoadFromFile(file, this);
                        Sources.Add(source);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }

            if (Devices.Count == 0)
            {
                //Devices, add a default folder device, then the other devices
                Devices.Add(OutputFolderDevice.Create());
                foreach (var file in Directory.GetFiles(DevicesEmailFolder, "*." + SealConfigurationFileExtension))
                {
                    try
                    {
                        Devices.Add(OutputEmailDevice.LoadFromFile(file, true));
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
                foreach (var file in Directory.GetFiles(DevicesFileServerFolder, "*." + SealConfigurationFileExtension))
                {
                    try
                    {
                        Devices.Add(OutputFileServerDevice.LoadFromFile(file, true));
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }

            if (!_assembliesLoaded)
            {
                //Load extra assemblies defined in Repository
                var assemblies = Directory.GetFiles(AssembliesFolder, "*.dll");
                foreach (var assembly in assemblies)
                {
                    try
                    {
                        Assembly.LoadFrom(assembly);
                    }
                    catch (Exception Exception)
                    {
                        Debug.WriteLine(Exception.Message);
                    }
                }

                //Add this assembly resolve necessary when executing Razor scripts
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolve);

                _assembliesLoaded = true;
            }
        }
Exemple #27
0
 public ResponseBatteryVoltage(Devices _destination)
 {
     m_destination = _destination.ToByteValue();
     m_timeStamp   = Environment.TickCount;
     buildPacket();
 }
 public void SetZSMI31014_EE(int LinkId, Devices.ZSMI31014_EERow row)
 {
     if (IsDeviceChair(LinkId))
         cBPPRotocol.CallOperation(LinkId, "ZSMI31014_EE_WRITE", new object[] { row });
 }
Exemple #29
0
 public static int GetPersonCount(int elevatorID)
 {
     return(Devices.Find(x => x.ID == elevatorID).PersonList.Count);
 }
        public static DeviceModel Get(Devices device)
        {
            switch (device)
            {
                case Devices.Iphone4:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(320, 568),
                        UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7"
                    };
                    break;
                case Devices.Iphone5:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(320, 568),
                        UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
                    };
                    break;
                case Devices.Iphone6:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(320, 480),
                        UserAgent =
                            "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4"
                    };
                    break;

                case Devices.Ipad:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(1024, 768),
                        UserAgent =
                            "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
                    };
                    break;
                case Devices.GalaxyS4:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(360, 640),
                        UserAgent = "Mozilla/5.0 (Linux; Android 4.2.2; GT-I9505 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36"
                    };
                    break;
                case Devices.GalaxyTab:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(1280, 800),
                        UserAgent = "Mozilla/5.0 (Linux; U; Android 3.0; xx-xx; GT-P7100 Build/HRI83) AppleWebkit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13"
                    };
                    break;
                case Devices.Nexus5:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(360, 640),
                        UserAgent =
                            "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Mobile Safari/537.36"
                    };
                    break;

                default:
                    return new DeviceModel
                    {
                        ScreenSize = new Size(1280, 1024),
                        UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
                    };
            }
        }
Exemple #31
0
        public async ValueTask SimpleRecoveryTest2([Values] CheckpointType checkpointType, [Values] bool isAsync)
        {
            checkpointManager = new DeviceLogCommitCheckpointManager(new LocalStorageNamedDeviceFactory(), new DefaultCheckpointNamingScheme(TestUtils.MethodTestDir + "/checkpoints4"), false);
            log = Devices.CreateLogDevice(TestUtils.MethodTestDir + "/SimpleRecoveryTest2.log", deleteOnClose: true);

            fht1 = new FasterKV <AdId, NumClicks>(128,
                                                  logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                                                  checkpointSettings: new CheckpointSettings {
                CheckpointManager = checkpointManager
            }
                                                  );

            fht2 = new FasterKV <AdId, NumClicks>(128,
                                                  logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                                                  checkpointSettings: new CheckpointSettings {
                CheckpointManager = checkpointManager
            }
                                                  );


            NumClicks value;
            AdInput   inputArg = default;
            Output    output   = default;

            var session1 = fht1.NewSession(new AdSimpleFunctions());

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                session1.Upsert(ref inputArray[key], ref value, Empty.Default, 0);
            }
            fht1.TryInitiateFullCheckpoint(out Guid token, checkpointType);
            fht1.CompleteCheckpointAsync().AsTask().GetAwaiter().GetResult();
            session1.Dispose();

            if (isAsync)
            {
                await fht2.RecoverAsync(token);
            }
            else
            {
                fht2.Recover(token);
            }

            var session2 = fht2.NewSession(new AdSimpleFunctions());

            for (int key = 0; key < numOps; key++)
            {
                var status = session2.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, 0);

                if (status.IsPending)
                {
                    session2.CompletePending(true);
                }
                else
                {
                    Assert.AreEqual(key, output.value.numClicks);
                }
            }
            session2.Dispose();
        }
Exemple #32
0
 public static void ClearDevice()
 {
     Devices.Clear();
     CallPersons.Clear();
 }
 public BastetCommunication(Devices lDevices, Form1 lForm1)
 {
     cDevices=lDevices;
     cForm1 = lForm1;
 }
 private void SetOneKey(Devices.DeviceKeys key, Color color)
 {
     keyColors[key] = color;
 }
Exemple #35
0
        /// <summary>
        /// Finds devices by device or service type synchronously using a timeout period.
        /// </summary>
        /// <param name="uriString">The URI string to search for or null / empty for all.</param>
        /// <param name="timeoutMS">The maximum timeout time in milliseconds to wait or -1 for wait forever.</param>
        /// <param name="maxDevices">The maximum number of devices to find before returning or 0 for as many as possible.</param>
        /// <param name="searchCompleted">True if the search completed and all available devices were returned.</param>
        /// <param name="addressFamily">The address family to search in. (Vista or above only).</param>
        /// <param name="resolveNetworkInterfaces">True to resolve network interface Guids.</param>
        /// <returns>A Devices list containing the found devices.</returns>
        public static Devices FindDevices(
            string uriString,
            int timeoutMS,
            int maxDevices,
            out bool searchCompleted,
            AddressFamilyFlags addressFamily = AddressFamilyFlags.IPvBoth,
            bool resolveNetworkInterfaces = false)
        {
            Discovery ldDiscovery = new Discovery(uriString, addressFamily, resolveNetworkInterfaces);
            Devices ldDevices = new Devices();
            bool lbSearchCompleted = false;
            ManualResetEvent lmreComplete = new ManualResetEvent(false);

            ldDiscovery.DeviceAdded +=
                (sender, args) =>
                {
                    ldDevices.Add(args.Device);
                    if (maxDevices > 0 && ldDevices.Count >= maxDevices)
                        lmreComplete.Set();
                };

            ldDiscovery.SearchComplete += (sender, args) =>
                {
                    lbSearchCompleted = true;
                    lmreComplete.Set();
                };

            ldDiscovery.Start();

            lmreComplete.WaitOne(timeoutMS);

            searchCompleted = lbSearchCompleted;
            ldDiscovery.Dispose();

            return ldDevices;
        }
 public static Image Take(string url, Devices device = Devices.Desktop)
 {
     var size = GetSize(device);
     return Take(url, size);
 }
        private Color GetOneKey(Devices.DeviceKeys key)
        {
            Color ret = Color.Black;

            if(keyColors.ContainsKey(key))
                ret = keyColors[key];

            return ret;
        }
Exemple #38
0
        static void Main()
        {
            long key = 1, value = 1, output = 0;

            // This is a simple in-memory sample of FASTER using value types

            // Create device for FASTER log
            var path = Path.GetTempPath() + "HelloWorld\\";
            var log  = Devices.CreateLogDevice(Path.GetTempPath() + "hlog.log");

            // Create store instance
            var store = new FasterKV <long, long>(
                size: 1L << 20, // 1M cache lines of 64 bytes each = 64MB hash table
                    logSettings: new LogSettings {
                LogDevice = log
                    }                                            // specify log settings (e.g., size of log in memory)
                );

            // Create functions for callbacks; we use a standard in-built function in this sample
            // although you can write your own by extending FunctionsBase or implementing IFunctions
            // In this in-built function, read-modify-writes will perform value merges via summation
            var funcs = new SimpleFunctions <long, long>((a, b) => a + b);

            // Each logical sequence of calls to FASTER is associated
            // with a FASTER session. No concurrency allowed within
            // a single session
            var session = store.NewSession(funcs);

            // (1) Upsert and read back upserted value
            session.Upsert(ref key, ref value);

            // In this sample, reads are served back from memory and return synchronously
            // Reads from disk will return PENDING status; see StoreCustomTypes example for details
            var status = session.Read(ref key, ref output);

            if (status == Status.OK && output == value)
            {
                Console.WriteLine("(1) Success!");
            }
            else
            {
                Console.WriteLine("(1) Error!");
            }

            /// (2) Delete key, read to verify deletion
            session.Delete(ref key);

            status = session.Read(ref key, ref output);
            if (status == Status.NOTFOUND)
            {
                Console.WriteLine("(2) Success!");
            }
            else
            {
                Console.WriteLine("(2) Error!");
            }

            // (3) Perform two read-modify-writes (summation), verify result
            key = 2;
            long input1 = 25, input2 = 27;

            session.RMW(ref key, ref input1);
            session.RMW(ref key, ref input2);

            status = session.Read(ref key, ref output);

            if (status == Status.OK && output == input1 + input2)
            {
                Console.WriteLine("(3) Success!");
            }
            else
            {
                Console.WriteLine("(3) Error!");
            }

            // End session
            session.Dispose();

            // Dispose store
            store.Dispose();

            // Close devices
            log.Dispose();

            // Delete the created files
            try { new DirectoryInfo(path).Delete(true); } catch { }

            Console.WriteLine("Press <ENTER> to end");
            Console.ReadLine();
        }
        private void PercentEffect(Color foregroundColor, Color backgroundColor, Devices.DeviceKeys[] keys, double value, double total, PercentEffectType effectType = PercentEffectType.Progressive)
        {
            double progress_total = value / total;
            if (progress_total < 0.0)
                progress_total = 0.0;
            else if (progress_total > 1.0)
                progress_total = 1.0;

            double progress = progress_total * keys.Count();

            for (int i = 0; i < keys.Count(); i++)
            {
                Devices.DeviceKeys current_key = keys[i];

                switch (effectType)
                {
                    case (PercentEffectType.AllAtOnce):
                        SetOneKey(current_key, Color.FromArgb(
                                (Int32)Math.Min((Int32)foregroundColor.R * progress_total + (Int32)backgroundColor.R * (1.0 - progress_total), 255),
                                (Int32)Math.Min((Int32)foregroundColor.G * progress_total + (Int32)backgroundColor.G * (1.0 - progress_total), 255),
                                (Int32)Math.Min((Int32)foregroundColor.B * progress_total + (Int32)backgroundColor.B * (1.0 - progress_total), 255)
                            ));
                        break;
                    case (PercentEffectType.Progressive_Gradual):
                        if (i == (int)progress)
                        {
                            double percent = (double)progress - i;
                            SetOneKey(current_key, Color.FromArgb(
                                (Int32)Math.Min((Int32)foregroundColor.R * percent + (Int32)backgroundColor.R * (1.0 - percent), 255),
                                (Int32)Math.Min((Int32)foregroundColor.G * percent + (Int32)backgroundColor.G * (1.0 - percent), 255),
                                (Int32)Math.Min((Int32)foregroundColor.B * percent + (Int32)backgroundColor.B * (1.0 - percent), 255)
                                ));
                        }
                        else if (i < (int)progress)
                            SetOneKey(current_key, foregroundColor);
                        else
                            SetOneKey(current_key, backgroundColor);
                        break;
                    default:
                        if (i < (int)progress)
                            SetOneKey(current_key, foregroundColor);
                        else
                            SetOneKey(current_key, backgroundColor);
                        break;
                }
            }
        }
 public Demo()
 {
     this._device = Devices.Desktop;
 }
 public static void Save(string url, string path, ImageFormat format, Devices device = Devices.Desktop)
 {
     var size = GetSize(device);
     Save(url, path, format, size);
 }
 public override void CreateDevice()
 {
     Devices.Add(new ScannerB());
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 internal void Initialize(AsyncLocoBuffer lb, Devices.MgvServo.ServoProgrammer programmer)
 {
     this.lb = lb;
     this.programmer = programmer;
     programmer.Turnout = turnoutSelection.Turnout;
 }
Exemple #44
0
 public override int RegisterHandler(Devices.TimerHandler handler, long TimeoutNS, bool Recurring, FOS_System.Object state)
 {
     return RegisterHandler(new PITHandler(handler, state, TimeoutNS, Recurring));
 }
 public Demo(Devices device)
 {
     this._device = device;
 }
Exemple #46
0
        internal static bool IsEnableAllDevicesRedundantOperation()
        {
            var allEnabled = Devices.All(dev => !dev.IsDisabled);

            return(allEnabled);
        }
Exemple #47
0
        public Devices SwitchDevices(Devices device)
        {
            byte[] data = new byte[8];
            data[0] = 0x02;
            data[1] = 0x55;
            data[2] = (byte)device;

            int result = HIDAPI.HIDWrite(handle, data);

            //TODO: This fails to read if the write fails. It blocks forever.
            data = HIDAPI.HIDRead(handle);

            if(data[1] == 0x5c)
                return (Devices)data[2];
            else {
                Console.WriteLine("Unable to read switch status.\n");
                return 0;
            }
        }
Exemple #48
0
        private async ValueTask SimpleRecoveryTest1_Worker(CheckpointType checkpointType, bool isAsync, bool testCommitCookie)
        {
            if (testCommitCookie)
            {
                // Generate a new unique byte sequence for test
                commitCookie = Guid.NewGuid().ToByteArray();
            }

            if (checkpointManager is null)
            {
                checkpointDir = TestUtils.MethodTestDir + $"/checkpoints";
            }

            log = Devices.CreateLogDevice(TestUtils.MethodTestDir + "/SimpleRecoveryTest1.log", deleteOnClose: true);

            fht1 = new FasterKV <AdId, NumClicks>(128,
                                                  logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                                                  checkpointSettings: new CheckpointSettings {
                CheckpointDir = checkpointDir, CheckpointManager = checkpointManager
            }
                                                  );

            fht2 = new FasterKV <AdId, NumClicks>(128,
                                                  logSettings: new LogSettings {
                LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29
            },
                                                  checkpointSettings: new CheckpointSettings {
                CheckpointDir = checkpointDir, CheckpointManager = checkpointManager
            }
                                                  );

            NumClicks value;
            AdInput   inputArg = default;
            Output    output   = default;

            var session1 = fht1.NewSession(new AdSimpleFunctions());

            for (int key = 0; key < numOps; key++)
            {
                value.numClicks = key;
                session1.Upsert(ref inputArray[key], ref value, Empty.Default, 0);
            }

            if (testCommitCookie)
            {
                fht1.CommitCookie = commitCookie;
            }
            fht1.TryInitiateFullCheckpoint(out Guid token, checkpointType);
            fht1.CompleteCheckpointAsync().AsTask().GetAwaiter().GetResult();
            session1.Dispose();

            if (isAsync)
            {
                await fht2.RecoverAsync(token);
            }
            else
            {
                fht2.Recover(token);
            }

            if (testCommitCookie)
            {
                Assert.IsTrue(fht2.RecoveredCommitCookie.SequenceEqual(commitCookie));
            }
            else
            {
                Assert.Null(fht2.RecoveredCommitCookie);
            }

            var session2 = fht2.NewSession(new AdSimpleFunctions());

            Assert.AreEqual(2, session2.ID);

            for (int key = 0; key < numOps; key++)
            {
                var status = session2.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, 0);

                if (status.IsPending)
                {
                    session2.CompletePendingWithOutputs(out var outputs, wait: true);
                    Assert.IsTrue(outputs.Next());
                    output = outputs.Current.Output;
                    Assert.IsFalse(outputs.Next());
                    outputs.Current.Dispose();
                }
                else
                {
                    Assert.IsTrue(status.Found);
                }
                Assert.AreEqual(key, output.value.numClicks);
            }
            session2.Dispose();
        }
Exemple #49
0
 /// <summary>
 /// Initialises a recurring new PIT handler.
 /// </summary>
 /// <param name="HandleOnTrigger">The method to call when the timeout expires.</param>
 /// <param name="aState">The state object to pass to the handler.</param>
 /// <param name="NanosecondsTimeout">The timeout, in nanoseconds.</param>
 /// <param name="NanosecondsLeft">The intial timeout value, in nanoseconds.</param>
 public PITHandler(Devices.TimerHandler HandleOnTrigger, FOS_System.Object aState, long NanosecondsTimeout, uint NanosecondsLeft)
 {
     this.HandleTrigger = HandleOnTrigger;
     this.NanosecondsTimeout = NanosecondsTimeout;
     this.NSRemaining = NanosecondsLeft;
     this.Recurring = true;
     this.state = aState;
 }
        private void AddEntryes()
        {
            #region ValueType
            ValueType valueIntType    = new ValueType("int");
            ValueType valueStringType = new ValueType("string");
            ValueType valueFloatType  = new ValueType("float");
            ValueType valueBoolType   = new ValueType("bool");
            ValueTypes.Add(valueIntType);
            ValueTypes.Add(valueStringType);
            ValueTypes.Add(valueFloatType);
            ValueTypes.Add(valueBoolType);
            SaveChanges();
            #endregion

            #region DeviceType
            DeviceType deviceLaptopType = new DeviceType("Ноутбук", Properties.Resources.Laptop);
            DeviceTypes.Add(deviceLaptopType);
            SaveChanges();
            #endregion

            #region Devices
            Device device1 = new Device(deviceLaptopType.ID, "Samsung NC10");
            Device device2 = new Device(deviceLaptopType.ID, "ASUS K50IN");
            Devices.Add(device1);
            Devices.Add(device2);
            SaveChanges();
            #endregion

            #region CharacteristicType
            CharacteristicType characteristicType_Webcam       = new CharacteristicType(deviceLaptopType.ID, "Веб-камера", valueBoolType.ID);
            CharacteristicType characteristicType_VideoCard    = new CharacteristicType(deviceLaptopType.ID, "Видеокарта", valueStringType.ID);
            CharacteristicType characteristicType_WorkingHours = new CharacteristicType(deviceLaptopType.ID, "Время работы", valueIntType.ID);
            CharacteristicType characteristicType_Screen       = new CharacteristicType(deviceLaptopType.ID, "Диагональ экрана", valueFloatType.ID);
            CharacteristicType characteristicType_Storage      = new CharacteristicType(deviceLaptopType.ID, "Накопитель", valueIntType.ID);
            CharacteristicType characteristicType_RAM          = new CharacteristicType(deviceLaptopType.ID, "Оперативная память", valueIntType.ID);
            CharacteristicType characteristicType_CPU          = new CharacteristicType(deviceLaptopType.ID, "Процессор", valueStringType.ID);
            CharacteristicTypes.Add(characteristicType_Webcam);
            CharacteristicTypes.Add(characteristicType_VideoCard);
            CharacteristicTypes.Add(characteristicType_WorkingHours);
            CharacteristicTypes.Add(characteristicType_Screen);
            CharacteristicTypes.Add(characteristicType_Storage);
            CharacteristicTypes.Add(characteristicType_RAM);
            CharacteristicTypes.Add(characteristicType_CPU);
            SaveChanges();
            #endregion

            #region Characteristics
            //1 Samsung NC10
            Characteristic char1_Webcam       = new Characteristic(device1.ID, characteristicType_Webcam.ID, "true");
            Characteristic char1_VideoCard    = new Characteristic(device1.ID, characteristicType_VideoCard.ID, "Intel GMA 952 (встроенная)");
            Characteristic char1_WorkingHours = new Characteristic(device1.ID, characteristicType_WorkingHours.ID, "6");
            Characteristic char1_Screen       = new Characteristic(device1.ID, characteristicType_Screen.ID, "10,20");
            Characteristic char1_Storage      = new Characteristic(device1.ID, characteristicType_Storage.ID, "80");
            Characteristic char1_RAM          = new Characteristic(device1.ID, characteristicType_RAM.ID, "1");
            Characteristic char1_CPU          = new Characteristic(device1.ID, characteristicType_CPU.ID, "Intel 945GSE");
            Characteristics.Add(char1_Webcam);
            Characteristics.Add(char1_VideoCard);
            Characteristics.Add(char1_WorkingHours);
            Characteristics.Add(char1_Screen);
            Characteristics.Add(char1_Storage);
            Characteristics.Add(char1_RAM);
            Characteristics.Add(char1_CPU);
            //2 ASUS K50IN
            Characteristic char2_Webcam       = new Characteristic(device2.ID, characteristicType_Webcam.ID, "true");
            Characteristic char2_VideoCard    = new Characteristic(device2.ID, characteristicType_VideoCard.ID, "NVIDIA GeForce G 102M (дискретная)");
            Characteristic char2_WorkingHours = new Characteristic(device2.ID, characteristicType_WorkingHours.ID, "6");
            Characteristic char2_Screen       = new Characteristic(device2.ID, characteristicType_Screen.ID, "15,6");
            Characteristic char2_Storage      = new Characteristic(device2.ID, characteristicType_Storage.ID, "250");
            Characteristic char2_RAM          = new Characteristic(device2.ID, characteristicType_RAM.ID, "2");
            Characteristics.Add(char2_Webcam);
            Characteristics.Add(char2_VideoCard);
            Characteristics.Add(char2_WorkingHours);
            Characteristics.Add(char2_Screen);
            Characteristics.Add(char2_Storage);
            Characteristics.Add(char2_RAM);
            SaveChanges();
            #endregion
        }