/// <summary> /// Constructor of the Control System Class. Make sure the constructor always exists. /// If it doesn't exit, the code will not run on your 3-Series processor. /// </summary> public ControlSystem() : base() { // subscribe to control system events CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should // define the max number of threads which we will use in the system. // the right number depends on your project; do not make this number unnecessarily large Thread.MaxNumberOfUserThreads = 20; // ensure this processor has ethernet if (this.SupportsEthernet) { // create new dmtx401c object and subscribe to its events dmTx = new DmTx401C(0x03, this); // IPID for the dmtx is 3 dmTx.BaseEvent += dmTx_BaseEvent; dmTx.HdmiInput.InputStreamChange += HdmiInput_InputStreamChange; dmTx.HdmiInput.VideoAttributes.AttributeChange += Hdmi_AttributeChange; dmTx.VgaInput.InputStreamChange += VgaInput_InputStreamChange; dmTx.VgaInput.VideoAttributes.AttributeChange += Vga_AttributeChange; dmTx.DisplayPortInput.InputStreamChange += DisplayPortInput_InputStreamChange; dmTx.DisplayPortInput.VideoAttributes.AttributeChange += DisplayPort_AttributeChange; dmTx.OnlineStatusChange += Device_OnlineStatusChange; // create new tt100 object using the dmtx401 constructor, and subscribe to its events connectIt = new Tt1xx(dmTx); connectIt.ButtonStateChange += connectIt_ButtonStateChange; connectIt.OnlineStatusChange += Device_OnlineStatusChange; // register the dmtx to this program, the tt100 will be registered as part of the dmtx if (dmTx.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> The DM-TX-401-c has been registered successfully"); else ErrorLog.Error(">>> The DM-TX-401-C was not registered: {0}", dmTx.RegistrationFailureReason); // create new dmrmc100c object and subscribe to its events dmRmc = new DmRmcScalerC(0x04, this); // IPID for the dmtx is 4 dmRmc.DmInput.InputStreamChange += DmRmc_InputStreamChange; dmRmc.ComPorts[1].SerialDataReceived += DmRmc_SerialDataReceived; dmRmc.OnlineStatusChange += Device_OnlineStatusChange; dmRmc.Scaler.OutputChange += Scaler_OutputChange; // register device with the control system if (dmRmc.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> The DM-RMC-Scaler-C has been registered successfully"); else ErrorLog.Error(">>> The DM-RMC-Scaler-C was not registered: {0}", dmRmc.RegistrationFailureReason); // create a new xpanel room object and subscribe to its events xPanelUi = new XpanelForSmartGraphics(0x0b, this); xPanelUi.SigChange += xPanelUi_SigChange; xPanelUi.OnlineStatusChange += Device_OnlineStatusChange; // pathway to the SGD file for this ui project string xPanelSgdFilePath = string.Format("{0}\\Config.Standalone.sgd", Directory.GetApplicationDirectory()); // make sure file exists in the application directory if (File.Exists(xPanelSgdFilePath)) { // load the SGD file for this ui project xPanelUi.LoadSmartObjects(xPanelSgdFilePath); // create reference for the various smart objects in the ui project dmRmcOutputResList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcOutputResList]; dmRmcAspectModeList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcAspectList]; dmRmcUnderscanList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcUnderscanList]; // subscribe to the smart object sig events dmRmcOutputResList.SigChange += dmRmcOutputResList_SigChange; dmRmcAspectModeList.SigChange += dmRmcAspectModeList_SigChange; dmRmcUnderscanList.SigChange += dmRmcUnderscanList_SigChange; } else { ErrorLog.Error(">>> Could not find xpanel SGD file. SmartObjects will not work at this time"); } // register device with the control system if (xPanelUi.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> xPanel has been registered successfully"); else ErrorLog.Error(">>> xPanel was not registered: {0}", xPanelUi.RegistrationFailureReason); } else { ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run"); } // create a new timer object to track system inactivity or unplugged cables ShutdownTimer = new CTimer(ShutownTimerCallback, Timeout.Infinite, Timeout.Infinite); }
public DummyEvent1( float foo, SmartObject obj1, SmartObject obj2) : base(obj1, obj2) { }
/// <summary> /// Highlight the given object. /// </summary> public void Highlight(SmartObject obj) { if (obj is SmartCrowd) { IEnumerable<SmartObject> objects = ((SmartCrowd)obj).GetObjects(); foreach (SmartObject o in objects) { Highlight(o); } return; } //Preferrably use improved highlighting system, but use old one as fallback Highlight highlight = obj.GetComponent<Highlight>(); if (highlight != null) { highlight.SelectOn(); currentHighlights.Add(highlight); } else { HaloHighlight halo = GetHalo(currentIndex++); halo.TargetTransform = obj.gameObject.transform; halo.haloEnabled = true; } }
public static void ServerRequest(SmartObject obj, string type) { Debug_Console.i.add("Server Request about to send, " + (int) Networking.PrimarySocket.Me.NetworkId); obj.AddString("type", type); obj.AddInt("sender", (int) Networking.PrimarySocket.Me.NetworkId); BMSByte byt = EasySerialization.EasySerialize(obj); Networking.WriteCustom(EventHelper.GetEventId("ServerRequest"), login_server_port, byt, NetworkReceivers.Server); }
public TestSmartEvent( SmartObject obj1, SmartObject obj2) : base(obj1, obj2) { // Don't need to actually do anything with obj1 or obj2 since // they don't do anything during the event itself, just need // to occupy them }
public static Node MoveZones( SmartObject mover, SmartObject fromZone, SmartObject toZone) { return new Sequence( mover.Node_Set(fromZone.Id, ~RelationName.IsInZone), mover.Node_Set(toZone.Id, RelationName.IsInZone)); }
public LeafAffordance( Val<string> affordance, Val<SmartObject> user, Val<SmartObject> obj) { this.affordance = affordance.Value; this.user = user.Value; this.obj = obj.Value; }
public void AttemptLogin() { string username = username_view.text; string password = password_view.text; SmartObject request_object = new SmartObject(); request_object.AddString("username", username); request_object.AddString("password", password); LoginServerController.ServerRequest(request_object, "Login"); }
protected Node StopLookAt(SmartObject user) { SmartCharacter character = (SmartCharacter)user; return new Sequence( this.Node_Require(StateName.RoleAttraction), character.Node_Require(StateName.RoleActor), character.Node_HeadLookStop() ); }
void Start() { if (MousePick.instance != null) { MousePick.instance.AddReceiver(this); } if (this.ParentObject == null) this.ParentObject = transform.parent.GetComponent<SmartObject>(); this.highlight = this.ParentObject.GetComponent<Highlight>(); }
public void ProcessUpdateEntities(Entity_Model[] updated_entities) { SmartObject obj = new SmartObject(); SmartObject updates = new SmartObject(); for(int i = 0; i < updated_entities.Length; i++) { updates.AddEntity("Entity_" + i, updated_entities[i]); } updates.AddInt("length", updated_entities.Length); obj.AddSmartObject("Updates", updates); Networking.WriteCustom(EventHelper.GetEventId("PROCESS_ENTITES"), socket, EasySerialization.EasySerialize(obj), true, NetworkReceivers.All); }
void ServerRequest(SmartObject response_object, ulong sender) { switch(response_object.GetString("type")) { case "Login": UserLogin(response_object, sender); break; case "Register": RegisterUser(response_object, sender); break; } }
protected Node MoveAndLookAt(SmartObject user) { SmartCharacter character = (SmartCharacter)user; return new Sequence( this.Node_Require(StateName.RoleAttraction), character.Node_Require(StateName.RoleActor, StateName.IsStanding), character.Node_GoTo(lookAtStandPoint.position), LookAt(character) ); }
public void LoginResponse(SmartObject obj) { string response = obj.GetString("response"); Debug_Console.i.add(response); if(response == "0") { Debug.Log("Failed to log in"); } else if(response == "1") { Debug.Log("Logged in"); hide_onfinish.SetActive(false); show_onfinish.SetActive(true); } }
public void AttemptRegister() { string username = username_view.text; string password = password_view.text; string email = email_view.text; SmartObject request_object = new SmartObject(); request_object.AddString("username", username); request_object.AddString("password", password); request_object.AddString("email", email); LoginServerController.ServerRequest(request_object, "Register"); }
public void RunAffordance(SmartObject obj, string name) { if (this.busy == false) { this.obj = obj; this.curAffordance = name; this.busy = true; } else { MousePick.instance.PlayFailed(); Debug.LogWarning("Too busy for " + obj + " : " + name); } }
public static bool Attempt_Rotate_Entity(Entity entity, Vector3 target) { if(Network_Command_Manager.instance.socket.IsServer) { LocalRotateEntity(entity, target); return true; } else { SmartObject obj = new SmartObject(); obj.AddString("type", "ROTATE_ENTITY"); obj.AddEntity("Entity", entity.entity_model); obj.AddVec3("Target", target); Network_Command_Manager.instance.ToNetController<Client_Controller>().SendRequest(obj); return false; } }
void RegisterUser(SmartObject obj, ulong sender) { string username = obj.GetString("username"); string password = obj.GetString("password"); string email = obj.GetString("email"); HTTP http = new HTTP("http://www.turnofwar.com/game/newuser.php"); http.Get((responses) => { Debug_Console.i.add((string) responses); SmartObject response_obj = new SmartObject(); response_obj.AddString("type", "Register"); response_obj.AddString("response", (string) responses); response_obj.AddInt("sender", (int) Networking.PrimarySocket.Me.NetworkId); Networking.WriteCustom(EventHelper.GetEventId("ServerResponse"), socket, EasySerialization.EasySerialize(response_obj), GetNetPlayer(sender), true); }, new string[3] { "username="******"password="******"email=" + email }); }
public void RegisterResponse(SmartObject obj) { string response = obj.GetString("response"); Debug_Console.i.add(response); if(response == "0") { } else if(response == "1") { MainThreadManager.Run(() => { hide_onfinish.SetActive(false); show_onfinish.SetActive(true); }); } else if(response == "2") { Debug.Log("Account already exists"); } }
void Update() { if (this.curAffordance != null && this.obj != null) { RunStatus status = this.obj.RunAffordance(curAffordance, this.user); if (status != RunStatus.Running) { if (status == RunStatus.Failure) { MousePick.instance.PlayFailed(); Debug.LogWarning("Failed " + this.obj + " : " + this.curAffordance); } this.curAffordance = null; this.obj = null; this.busy = false; } } }
public void NoResponseEventShouldBeSendForFunctionCall() { var mockWebsocketInterface = new MockWebsocketInterface(); mockWebsocketInterface.Start(); var testMsbClient = new MsbClient(mockWebsocketInterface.URL); var testSmartObject = new SmartObject(Guid.NewGuid().ToString(), "Name", "Description", Guid.NewGuid().ToString()); var responseEventWhichShouldNotBeSend = new Event("ResponseEventWhichShouldNotBeSend", "", "", null); testSmartObject.AddEvent(responseEventWhichShouldNotBeSend); var testFunction = new Function(this.GetType().GetRuntimeMethod("NoResponseEventShouldBeSendForFunctionCallMsbFunction", new Type[] { typeof(FunctionCallInfo) }), this); testSmartObject.AddFunction(testFunction); Assert.True(testMsbClient.ConnectAsync().Result); Assert.True(testMsbClient.RegisterAsync(testSmartObject).Result); string functionCallJson = $@"{MessageType.FUNCTION_CALLBACK} {{ ""uuid"" : ""{testSmartObject.Uuid}"", ""correlationId"" : ""{Guid.NewGuid().ToString()}"", ""functionId"" : ""NoResponseEventShouldBeSendForFunctionCallMsbFunction"", ""functionParameters"" : {{ }} }}"; try { var raisedEvent = Assert.RaisesAnyAsync <EventArgs>( h => testMsbClient.EventPublished += h, h => testMsbClient.EventPublished -= h, () => Task.Run(() => { mockWebsocketInterface.SendMessageOfType(functionCallJson); Thread.Sleep(100); })).Result; } catch (AggregateException e) { Assert.Contains("No event was raised", e.InnerException.Message); } }
public void PrimtiveFunctionParameterConversion_Integers() { var mockWebsocketInterface = new MockWebsocketInterface(); mockWebsocketInterface.Start(); var testMsbClient = new MsbClient(mockWebsocketInterface.URL); var testSmartObject = new SmartObject(Guid.NewGuid().ToString(), "Name", "Description", Guid.NewGuid().ToString()); var testFunction = new Function(this.GetType().GetRuntimeMethod("TestFunction", new Type[] { typeof(int), typeof(FunctionCallInfo) }), this); testSmartObject.AddFunction(testFunction); Assert.True(testMsbClient.ConnectAsync().Result); Assert.True(testMsbClient.RegisterAsync(testSmartObject).Result); string functionCallJson = $@"{MessageType.FUNCTION_CALLBACK} {{ ""uuid"" : ""{testSmartObject.Uuid}"", ""correlationId"" : ""{Guid.NewGuid().ToString()}"", ""functionId"" : ""TestFunction"", ""functionParameters"" : {{ ""testParameter"" : 1234 }} }}"; mockWebsocketInterface.SendMessageOfType(functionCallJson); var maxPollTries = 10; for (int i = 0; i < maxPollTries; i++) { if (this.testFunctionCallReceived) { break; } else { Thread.Sleep(50); } } Assert.True(this.testFunctionCallReceived); }
public void ConfigurationParameterReceived() { SmartObject testSmartObject = new SmartObject("6e93a348-35cc-4fe1-b6fa-7015787dec61", "Name", "Description", "Token"); string serviceUuid = testSmartObject.Uuid; string parameterName = "testParameter"; object parameterValue = 43536; Assert.True(this.testMsbClient.ConnectAsync().Result); Assert.True(this.testMsbClient.RegisterAsync(testSmartObject).Result); var raisedEvent = Assert.RaisesAnyAsync <ConfigurationParameterReceivedEventArgs>( h => this.testMsbClient.ConfigurationParameterReceived += h, h => this.testMsbClient.ConfigurationParameterReceived -= h, () => Task.Run(() => { this.mockWebsocketInterface.SendConfigurationParameter(serviceUuid, parameterName, parameterValue); Thread.Sleep(100); })).Result; Assert.IsType <ConfigurationParameterReceivedEventArgs>(raisedEvent.Arguments); Assert.Equal(testSmartObject, raisedEvent.Arguments.Service); raisedEvent.Arguments.Value.Should().Contain(new KeyValuePair <string, object>(parameterName, parameterValue)); }
public void EventCached() { Event testEvent = new Event("Id", "Name", "Description", typeof(string)); EventData testEventData = new EventDataBuilder(testEvent).Build(); SmartObject testSmartobject = new SmartObject("Id", "Name", "Description", "Token"); testSmartobject.AddEvent(testEvent); Assert.True(this.testMsbClient.ConnectAsync().Result); Assert.True(this.testMsbClient.RegisterAsync(testSmartobject).Result); this.testMsbClient.Disconnect(); var raisedEvent = Assert.RaisesAnyAsync <EventArgs>( h => this.testMsbClient.EventCached += h, h => this.testMsbClient.EventCached -= h, () => Task.Run(() => { Assert.False(this.testMsbClient.PublishAsync(testSmartobject, testEventData).Result); Thread.Sleep(100); })).Result; Assert.IsType <EventArgs>(raisedEvent.Arguments); }
public SmartObjectDynamicListHelper(SmartObject smartObject, SmartObjectDynamicListHelperParameters helperParams) : base(smartObject, helperParams) { MaxNumberOfItems = (ushort)_smartObject.BooleanOutput.Count(s => s.Name.EndsWith("Pressed")); _items = new Dictionary <uint, SmartObjectDynamicListItem>(MaxNumberOfItems); for (uint i = 1; i <= MaxNumberOfItems; i++) { _items.Add(i, new SmartObjectDynamicListItem(this, i)); } Items = new ReadOnlyDictionary <uint, SmartObjectDynamicListItem>(_items); NumberOfItems = helperParams.NumberOfItems; if (helperParams.NumberOfItems > MaxNumberOfItems) { throw new ArgumentOutOfRangeException("helperParams.NumberOfItems", "Only " + MaxNumberOfItems + " items defined in the SGD file"); } else { NumberOfItems = helperParams.NumberOfItems; } }
/// <summary> /// Implements <see cref="Mnubo.SmartObjects.Client.IObjectClient.CreateAsync" /> /// </summary> public async Task CreateAsync(SmartObject smartObject) { if (smartObject == null) { throw new ArgumentException("SmartObject body cannot be null."); } if (string.IsNullOrEmpty(smartObject.DeviceId)) { throw new ArgumentException("x_device_id cannot be blank."); } if (string.IsNullOrEmpty(smartObject.ObjectType)) { throw new ArgumentException("x_object_type cannot be blank."); } await client.sendAsyncRequest( HttpMethod.Post, "objects", ObjectSerializer.SerializeObject(smartObject)); }
public UIDynamicButtonList(UIControllerWithSmartObjects uiController, SmartObject smartObject) { _uiController = uiController; _smartObject = smartObject; _smartObject.SigChange += SmartObjectOnSigChange; CloudLog.Debug("{0}.ctor for SmartObject ID: {1}", GetType(), smartObject.ID); try { uint count = 1; while (true) { var name = string.Format("Item {0} Visible", count); if (_smartObject.BooleanInput.Contains(name)) { count++; } else { break; } } _maxNumberOfItems = count - 1; CloudLog.Debug("{0} for SmartObject ID: {1} contains {2} items", GetType(), smartObject.ID, _maxNumberOfItems); for (uint i = 1; i <= _maxNumberOfItems; i++) { _items[i] = new UIDynamicButtonListItem(this, i); } } catch (Exception e) { CloudLog.Exception(e, "Error in {0}.ctor, {1}", GetType().Name, e.Message); } }
public override void Setup(ref NetWorker socket) { base.Setup(ref socket); socket.AddCustomDataReadEvent(EventHelper.GetEventId("SERVER_REQUEST"), ReadRequest); // socket.AddCustomDataReadEvent ("COMBAT_REGISTER", ReadCombatRegister); SmartObject obj = new SmartObject(); SmartObject add = new SmartObject(); Client_Model[] players = Turn_Controller.instance.server_players.players.ToArray(); int entity_count = 0; for(int i = 0; i < players.Length; i++) { Entity_Model_Army army = Entity_Model_Army.GenerateRandomArmy(ref players[i], 2); for(int i2 = 0; i2 < army.entity_army.Length; i2++) { add.AddEntity("Entity_" + entity_count, army.entity_army[i2]); entity_count++; } } Debug_Console.i.add("Host controller setup"); add.AddInt("length", entity_count); obj.AddSmartObject("Additions", add); BMSByte bms_byte = EasySerialization.EasySerialize(obj); StartCoroutine("Delayed", bms_byte); }
// public static void Rotate_Entity(Entity entity, Vector3 target){ // target = target - entity.transform.position; // target = new Vector3 (target.x, 0, target.z); // Quaternion look_rotation = Quaternion.LookRotation (target); // entity.transform.rotation = look_rotation; // } public static void Attempt_Move_Entity(Entity entity, Vector3 target, System.Action<Entity_Model> action = null) { if(Network_Command_Manager.instance.socket.IsServer) { Seeker seeker = entity.GetComponent<Seeker>(); seeker.StartPath(seeker.transform.position, target, delegate (Path path) { Vector3[] vecp = path.vectorPath.ToArray(); if(vecp.Length > 1) { Quaternion rotation; Vector3 destination; float moved; PathFindAlong(entity.entity_model.stats.movement, vecp, out moved, out rotation, out destination); entity.entity_model.stats.movement -= moved; if(entity.entity_model.stats.movement < 0.1f) entity.entity_model.stats.movement = 0; if(moved <= 0) return; entity.transform.rotation = rotation; entity.transform.position = destination; entity.entity_model.pos = new Vector3_Serial(entity.transform.position); entity.transform.rotation = Quaternion.Euler(new Vector3(0, entity.transform.rotation.eulerAngles.y, 0)); entity.entity_model.rot = new Vector3_Serial(entity.transform.rotation.eulerAngles); action(entity.entity_model); } }); } else { SmartObject obj = new SmartObject(); obj.AddString("type", "MOVE_ENTITY"); Debug.Log("sending move request"); Debug.Log(target); obj.AddEntity("Entity", entity.entity_model); obj.AddVec3("Target", target); Network_Command_Manager.instance.ToNetController<Client_Controller>().SendRequest(obj); } }
void ServerResponse(SmartObject response_object) { Debug_Console.i.add(response_object.GetString("type")); Debug_Console.i.add(response_object.GetString("response")); switch(response_object.GetString("type")) { case "Login": /* *[type] *[username] *[password] */ LoginMenuController.instance.LoginResponse(response_object); break; case "Register": /* *[type] *[username] *[password] *[email] */ RegisterMenuController.instance.RegisterResponse(response_object); break; } }
private string getTaxData() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); SmartObjectClientServer smoServer = ConnectionClass.GetSmartObjectClient(); SmartObject mmdSmo = smoServer.GetSmartObject(this.SMOInternalName); SmartListMethod getList = mmdSmo.ListMethods["GetAllChildTermsInTermSet"]; getList.InputProperties["TermStoreId"].Value = this.TermStoreGuid; getList.InputProperties["TermSetId"].Value = this.TermSetGuid; mmdSmo.MethodToExecute = "GetAllChildTermsInTermSet"; var TermList = new List <Term>(); SmartObjectList smoList = smoServer.ExecuteList(mmdSmo); foreach (SmartObject smo in smoList.SmartObjectsList) { string termId = smo.Properties["TermId"].Value; string termLabel = smo.Properties["Label"].Value; string termPath = smo.Properties["Path"].Value; TermList.Add(new Term() { TermId = termId, TermLabel = termLabel, TermPath = termPath }); } var serializer = new JavaScriptSerializer(); var serialized = serializer.Serialize(TermList); var fixedString = serialized.Replace(""", @""""); sb.Append(@"{""terms"":"); sb.Append(fixedString); sb.Append(@"}"); return(HttpUtility.HtmlDecode(sb.ToString())); }
public static void AllInOneSample() { const string MsbWebsocketInterfaceUrl = "ws://localhost:8085"; const string MyMsbSmartObjectUuid = "1a17b5e3-3a6a-4e62-97b0-82cfdd1cc818"; const string MyMsbSmartObjectName = "C# Sample SmartObject"; const string MyMsbSmartObjectDescription = "Description of my C# sample SmartObject"; const string MyMsbSmartObjectToken = "30e47482-c140-49a9-a79f-6f2396d8e0ab"; const string MyMsbApplicationUuid = "46441dc8-c3ab-4c93-9632-d1f356afb8ca"; const string MyMsbApplicationName = "C# Sample Application"; const string MyMsbApplicationDescription = "Description of my C# sample Application"; const string MyMsbApplicationToken = "5b6b273b-18ff-420b-bbff-5f40288c18f9"; // Create a new MsbClient which allows SmartObjects and Applications to communicate with the MSB MsbClient myMsbClient = new MsbClient(MsbWebsocketInterfaceUrl); // Create the self description of a sample SmartObject and a sample Application SmartObject myMsbSmartObject = new SmartObject(MyMsbSmartObjectUuid, MyMsbSmartObjectName, MyMsbApplicationDescription, MyMsbSmartObjectToken); Application myMsbApplication = new Application(MyMsbApplicationUuid, MyMsbApplicationName, MyMsbSmartObjectDescription, MyMsbApplicationToken); // Add configuration parameters myMsbSmartObject.AddConfigurationParameter("sampleParameter1", new ConfigurationParameterValue(1337)); myMsbSmartObject.AddConfigurationParameter("sampleParameter2", new ConfigurationParameterValue("SampleValue")); // Add events Event simpleEvent = new Event("SimpleEventId", "Name of simple event", "Event with simple data format", typeof(string)); Event flatEvent = new Event("FlatEventId", "Name of flat event", "Event with flat data format", typeof(Events.SimpleEvent)); Event complexEvent = new Event("ComplexEventId", "Name of complex event", "Event with nested data format", typeof(Events.ComplexEvent)); myMsbSmartObject.AddEvent(simpleEvent); myMsbSmartObject.AddEvent(flatEvent); myMsbSmartObject.AddEvent(complexEvent); myMsbApplication.AddEvent(simpleEvent); myMsbApplication.AddEvent(flatEvent); myMsbApplication.AddEvent(complexEvent); // Add functions SampleFunctionHandler simpleFunctions = new SampleFunctionHandler(); myMsbSmartObject.AddFunctionHandler(simpleFunctions); // Connect to the MSB and register the sample SmartObject and sample Application via the MsbClient myMsbClient.ConnectAsync().Wait(); myMsbClient.RegisterAsync(myMsbSmartObject).Wait(); myMsbClient.RegisterAsync(myMsbApplication).Wait(); // Publish events while (true) { EventData eventData_SimpleEvent = new EventDataBuilder(simpleEvent).SetValue("TestString").Build(); myMsbClient.PublishAsync(myMsbSmartObject, eventData_SimpleEvent).Wait(); EventData eventData_FlatEvent = new EventDataBuilder(flatEvent).SetValue(new Events.SimpleEvent()).Build(); myMsbClient.PublishAsync(myMsbSmartObject, eventData_FlatEvent).Wait(); EventData eventData_ComplexEvent = new EventDataBuilder(complexEvent).SetValue(new Events.ComplexEvent()).Build(); myMsbClient.PublishAsync(myMsbSmartObject, eventData_ComplexEvent).Wait(); Thread.Sleep(3000); } }
void Start() { this.user = this.GetComponent<SmartCharacter>(); }
/// <summary> /// Calculates the level of a given Smart Object, by looking at the levels of /// the events where it is involved with. /// </summary> private void CalculateLevel(SmartObject obj) { int max = DEFAULT_LEVEL; foreach (EventStub evnt in involvedObjectToEvents[obj]) { max = Mathf.Max(max, GetLevelForEvent(evnt)); } levelsForObjects[obj] = max; }
/// <summary> /// Gets the set of events the given SmartObject is involved in (as an involved object, but not necessarily as /// a participant). Returns an empty set if it isn't involved in any events. /// </summary> public HashSet<EventStub> GetInvolvedInEvents(SmartObject obj) { if (!involvedObjectToEvents.ContainsKey(obj)) { involvedObjectToEvents[obj] = new HashSet<EventStub>(); } return involvedObjectToEvents[obj]; }
public World() { _importantThing = new SmartObject("Important thing", AIDomainSlots.HighPriority); }
public AudioFaderList(UIControllerWithSmartObjects uiController, SmartObject smartObject) : base(uiController, smartObject, 7, 7, 2, (list, index) => new AudioFaderListItem(list, index)) { }
public static void SetFilter(this SmartObject smartObject, LogicalFilter filter) { var listMethod = smartObject.GetExecutingMethod() as SmartListMethod; listMethod.Filter = filter; }
public static string GetReturnPropertyValue(this SmartObject smartObject, string propertyName = null) { var smartProperty = GetReturnProperty(smartObject, propertyName); return(smartProperty.Value); }
public UISmartObjectTabBar(SmartObject smartObject, BoolInputSig objectEnableJoin, BoolInputSig objectVisibleJoin) : this(smartObject) { this.EnableJoin = objectEnableJoin; this.VisibleJoin = objectVisibleJoin; }
public void Create(SmartObject smartObject) { ClientUtils.WaitTask(CreateAsync(smartObject)); }
public virtual SmartObjectReader ExecuteListReader(SmartObject smartObject, ExecuteListReaderOptions options) { return(_serviceClientServer.ExecuteListReader(smartObject, options)); }
public virtual SmartObject ExecuteScalar(SmartObject smartObject) { return(_serviceClientServer.ExecuteScalar(smartObject)); }
/// <summary> /// Create a basic smart object button with dynamic text /// </summary> /// <param name="smartObject">The smartobject extender</param> /// <param name="pressJoinName">The join name of the smart object push</param> /// <param name="feedbackJoinName">The join name of the smart object feedback</param> /// <param name="serialJoinName">The set text join name of the smart object</param> public VolumeMuteButton(SmartObject smartObject, string pressJoinName, string feedbackJoinName, string serialJoinName) : base(smartObject, pressJoinName, feedbackJoinName, serialJoinName) { }
public SmartObjectDynamicButtonIconListHelper(SmartObject smartObject, SmartObjectDynamicListHelperParameters helperParams) : base(smartObject, helperParams) { }
static void Main(string[] args) { SmartObjectClientServer server = new SmartObjectClientServer(); try { SCConnectionStringBuilder cb = new SCConnectionStringBuilder(); cb.Host = "DLX"; cb.Port = 5555; cb.Integrated = true; cb.IsPrimaryLogin = true; //Connect to server server.CreateConnection(); server.Connection.Open(cb.ToString()); //-------------------------- //Get the Employee //Get SmartObject Definition SmartObject employee = server.GetSmartObject("Employee"); //Set properties employee.Properties["ID"].Value = "2"; //Get the record employee.MethodToExecute = "FindEmployee"; server.ExecuteScalar(employee); System.Diagnostics.Trace.WriteLine( employee.Properties["FirstName"].Value); System.Diagnostics.Trace.WriteLine( employee.Properties["LastName"].Value); System.Diagnostics.Trace.WriteLine( employee.Properties["Email"].Value); } catch (Exception ex) { throw new Exception("Error Creating Request >> " + ex.Message); } }
/// <summary> /// Gets the list of events the given SmartObject participates in (as a participant). If it does not exist, /// returns an empty list. Does not return null. /// </summary> public HashSet<EventStub> GetParticipatingEvents(SmartObject obj) { if (!participantToEvents.ContainsKey(obj)) { participantToEvents[obj] = new HashSet<EventStub>(); } return participantToEvents[obj]; }
public UIGuage(SmartObject smartObject, string analogFeedbackJoinName) : base(smartObject) { AnalogFeedbackJoin = smartObject.UShortInput[analogFeedbackJoinName]; }
/// <summary> /// Returns the level of the given object. If the object has no level (i.e. /// it does not participate in any event), returns 0. /// </summary> public int GetLevelForObject(SmartObject obj) { if (!levelsForObjects.ContainsKey(obj)) { return DEFAULT_LEVEL; } return levelsForObjects[obj]; }
public SetupMenu(UIControllerWithSmartObjects uiController, SmartObject smartObject) : base(uiController, smartObject, 1, 1, 1, (list, index) => new SetupMenuItem(list, index)) { }
/// <summary> /// Adds the given authored event to the list of events for the given object. /// </summary> private void AddAuthoredEventToObject(EventStub authoredEvent, SmartObject obj) { if (authoredEvent.Participants.Contains(obj)) { GetParticipatingEvents(obj).Add(authoredEvent); } GetInvolvedInEvents(obj).Add(authoredEvent); }
public virtual SmartObject ExecuteBulkScalar(SmartObject smartObject, DataTable inputTable) { return(_serviceClientServer.ExecuteBulkScalar(smartObject, inputTable)); }
public Evt_KillAndTakeBall(SmartObject thief, SmartObject victim) : base(thief, victim) { this.thief = (SmartCharacter)thief; this.victim = (SmartCharacter)victim; }
public virtual SmartObjectList ExecuteList(SmartObject smartObject, ExecuteListOptions options) { return(_serviceClientServer.ExecuteList(smartObject, options)); }
public static T GetReturnPropertyValue <T>(this SmartObject smartObject, string propertyName = null) { var property = GetReturnProperty(smartObject, propertyName); return(ValueHelper.GetValue <T>(property)); }
public virtual DataTable ExecuteListDataTable(SmartObject smartObject, ExecuteListOptions options) { return(_serviceClientServer.ExecuteListDataTable(smartObject, options)); }
public void Update(SmartObject smartObject, string deviceId) { ClientUtils.WaitTask(UpdateAsync(smartObject, deviceId)); }
public PanelCalendarMeetingList(UIControllerWithSmartObjects uiController, SmartObject smartObject) : base(uiController, smartObject, 2, 1, 3, (list, index) => new PanelCalendarMeetingListItem(list, index)) { }
public void RetryWorkflow() { SmartObjectClientServer soServer = this.NewSmartObjectClientServer(); try { using (soServer.Connection) { SmartObject soError = soServer.GetSmartObject("com_K2_System_Workflow_SmartObject_ErrorLog"); //set method we want to execute. soError.MethodToExecute = "GetErrorLogs"; soError.Properties["ErrorProfileName"].Value = "All"; //get the list of SmartObjects returned by the method SmartObjectList soListError = soServer.ExecuteList(soError); //iterate over the collection List <K2ErrorLog> listK2ErrorLog = new List <K2ErrorLog>(); string[] workflowNames = this.AppConfig.WorkflowNames.Split(';'); foreach (SmartObject soItem in soListError.SmartObjectsList) { for (int i = 0; i < workflowNames.Length; i++) { if (soItem.Properties["ProcessName"].Value == workflowNames[i]) { string soDescription = soItem.Properties["Description"].Value.ToString(); if (soDescription.Contains("was deadlocked on lock resources with another process") || soDescription.Contains("SQL") || soDescription.Contains("IIF")) { listK2ErrorLog.Add(new K2ErrorLog(soItem)); } } } //ambil hanya transaksi deadlocked saja } foreach (K2ErrorLog k2ErrorLog in listK2ErrorLog) { SmartObject errorSO = soServer.GetSmartObject("com_K2_System_Workflow_SmartObject_ErrorLog"); //set method we want to execute. errorSO.MethodToExecute = "RetryError"; errorSO.Properties["Id"].Value = k2ErrorLog.Id.ToString(); errorSO.Properties["ProcInstId"].Value = k2ErrorLog.ProcInstID.ToString(); errorSO.Properties["TypeId"].Value = k2ErrorLog.TypeID.ToString(); errorSO.Properties["ObjectId"].Value = k2ErrorLog.ObjectID.ToString(); errorSO.Properties["UserName"].Value = "System"; this.Logger.Info("K2 Retry ProcInstId = " + k2ErrorLog.ProcInstID.ToString()); //get the list of SmartObjects returned by the method Thread.Sleep(1000); //delay 1 detik soServer.ExecuteScalar(errorSO); } } } finally { soServer.DeleteConnection(); } }
public RoutingList(UIControllerWithSmartObjects uiController, SmartObject smartObject) : base(uiController, smartObject, 2, 4, 2, (list, index) => new RoutingListItem(list, index)) { }