public static Object[] ValueConvertion(String[] ValueStr) { List <Object> ListValue = new List <Object>(); foreach (String ThisValue in ValueStr) { if (ThisValue == null || ThisValue == "") { return(null); } int ValueInt = 0; Double ValueDouble = 0.0; Boolean ValueBoolean = false; if (ThisValue.Contains(".")) { if (Double.TryParse(ThisValue, out ValueDouble)) { ListValue.Add(ValueDouble); } else { ListValue.Add(ThisValue); } } else if (int.TryParse(ThisValue, out ValueInt)) { ListValue.Add(ValueInt); } else if (Boolean.TryParse(ThisValue, out ValueBoolean)) { ListValue.Add(ValueBoolean); } else { ListValue.Add(ThisValue); } } return(ListValue.ToArray()); }
static public int LogOutputMask(string SwitchString) { int RetVal = 0; if (!String.IsNullOrEmpty(SwitchString)) { string[] OutputSwitch = SwitchString.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string ThisValue in OutputSwitch) { string CapturedSwitch = ThisValue.Trim().ToLower(); Int32 DirectValue = 0; if (Int32.TryParse(CapturedSwitch, out DirectValue)) { RetVal |= DirectValue; } else { string[] EnumNames = Enum.GetNames(typeof(OutputType)); for (int i = 0; i < EnumNames.Length; i++) { if (String.Equals(CapturedSwitch, EnumNames[i], StringComparison.OrdinalIgnoreCase)) { OutputType[] TheValues = (OutputType[])Enum.GetValues(typeof(OutputType)); RetVal |= (int)TheValues[i]; break; } } } } } return(RetVal); }
public static ReturnKnowType VerifyCommand(STATIONNAME StationName, DEVICECATEGORY DeviceCategory, dynamic CommandName, Object[] Value) { if (CommandName == null) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD001) Failed to get command name from list see. (Command name was not avaliable.)")); } TCSCommandStructure ThisCommand = CommandList.FirstOrDefault(Item => Item.StationOwner.Contains(StationName) && Item.DeviceCategory == DeviceCategory && Item.Command.ToString() == CommandName.ToString()); if (ThisCommand != null) { List <String> ValueStr = new List <String>(); foreach (Object ThisValue in Value) { ValueStr.Add(ThisValue.ToString()); } Object[] Values = ValueConvertion(ValueStr.ToArray()); ReturnKnowType ThisReturn = VerifyParameter(ThisCommand, Values); return(ThisReturn); } return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD004) Could not be found commmand (" + CommandName + ") that contain station name : (" + StationName + ") Device Name : (" + DeviceCategory + "). Please check station name or device name.")); }
internal void RefreshChannel(Channel pChannel) { bool found = true; int i = 0; if (pChannel.Function == this.Function) { this.Function = pChannel.Function; } if (this.Function == ChannelFunction.Basic || this.Function == ChannelFunction.Pan || this.Function == ChannelFunction.Tilt) { if (this.mDmxValues != null) { this.mDmxValues.Clear(); } return; } if (this.mDmxValues == null) { this.mDmxValues = new System.Collections.ArrayList(); } foreach (DmxValue ThisValue in mDmxValues) { found = false; foreach (DmxValue pValue in pChannel.DmxValues) { if (pValue.EqualsTo(ThisValue)) { ThisValue.RefreshValue(pValue); found = true; break; } } if (!found) { mDmxValues.Remove(ThisValue); } } foreach (DmxValue pValue in pChannel.DmxValues) { found = false; foreach (DmxValue ThisValue in mDmxValues) { if (pValue.EqualsTo(ThisValue)) { found = true; break; } } if (!found) { mDmxValues.Insert(1, pValue); } i++; } }