/* public void addSSIDExtraData(Scheduler.Classes.DeviceClass Device, string Key, string value) * { * * * var EDO = Device.get_PlugExtraData_Get(Instance.host); * var parts = HttpUtility.ParseQueryString(EDO.GetNamed("SSIDKey").ToString()); * parts[Key] = value; * EDO.RemoveNamed("SSIDKey"); * EDO.AddNamed("SSIDKey", parts.ToString()); * Device.set_PlugExtraData_Set(Instance.host, EDO); * * }*/ public void setValue(CAPI.CAPIControl ActionIn) { var devID = ActionIn.Ref; var newDevice = SiidDevice.GetFromListByID(Instance.Devices, devID); Instance.host.SetDeviceValueByRef(newDevice.Ref, ActionIn.ControlValue, true); Instance.host.SetDeviceString(newDevice.Ref, "" + ActionIn.ControlValue, true); newDevice.UpdateExtraData("ScratchPadString", "" + ActionIn.ControlValue); }
/// <summary> /// for all accumulators: float/double value ///SIID reset accumulator: -1 ///SIID set day of monthly reset: integer between 0 and 28 ///SIID set rate(units per dollar): float between 200 and 1000 (subtract 200 round to 4 decimal places), rate range between 0 and 800 ///SIID fixed cost: Between 1000 and 2000(subtract 1000 round to 4 decmil, range from 0 to 1000) ///For indoor / outdoor water: ///SIID Tiers(4 tiers with boundaries based on AWC or Lotsize), each tier needs an editable rate. /// Tier 1 rate between 2000 and 3000(subtract 2000, round to 4 decmil, range 0 to 1000) /// Tier 2 rate between 3000 and 4000(subtract 3000, round to 4 decmil, range 0 to 1000) /// Tier 3 rate between 4000 and 5000(subtract 4000, round to 4 decmil, range 0 to 1000) ///SIID AWC: Negative number less than - 10(negate, subtract 10) No hardcoded upper range ///SIID LotSize: -Either AWC or LOTSIZE depending on indooor / outdoor, can use the same range for setting /// </summary> /// <param name="ActionIn"></param> public void scratchpadCommandIn(CAPI.CAPIControl ActionIn) { try { var devID = ActionIn.Ref; var newDevice = SiidDevice.GetFromListByID(Instance.Devices, devID); if (ActionIn.ControlValue == -1) { //reset if -1 Reset(newDevice); } else if (ActionIn.ControlValue >= 0 && ActionIn.ControlValue < 35) { newDevice.UpdateExtraData("IsEnabled", "True"); newDevice.UpdateExtraData("IsAccumulator", "True"); newDevice.UpdateExtraData("ResetType", "3"); newDevice.UpdateExtraData("DayOfMonth", "" + Math.Round(ActionIn.ControlValue).ToString() + ""); } else if (ActionIn.ControlValue >= 200 && ActionIn.ControlValue < 1000) { SetRate(newDevice, ActionIn.ControlValue); } else if (ActionIn.ControlValue >= 1000 && ActionIn.ControlValue < 2000) { SetFixedCost(newDevice, ActionIn.ControlValue); } else if (ActionIn.ControlValue >= 2000) { SetTieredRate(newDevice, ActionIn.ControlValue); } else if (ActionIn.ControlValue <= -10) { SetAWC_LotSize(newDevice, ActionIn.ControlValue); } else { //Set to monthly, accumulator, active, with date as value Instance.hspi.Log("Error when parsing scratchpad command: Command was not in a recognised range. \nDevice: " + ActionIn.Ref + " Command: " + ActionIn.ControlValue.ToString(), 2); } } catch (Exception E) { Instance.hspi.Log("Error when parsing scratchpad command " + E.Message + "\nDevice: " + ActionIn.Ref + " Command: " + ActionIn.ControlValue.ToString(), 2); } }
/// <summary> /// Helper for MakeVSpsListControl /// If pair.PairType is SingleRangeEntry - make a range string, i.e. "Dim 30-100%" /// </summary> /// <param name="capi">CAPI.CAPIControl</param> /// <returns></returns> private static MyPair MakePair(CAPI.CAPIControl capi) { string name; object value; if (capi.Range == null) { name = capi.Label; value = capi.ControlValue; } else { value = $"{capi.Range.RangeStart}-{capi.Range.RangeEnd}"; // make a range string, i.e. "Dim 30-100%" name = $"{capi.Range.RangeStatusPrefix}({value}){capi.Range.RangeStatusSuffix}"; } return(new MyPair(name, value)); }