void SmartObject_SigChange(GenericBase currentDevice, SmartObjectEventArgs args) { // The control system handles each Smart Object's own signal changes according to its respective Smart Object ID. // The SmartObject_SigChange handler should therefore read this ID via args.SmartObjectArgs.ID to determine // which Smart Object has sent a signal change. From there, the program must use the Number property of the sig // to determine which component of the Smart Object sent the signal try { switch (args.SmartObjectArgs.ID) // which Smart Object? { // The touchpanel uses a Button list Smart Object to display the 5 access levels case SmartObjectIDs.AccessLevelList: if (args.Sig.BoolValue) // only need to process the signal's "rising edge" (click, not the unclick) { LatchButton(args.Sig.Number); switch (args.Sig.Number) // which component of the Smart Object? { case AccessLevelList.Connection: newGroupAccessLevel = Authentication.UserAuthenticationLevelEnum.Connect; break; case AccessLevelList.User: newGroupAccessLevel = Authentication.UserAuthenticationLevelEnum.User; break; case AccessLevelList.Operator: newGroupAccessLevel = Authentication.UserAuthenticationLevelEnum.Operator; break; case AccessLevelList.Programmer: newGroupAccessLevel = Authentication.UserAuthenticationLevelEnum.Programmer; break; case AccessLevelList.Administrator: newGroupAccessLevel = Authentication.UserAuthenticationLevelEnum.Administrator; break; default: newGroupAccessLevel = Authentication.UserAuthenticationLevelEnum.NoAccess; break; } } isAccessLevelChosen = true; break; } } catch (Exception e) { CrestronConsole.PrintLine("Error in SmartObject_SigChange: {0}", e); } finally { } }
// Add a new group to the control system, or print an error message to the touchpanel public bool AddNewGroup(string groupName, Authentication.UserAuthenticationLevelEnum accessLevel) { try { if (!AdminCheck(adminToken)) { panel.StringInput[SerialInputJoins.AddNewGroupErrMsg].StringValue = "You do not have sufficient access to perform this operation"; return(false); } if (!isAccessLevelChosen) { panel.StringInput[SerialInputJoins.AddNewGroupErrMsg].StringValue = "You must choose an access level for this new group"; return(false); } CrestronConsole.PrintLine("Creating group {0} with access level {1} ({2})...\r\n", groupName, accessLevel, (Int32)accessLevel); if (Authentication.AddGroupToSystem(ref adminToken, groupName, accessLevel)) { CrestronConsole.PrintLine("Group \"{0}\" added", groupName); return(true); } panel.StringInput[SerialInputJoins.AddNewGroupErrMsg].StringValue = String.Format("Group \"{0}\" could not be added", groupName); CrestronConsole.PrintLine("Group \"{0}\" could not be added", groupName); return(false); } catch (Exception e) { WriteError("AddNewGroup", e, SerialInputJoins.AddNewGroupErrMsg); return(false); } finally { } }