public SiidDevice(InstanceHolder I, Scheduler.Classes.DeviceClass Dev) { this.Instance = I; this.Ref = Dev.get_Ref(Instance.host); this.Device = Dev; this.Extra = Dev.get_PlugExtraData_Get(Instance.host); }
public SiidDevice(InstanceHolder I, int R) { this.Instance = I; this.Ref = R; this.Device = (Scheduler.Classes.DeviceClass)Instance.host.GetDeviceByRef(R); this.Extra = Device.get_PlugExtraData_Get(Instance.host); }
public SiidDevice(InstanceHolder I) { this.Instance = I; this.Ref = 0; this.Device = null; this.Extra = null; }
private void OnInputListenerChanged(int index, SButton value) { switch (index) { case 0: Config.ButtonShowMenu = value; break; case 1: Config.ButtonToggleBlackList = value; break; case 2: Config.ButtonToggleFlowerColorUnification = value; break; case 3: Config.ToggleAfkFishing = value; break; default: return; } InstanceHolder.WriteConfig(); _listener = null; }
private void OnSomewhereClicked(int index, Point point) { _clickListener = null; if (index == -1) { //Assertion was cancelled Logger.Log("Assertion Cancelled"); return; } switch (index) { case 0: Config.ProbBoxCoordinates = point; break; case 1: Config.PriceBoxCoordinates = point; break; default: return; } InstanceHolder.WriteConfig(); }
public BACnetDevice(BACnetNetwork bnn, BacnetAddress bna, uint deviceId, InstanceHolder I) // : base() //: base(BACnetDevice bnd, BacnetObjectId boi) { this.BacnetNetwork = bnn; //may be multiple devices on one network this.BacnetAddress = bna; //each device has single bacnet network this.InstanceNumber = deviceId; //pretty much just for internal use Instance = I; }
public BACnetNetwork(BACnetGlobalNetwork bgn, String ipAddr, InstanceHolder I) //, BACnetGlobalNetwork bgn) { this.IpAddress = ipAddr; this.BacnetGlobalNetwork = bgn; Instance = I; //this.BacnetTreeNode = new TreeNode(this); //Discover(); //no, not until user clicks on node to get child devices. }
public static void ToggleFlowerColorUnification() { GameLocation loc = Game1.currentLocation; Vector2 tileLoc = Game1.currentCursorTile; Dictionary <Vector2, HoeDirt> hoeDirts = loc.terrainFeatures.Pairs .Where(p => p.Value is HoeDirt) .ToDictionary(p => p.Key, p => p.Value as HoeDirt); if (!hoeDirts.ContainsKey(tileLoc)) { Logger.Log("The given tile is not a hoe dirt."); return; } HoeDirt dirt = hoeDirts[tileLoc]; Crop crop = dirt.crop; if (crop == null) { Logger.Log("There is no crop."); return; } if (crop.dead.Value) { Logger.Log("The crop is dead."); return; } if (!crop.programColored.Value) { Logger.Log("That crop may not be a flower."); return; } int index = crop.indexOfHarvest.Value; if (IsVanillaFlower(index)) { Util.ShowHudMessage(Translation.Get("flower.vanilla")); return; } if (GetCustomizedFlowerColor(index) != null) { // Unregister flower Config.CustomizedFlowerColors.Remove(crop.indexOfHarvest.Value); InstanceHolder.WriteConfig(); Util.ShowHudMessage(string.Format(Translation.Get("flower.unregister"), Util.GetItemName(index))); return; } // Show flower registration menu Game1.playSound("bigSelect"); Game1.activeClickableMenu = new RegisterFlowerMenu(800, 640, crop.tintColor.Value, index, RegisterFlowerColor); }
public BACnetGlobalNetwork(InstanceHolder instance, Boolean filterIpAddress = false, String selectedIpAddress = "", Int32 udpPort = 47808, Boolean filterDeviceInstance = false, Int32 deviceInstanceMin = 0, Int32 deviceInstanceMax = 4194303) { this.Instance = instance; this.FilterIpAddress = filterIpAddress; this.SelectedIpAddress = selectedIpAddress; this.UdpPort = udpPort; this.FilterDeviceInstance = filterDeviceInstance; this.DeviceInstanceMin = deviceInstanceMin; this.DeviceInstanceMax = deviceInstanceMax; }
public async Task Pool_should_accept_preset_instances_and_allow_controlling_their_disposal(bool shouldDispose) { var holder = new InstanceHolder(); var instances = Enumerable.Range(0, 5).Select(x => holder.CreateInstance()).ToArray(); using (var pool = new ResourcePool <IDisposable>(instances, shouldDispose)) await RunTasks(pool, instances.Length * 3); foreach (var instance in holder.Instances) { instance.Verify(x => x.Dispose(), Times.Exactly(shouldDispose ? 1 : 0)); } }
public BACnetDataService(string pagename, InstanceHolder instance) : base(pagename) { Instance = instance; //hmm. Aren't we still accessing same network data, even if multiple instances? Is a lock necessary? //BACnetBuilder = new htmlBuilder("BACnetObjectDataService" + Instance.ajaxName); //DiscoveredBACnetDevices = new List<string>(); this.PageName = pagename + instance.ajaxName; //this.PageName = //this.PageName = BaseUrl + instance.ajaxName.Replace(":", "_"); }
private void OnSomewhereClicked(int index, Point point) { _isListeningClick = false; _clickListener = null; switch (index) { case 0: Config.ProbBoxCoordinates = point; break; default: return; } InstanceHolder.WriteConfig(); }
public async Task Pool_should_dynamically_create_new_instances_when_required_and_dispose_upon_completion_async_version() { var holder = new InstanceHolder(); var taskCount = 100; using (var pool = new ResourcePool <IDisposable>(holder.CreateInstanceAsync)) await RunTasks(pool, taskCount); Assert.That(holder.Instances.Count, Is.EqualTo(taskCount)); foreach (var instance in holder.Instances) { instance.Verify(x => x.Dispose()); } }
private static bool ToggleBlackList(Crop crop) { int index = crop.forageCrop.Value ? crop.whichForageCrop.Value : crop.indexOfHarvest.Value; if (IsBlackListed(crop)) { InstanceHolder.Config.HarvestException.Remove(index); } else { InstanceHolder.Config.HarvestException.Add(index); } InstanceHolder.WriteConfig(); return IsBlackListed(crop); }
public async Task Pool_should_dynamically_create_new_instances_up_to_the_specified_limit_async_version() { var holder = new InstanceHolder(); var expectedLimit = 5; using (var pool = new ResourcePool <IDisposable>(holder.CreateInstanceAsync, expectedLimit)) await RunTasks(pool, expectedLimit * 3); Assert.That(holder.Instances.Count, Is.EqualTo(expectedLimit)); foreach (var instance in holder.Instances) { instance.Verify(x => x.Dispose()); } }
public static void Update(InstanceHolder I) { List <SiidDevice> UpdatedDevs = new List <SiidDevice>(); lock (I.Devices) { foreach (SiidDevice D in I.Devices.ToList()) { if (I.host.DeviceExistsRef(D.Ref)) { UpdatedDevs.Add(D); } } } I.Devices = UpdatedDevs; }
private void OnSliderValueChanged(int index, int value) { switch (index) { case 0: Config.CpuThresholdFishing = value / 10.0f; break; case 1: Config.StaminaToEatRatio = value / 10.0f; break; case 2: Config.HealthToEatRatio = value / 10.0f; break; case 3: Config.AutoWaterRadius = value; break; case 4: Config.AutoPetRadius = value; break; case 5: Config.AutoHarvestRadius = value; break; case 6: Config.AutoCollectRadius = value; break; case 7: Config.AutoShakeRadius = value; break; case 8: Config.AutoDigRadius = value; break; case 10: Config.MachineRadius = value; break; case 12: Config.IdleTimeout = value; break; case 13: Config.ScavengingRadius = value; break; case 14: Config.AnimalHarvestRadius = value; break; case 15: Config.TrialOfExamine = value; break; case 16: Config.RadiusFarmCleanup = value; break; case 17: Config.ThrowPower = value / 10.0f; break; case 18: Config.ThresholdStaminaPercentage = value; break; default: return; } InstanceHolder.WriteConfig(); }
public void OnBeforeSerialize() { int instancesCount = instances.Count; if (serializedPrefabs == null || serializedPrefabs.Length != instancesCount) { serializedPrefabs = new Transform[instancesCount]; } if (serializedInstances == null || serializedInstances.Length != instancesCount) { serializedInstances = new InstanceHolder[instancesCount]; } int i = 0; foreach (KeyValuePair <Transform, List <Instance> > kvp in instances) { Transform prefab = kvp.Key; List <Instance> list = kvp.Value; int listCount = list.Count; InstanceHolder instanceHolder = serializedInstances[i]; if (instanceHolder.list == null || instanceHolder.list.Length != listCount) { instanceHolder = new InstanceHolder() { list = new Instance[listCount] }; serializedInstances[i] = instanceHolder; } serializedPrefabs[i] = prefab; for (int j = 0; j < listCount; j++) { instanceHolder.list[j] = list[j]; } i++; } }
public void Given_resource_can_be_used_only_by_one_provider_at_a_time() { var holder = new InstanceHolder(); var usage = new ConcurrentDictionary <object, object>(); ResourcePool <IDisposable> pool; async Task RunTask() { using (var provider = new ResourceHandle <IDisposable>(pool)) { var instance = await provider.ObtainAsync(); usage.AddOrUpdate(instance, instance, (_, __) => throw new InvalidOperationException("Instance already in use!")); await Task.Delay(250); usage.TryRemove(instance, out _); } } using (pool = new ResourcePool <IDisposable>(holder.CreateInstance, 5)) Assert.DoesNotThrowAsync(() => RunTasks(5, RunTask)); }
private void OnCheckboxValueChanged(int index, bool value) { switch (index) { case 0: Config.MineInfoGui = value; break; case 1: Config.GiftInformation = value; break; case 2: Config.AutoWaterNearbyCrops = value; break; case 3: Config.AutoPetNearbyAnimals = value; break; case 4: Config.AutoAnimalDoor = value; break; case 5: Config.AutoFishing = value; break; case 6: Config.AutoReelRod = value; break; case 8: Config.FishingInfo = value; break; case 9: Config.AutoGate = value; break; case 10: Config.AutoEat = value; break; case 11: Config.AutoHarvest = value; break; case 12: Config.AutoDestroyDeadCrops = value; break; case 13: Config.AutoRefillWateringCan = value; break; case 14: Config.AutoCollectCollectibles = value; break; case 15: Config.AutoShakeFruitedPlants = value; break; case 16: Config.FindCanFromInventory = value; break; case 17: Config.AutoDigArtifactSpot = value; break; case 18: Config.FindHoeFromInventory = value; break; case 20: Config.BalancedMode = value; break; case 22: Config.AutoDepositIngredient = value; break; case 23: Config.AutoPullMachineResult = value; break; case 24: Config.AutoPetNearbyPets = value; break; case 25: Config.ProtectNectarProducingFlower = value; break; case 26: Config.FishingProbabilitiesInfo = value; break; case 28: Config.EstimateShippingPrice = value; break; case 29: Config.UnifyFlowerColors = value; break; case 30: Config.AutoLootTreasures = value; break; case 31: Config.CloseTreasureWhenAllLooted = value; break; case 32: Config.FilterBackgroundInMenu = value; break; case 33: Config.PauseWhenIdle = value; break; case 34: Config.AutoPickUpTrash = value; break; case 35: Config.AutoShearingAndMilking = value; break; case 36: Config.CollectLetterAttachmentsAndQuests = value; break; case 37: Config.MorePreciseProbabilities = value; break; case 38: Config.ShowMousePositionWhenAssigningLocation = value; break; case 39: Config.CutWeeds = value; break; case 40: Config.BreakRocks = value; break; case 41: Config.ChopTwigs = value; break; default: return; } InstanceHolder.WriteConfig(); }
public ScratchpadDevicePage(string pagename, InstanceHolder instance) : base(pagename) { Instance = instance; ScratchpadBuilder = new htmlBuilder("Scratchpad" + Instance.ajaxName); }
public static string GetValues(InstanceHolder Instance, string ScratchPadString) { ScratchPadString = ScratchPadString.Replace("(^p^)", "+"); List <int> Raws = new List <int>(); List <int> Processed = new List <int>(); Match m = Regex.Match(ScratchPadString, @"(\$\()+(\d+)(\))+"); while (m.Success) { if (!Raws.Contains(int.Parse(m.Groups[2].ToString()))) { Raws.Add(int.Parse(m.Groups[2].ToString())); } m = m.NextMatch(); } m = Regex.Match(ScratchPadString, @"(\#\()+(\d+)(\))+"); while (m.Success) { if (!Processed.Contains(int.Parse(m.Groups[2].ToString()))) { Processed.Add(int.Parse(m.Groups[2].ToString())); } m = m.NextMatch(); } StringBuilder FinalString = new StringBuilder(ScratchPadString); foreach (int dv in Raws) { SiidDevice TempDev = SiidDevice.GetFromListByID(Instance.Devices, dv); if (TempDev == null) { try { Scheduler.Classes.DeviceClass newDevice = (Scheduler.Classes.DeviceClass)Instance.host.GetDeviceByRef(dv); //If the device exists and is a SIID device, adds it into the list var E = newDevice.get_PlugExtraData_Get(Instance.host); if (E.GetNamed("SSIDKey") != null) { TempDev = new SiidDevice(Instance, newDevice); Instance.Devices.Add(TempDev); } } catch { //Device reference either incorrect or not a SIID device. } } if (TempDev != null) { //OK the extradata store in the SIID device list is outdated. grab from the device... //var TempEDO = TempDev.Extra; var TempEDO = TempDev.Device.get_PlugExtraData_Get(Instance.host); var Tempparts = HttpUtility.ParseQueryString(TempEDO.GetNamed("SSIDKey").ToString()); try { Double results = 0; Double.TryParse(Tempparts["RawValue"], out results); string Rep = results.ToString("0.#####################################################################################################################################################################################################################################################################################################################################"); if (Rep == null) { throw new Exception(); } FinalString.Replace("$(" + dv + ")", Rep); } catch { try { string Rep = Instance.host.DeviceValueEx(dv).ToString("0.#####################################################################################################################################################################################################################################################################################################################################"); //Problem, device values return as int if (Rep == null) { throw new Exception(); } FinalString.Replace("$(" + dv + ")", Rep); } catch { } } } else //Not an SIID device, use the device value { try { string Rep = Instance.host.DeviceValueEx(dv).ToString(); //Fails for BACnet devices because the status does not reflect the displayed value if (Rep == null) { throw new Exception(); } Double results = 0; Double.TryParse(Rep, out results); Rep = results.ToString("0.#####################################################################################################################################################################################################################################################################################################################################"); FinalString.Replace("$(" + dv + ")", Rep); } catch (Exception E) { Instance.hspi.Log("Error parsing scratchpad string: Could not retrive device value for device: " + dv, 2); } } } foreach (int dv in Processed) { SiidDevice TempDev = SiidDevice.GetFromListByID(Instance.Devices, dv);// (Scheduler.Classes.DeviceClass)Instance.host.GetDeviceByRef(dv); if (TempDev != null) { var TempEDO = TempDev.Extra; var Tempparts = HttpUtility.ParseQueryString(TempEDO.GetNamed("SSIDKey").ToString()); try { string Rep = Tempparts["ProcessedValue"]; if (Rep == null) { throw new Exception(); } FinalString.Replace("#(" + dv + ")", Rep); } catch { try { string Rep = Instance.host.DeviceValueEx(dv).ToString(); if (Rep == null) { throw new Exception(); } FinalString.Replace("#(" + dv + ")", Rep); } catch { } } } else { try { string Rep = Instance.host.DeviceValueEx(dv).ToString(); if (Rep != null) { FinalString.Replace("#(" + dv + ")", Rep); } } catch { } } } return(FinalString.ToString()); }
public MosbusAjaxReceivers(InstanceHolder instance) { Instance = instance; hspi = Instance.hspi; }