/// <summary> /// Edit a switch registered with the HomeWizard /// </summary> /// <param name="id">Required: Id of the switch</param> /// <param name="name">Required: Name of the switch (max 15 characters)</param> /// <param name="type">Required: Type of the switch</param> public async Task EditSwitch(long id, string name, SwitchType type) { string switchType = type.ToString().ToLowerInvariant(); string urlEncodedName = WebUtility.UrlEncode(CleanName(name)); await GetData("sw/edit/" + id + "/" + urlEncodedName + "/no/" + switchType + "/0"); }
//TODO: Hue lights //command: sw/<switch id>/[on/off]/[0..360]/[0..100]/[0..100] //Control a Hue light. Where the on or off switches the light on or off. The other values are: Hue, Saturation and Brightness in that order. /// <summary> /// Add a switch to the HomeWizard /// </summary> /// <param name="name">Required: Name of the switch (max 15 characters)</param> /// <param name="type">Required: Type of the switch</param> /// <param name="code">Required: Code of the switch</param> /// <returns>Id of the added switch</returns> public async Task <long> AddSwitch(string name, SwitchType type, string code) { string switchType = type.ToString().ToLowerInvariant(); string urlEncodedName = WebUtility.UrlEncode(CleanName(name)); NewSwitch added = await GetData <NewSwitch>("sw/add/" + urlEncodedName + "/" + switchType + "/" + code); return(added.Id); }
void InitSwitch(VPort switchPort, SwitchType switchType, bool isColored) { logger.Log("{0} adding switch {1} {2}", this.ToString(), switchType.ToString(), switchPort.ToString()); SwitchInfo switchInfo = new SwitchInfo(); switchInfo.Capability = GetCapability(switchPort, Constants.UserSystem); switchInfo.Level = 0; switchInfo.Type = switchType; switchInfo.IsColored = isColored; switchInfo.Color = Color.Black; registeredSwitches.Add(switchPort, switchInfo); string switchFriendlyName = switchPort.GetInfo().GetFriendlyName(); switchFriendlyNames.Add(switchFriendlyName, switchPort); if (switchInfo.Capability != null) { IList <VParamType> retVals; if (switchType == SwitchType.Multi) { retVals = switchPort.Invoke(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, null, ControlPort, switchInfo.Capability, ControlPortCapability); switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability); if (retVals[0].Maintype() < 0) { logger.Log("SwitchController could not get current level for {0}", switchFriendlyName); } else { switchInfo.Level = (double)retVals[0].Value(); } } else { retVals = switchPort.Invoke(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, null, ControlPort, switchInfo.Capability, ControlPortCapability); switchPort.Subscribe(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability); if (retVals[0].Maintype() < 0) { logger.Log("SwitchController could not get current level for {0}", switchFriendlyName); } else { bool boolLevel = (bool)retVals[0].Value(); switchInfo.Level = (boolLevel) ? 1 : 0; } } } }
public string GetDefinitionObjects() { string message = ""; string typeSwitch = ""; if (type == SwitchType.init) { typeSwitch = "switch"; } else { typeSwitch = type.ToString(); } message += name + " - " + typeSwitch; return(message); }
public override void WriteXml(XmlWriter writer) { base.WriteXml(writer); writer.WriteElementString("SwitchType", SwitchType.ToString()); writer.WriteElementString("Orientation", Orientation.ToString()); writer.WriteElementString("ClickType", ClickType.ToString()); writer.WriteElementString("PositionOneImage", PositionOneImage); writer.WriteElementString("PositionTwoImage", PositionTwoImage); if (HasIndicator) { writer.WriteStartElement("Indicator"); writer.WriteElementString("PositionOneImage", PositionOneIndicatorOnImage); writer.WriteElementString("PositionTwoImage", PositionTwoIndicatorOnImage); writer.WriteEndElement(); } writer.WriteElementString("DefaultPosition", DefaultPosition.ToString()); }
public override void WriteXml(System.Xml.XmlWriter writer) { base.WriteXml(writer); writer.WriteElementString("SwitchType", SwitchType.ToString()); writer.WriteElementString("Orientation", Orientation.ToString()); writer.WriteElementString("ClickType", ClickType.ToString()); writer.WriteStartElement("GuardUp"); writer.WriteElementString("PositionOneImage", PositionOneGuardUpImage); writer.WriteElementString("PositionTwoImage", PositionTwoGuardUpImage); writer.WriteEndElement(); writer.WriteStartElement("GuardDown"); writer.WriteElementString("PositionOneImage", PositionOneGuardDownImage); writer.WriteElementString("PositionTwoImage", PositionTwoGuardDownImage); writer.WriteEndElement(); writer.WriteElementString("DefaultPosition", DefaultPosition.ToString()); writer.WriteElementString("DefaultGuardPosition", DefaultGuardPosition.ToString()); }
public override void WriteXml(System.Xml.XmlWriter writer) { base.WriteXml(writer); writer.WriteElementString("SwitchType", SwitchType.ToString()); writer.WriteElementString("Orientation", Orientation.ToString()); writer.WriteElementString("ClickType", ClickType.ToString()); writer.WriteStartElement("GuardUp"); writer.WriteElementString("PositionOneImage", PositionOneGuardUpImage); writer.WriteElementString("PositionTwoImage", PositionTwoGuardDownImage);// writing this value just for compatibility with old profiles writer.WriteEndElement(); writer.WriteStartElement("GuardDown"); writer.WriteElementString("PositionOneImage", PositionOneGuardUpImage);// writing this value just for compatibility with old profiles writer.WriteElementString("PositionTwoImage", PositionTwoGuardDownImage); writer.WriteEndElement(); writer.WriteElementString("DefaultPosition", "Two"); // writing this value just for compatibility with old profiles writer.WriteElementString("DefaultGuardPosition", DefaultGuardPosition.ToString()); }
/// <summary> /// For the ScanIT application type the lightkey command will light the key fob or key position /// associated with specified key serial number or position. Most common usage is to provide user /// feedback on key selection options. The ability to turn a key fob or position light off is also provided. /// </summary> /// <param name="type">on|off</param> /// <param name="pos">Position number of asset</param> /// <param name="userId">User ID of user to be assigned to removed assets (SKD application only)</param> /// <param name="keyList">"-" range operator and "," delimiter for key or range list</param> /// <param name="log">on|off</param> /// <param name="keySerialNumber">Key serial number of key fob or position to be lit</param> /// <returns>KSI string command</returns> public static string LightKey(int pos , SwitchType type = SwitchType.On , string userId = null , string keyList = null , SwitchType?log = null , string keySerialNumber = null ) { var sb = new StringBuilder(); sb.Append($"<lightkey type={type.ToString().ToLower()} pos={pos}"); if (!string.IsNullOrWhiteSpace(userId)) { sb.Append($" userid={userId}"); } if (!string.IsNullOrWhiteSpace(keyList)) { sb.Append($" keylist={keyList}"); } if (log != null) { sb.Append($" log={log.ToString().ToLower()}"); } if (!string.IsNullOrWhiteSpace(keySerialNumber)) { sb.Append($">{keySerialNumber}</lightkey>"); } else { sb.Append($"></lightkey>"); } return(sb.ToString()); }
public Keyboard(String producer, String name, String colour, SwitchType switchType, bool isFullSize) : base(producer, name, colour) { this.SwitchType = switchType.ToString(); this.isFullSize = isFullSize; }
void InitSwitch(VPort switchPort, SwitchType switchType, bool isColored) { logger.Log("{0} adding switch {1} {2}", this.ToString(), switchType.ToString(), switchPort.ToString()); SwitchInfo switchInfo = new SwitchInfo(); switchInfo.Capability = GetCapability(switchPort, Constants.UserSystem); switchInfo.Level = 0; switchInfo.Type = switchType; switchInfo.IsColored = isColored; switchInfo.Color = Color.Black; registeredSwitches.Add(switchPort, switchInfo); string switchFriendlyName = switchPort.GetInfo().GetFriendlyName(); switchFriendlyNames.Add(switchFriendlyName, switchPort); if (switchInfo.Capability != null) { IList<VParamType> retVals; if (switchType == SwitchType.Multi) { retVals = switchPort.Invoke(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, null, ControlPort, switchInfo.Capability, ControlPortCapability); switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability); if (retVals[0].Maintype() < 0) { logger.Log("SwitchController could not get current level for {0}", switchFriendlyName); } else { switchInfo.Level = (double)retVals[0].Value(); } } else { retVals = switchPort.Invoke(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, null, ControlPort, switchInfo.Capability, ControlPortCapability); switchPort.Subscribe(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability); if (retVals[0].Maintype() < 0) { logger.Log("SwitchController could not get current level for {0}", switchFriendlyName); } else { bool boolLevel = (bool)retVals[0].Value(); switchInfo.Level = (boolLevel) ? 1 : 0; } } //fix the color up now if (isColored) { var retValsColor = switchPort.Invoke(RoleLightColor.RoleName, RoleLightColor.OpGetName, null, ControlPort, switchInfo.Capability, ControlPortCapability); switchPort.Subscribe(RoleLightColor.RoleName, RoleLightColor.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability); if (retVals[0].Maintype() < 0) { logger.Log("SwitchController could not get color for {0}", switchFriendlyName); } else { byte red, green, blue; red = Math.Min(Math.Max((byte)(int)retValsColor[0].Value(), (byte)0), (byte)255); green = Math.Min(Math.Max((byte)(int)retValsColor[1].Value(), (byte)0), (byte)255); blue = Math.Min(Math.Max((byte)(int)retValsColor[2].Value(), (byte)0), (byte)255); switchInfo.Color = Color.FromArgb(red, green, blue); } } } }