public static Configuration.Message AddMessage(string messageName, string canId, Configuration.Node node, Configuration.Bus parentBus) { if (messageName == null) { throw new ArgumentNullException(nameof(messageName)); } if (canId == null) { throw new ArgumentNullException(nameof(canId)); } if (node == null) { throw new ArgumentNullException(nameof(node)); } if (parentBus == null) { throw new ArgumentNullException(nameof(parentBus)); } Configuration.Message message = new Configuration.Message { name = messageName, id = "0x" + CanUtilities.Trim0x(canId) }; NodeRef nodeRef = new NodeRef { id = node.id }; message.Producer.Add(nodeRef); parentBus.Message.Add(message); return(message); }
/* ** Internal function to manipulate arrays. ** Given an array object and a reference value, return the next element ** in the hash. ** This function pushs the element value and its reference to the stack. */ private static void firstnode(Hash a, int h) { if (h < nhash(a)) { int i; for (i = h; i < nhash(a); i++) { if (list(a, i) != null) { if (tag(list(a, i).get().val) != Type.T_NIL) { lua_pushobject(list(a, i).get().@ref); lua_pushobject(list(a, i).get().val); return; } else { NodeRef next = list(a, i).get().next; while (next != null && tag(next.get().val) == Type.T_NIL) { next = next.get().next; } if (next != null) { lua_pushobject(next.get().@ref); lua_pushobject(next.get().val); return; } } } } } lua_pushnil(); lua_pushnil(); }
/* ** If the hash node is present, return its pointer, otherwise create a new ** node for the given reference and also return its pointer. ** On error, return NULL. */ public static Object_ lua_hashdefine(Hash t, Object_ @ref) { int h; NodeRef n; h = head(t, @ref); if (h < 0) { return(null); } n = present(t, @ref, h); if (n == null) { n = NodeRef.assign(new_Node()); //(Node) new_("Node"); if (n == null) { lua_error("not enough memory"); return(null); } n.get()[email protected](@ref); tag(n.get().val, Type.T_NIL); n.get().next = NodeRef.assign(list(t, h)); /* link node to head of list */ list(t, h, n.get()); } return(n.get().val); }
private static void freelist(NodeRef n) { while (n != null) { NodeRef next = NodeRef.assign(n.get().next); free(n.get()); n = next; } }
public static NodeRef assign(NodeRef node) { if (node == null) { return(null); } else { return(new NodeRef(node.index)); } }
public Node(MonoBehaviour switchBehaviour, NodeRef parent = null, int treeDepth = 0) { this._switchBehaviour = switchBehaviour; this.parent = parent; this.treeDepth = treeDepth; _isValid = true; children = new List <Node>(); numAllChildren = 0; constructChildren(); }
public Agent(Uri apiAddress, Guid environmentId, string token) { var api = new Api(apiAddress, token) .ForEnvironment(environmentId); var nodeRef = new NodeRef { NodeType = AgentConstants.NodeType.Server, Parts = new Dictionary <string, string> { { "machine-name", Env.MachineName } }, }; _statisticsMonitor = new StatisticsMonitor(api, nodeRef); _topologyMonitor = new TopologyMonitor(api, nodeRef); }
/* ** Mark a hash and check its elements */ public static void lua_hashmark(Hash h) { int i; markarray(h, (char)1); for (i = 0; i < nhash(h); i++) { NodeRef n; for (n = list(h, i); n != null; n = NodeRef.assign(n.get().next)) { lua_markobject(n.get().@ref); lua_markobject(n.get().val); } } }
public override void CheckForValueUpdate() { if (ShouldReplicate()) { return; } // Find the most recent update uint CurrentTick = GameClock.GetRemoteTick(); if (ValueList.Count == 0 || CurrentTick == LastTickValueWasChanged) { return; } uint NextValue = FindNextValue(); if (NextValue == 0) { // We got no more values in queue return; } // Nothing to interpolate yet if (LastClockedValue.Key == 0) { T Val = GetValueForTick(NextValue); Node node = NodeRef.GetRef() as Node; if (HasValueChanged((T)Member.GetValue(node), Val)) { UpdateValue(Val); } return; } // Interpolate between last and current float TicksSinceLastValue = CurrentTick - LastClockedValue.Key; float TicksBetweenUpdates = NextValue - LastClockedValue.Key; // Set the value T Value = GetValueForTick(NextValue); float Alpha = Mathf.Clamp(TicksSinceLastValue / TicksBetweenUpdates, 0f, 1f); UpdateValue(LinearInterpolate(LastClockedValue.Value, Value, Alpha)); LastTickValueWasChanged = GameClock.GetRemoteTick(); }
private void UISetObjectXform(ref Vector3 p, ref Quaternion q) { if (mSelected == null) { return; } mSelected.localScale = p; NodeRef nr = mSelected.GetComponent <NodeRef>(); if (nr != null) { foreach (TreeNodePrimitive tnp in nr.treeNode.PrimitiveList) { tnp.transform.localScale = p; } } }
/* ** Re-hash */ private static void rehash(Hash t) { Word i; Word nold = nhash(t); NodeRef vold = nodevector(t); nhash(t, redimension(nhash(t))); nodevector(t, hashnodecreate(nhash(t))); for (i = 0; i < nold; i++) { Node n = vold.get(i); if (tag(ref_(n)) != lua_Type.LUA_T_NIL && tag(val_(n)) != lua_Type.LUA_T_NIL) { node(t, present(t, ref_(n))).set(n); /* copy old node to new hahs */ } } luaI_free_NodeRef(vold); }
public Configuration.Message AddMessage(string messageName, string canId, Configuration.Node node, Configuration.Bus parentBus) { Configuration.Message message = new Configuration.Message { name = messageName, id = "0x" + MyExtensions.Trim0x(canId) }; NodeRef nodeRef = new NodeRef { id = node.id }; message.Producer.Add(nodeRef); parentBus.Message.Add(message); return(message); }
private static NodeRef present(Hash t, Object_ @ref, int h) { NodeRef n = null, p = null; if (tag(@ref) == Type.T_NUMBER) { for (p = null, n = list(t, h); n != null; p = n, n = NodeRef.assign(n.get().next)) { if (ref_tag(n.get()) == Type.T_NUMBER && nvalue(@ref) == ref_nvalue(n.get())) { break; } } } else if (tag(@ref) == Type.T_STRING) { for (p = null, n = list(t, h); n != null; p = n, n = NodeRef.assign(n.get().next)) { // if (ref_tag(n.get()) == Type.T_STRING) // { // Console.WriteLine("=========================" + svalue(@ref).ToString() + ", " + ref_svalue(n.get())); // } if (ref_tag(n.get()) == Type.T_STRING && streq(svalue(@ref), ref_svalue(n.get()))) { // Console.WriteLine("========================="); break; } } } if (n == null) /* name not present */ { return(null); } #if false if (p != null) /* name present but not first */ { p.next = n.next; /* move-to-front self-organization */ n.next = list(t, h); list(t, h, n); } #endif return(n); }
public override void Replicate(int JoinInProgressPeerId, bool IsIntervalReplicationTime) { IMDCommandReplicator CommandReplicator = GetCommandReplicator(); Node Instance = NodeRef.GetRef() as Node; if (CommandReplicator == null) { MDLog.Error(LOG_CAT, $"Command replicator is null for member {Instance.GetPath()}#{Member.Name}"); return; } if ((GetReplicatedType() == MDReplicatedType.Interval && IsIntervalReplicationTime) || (GetReplicatedType() == MDReplicatedType.OnChange)) { // We do a check here to see if anything has updated GetCommandReplicator().MDShouldBeReplicated(); List <object[]> commands = GetCommandReplicator().MDGetCommands(); if (commands.Count > 0) { // Do replication to all except joining peer if we got one commands.ForEach(value => { foreach (int PeerId in GameSession.GetAllPeerIds()) { if (PeerId != JoinInProgressPeerId && PeerId != MDStatics.GetPeerId()) { ReplicateCommandToPeer(value, PeerId); } } }); CheckCallLocalOnChangeCallback(); } } if (JoinInProgressPeerId != -1) { // Replicate current data to joining peer and send current command we are at List <object[]> newPlayerCommands = CommandReplicator.MDGetCommandsForNewPlayer(); newPlayerCommands.ForEach(value => ReplicateCommandToPeer(value, JoinInProgressPeerId)); } }
void HandleRotation() { if (ControlledObject != null) { float d = GetDeltaDistance(); float rotDelta = 0; Quaternion Q = Quaternion.identity; // If manipulator selected, calculate rotation if (Selection.tag == "X-Manipulator") { Vector3 mR = manipulator_R.transform.localRotation.eulerAngles; rotDelta = mR.x + (d * inputDampening); Q = Quaternion.Euler(rotDelta, mR.y, mR.z); } else if (Selection.tag == "Y-Manipulator") { Vector3 mR = manipulator_R.transform.localRotation.eulerAngles; rotDelta = mR.y + (d * inputDampening); Q = Quaternion.Euler(mR.x, rotDelta, mR.z); } else if (Selection.tag == "Z-Manipulator") { Vector3 mR = manipulator_R.transform.localRotation.eulerAngles; rotDelta = mR.z + (d * inputDampening); Q = Quaternion.Euler(mR.x, mR.y, rotDelta); } // If manipulator selected, assign rotation if (Selection.tag == "X-Manipulator" || Selection.tag == "Y-Manipulator" || Selection.tag == "Z-Manipulator") { manipulator_R.transform.localRotation = Q; ControlledObject.transform.localRotation = Q; NodeRef nr = ControlledObject.GetComponent <NodeRef>(); if (nr != null) { nr.treeNode.transform.localRotation = Q; } } LastMousePosition = Input.mousePosition; } }
public override void CheckForValueUpdate() { // Check if we are the owner of this if (ShouldReplicate()) { return; } uint RemoteTick = GameClock.GetRemoteTick(); bool ValueChanged = false; // Find the most recent update List <uint> touchedKeys = new List <uint>(); foreach (uint key in ValueList.Keys) { if (key > RemoteTick) { break; } ValueList[key].ForEach(parameters => GetCommandReplicator().MDProcessCommand((object[])parameters)); ValueChanged = true; touchedKeys.Add(key); } if (ValueChanged) { // Remove old touchedKeys.ForEach(k => ValueList.Remove(k)); // Send event if (OnValueChangedCallback != null) { Node Instance = NodeRef.GetRef() as Node; OnValueChangedCallback.Invoke(Instance, null); } } }
public override void SetValues(uint Tick, params object[] Parameters) { // If the tick this update is for is past the current tick if (GameClock.GetRemoteTick() >= Tick || IsSynchInProgress()) { GetCommandReplicator().MDProcessCommand(Parameters); if (OnValueChangedCallback != null) { Node Instance = NodeRef.GetRef() as Node; OnValueChangedCallback.Invoke(Instance, null); } } else { if (!ValueList.ContainsKey(Tick)) { ValueList.Add(Tick, new List <object>()); } ValueList[Tick].Add(Parameters); } }
public static void nodevector(Hash t, NodeRef v) { t.node = v; }
public readonly bool Equals(NodeRef other) => Index == other.Index;
public StatisticsMonitor(EnvironmentApi api, NodeRef nodeRef) : base((int)TimeSpan.FromMinutes(1).TotalMilliseconds) { _api = api; _nodeRef = nodeRef; }
public NodeInfo(NodeRef reference, DateTime lastSeen, NodeState state) { Reference = reference; LastSeen = lastSeen; State = state; }
static void Main(string[] args) { NodeRef nodeRef = new NodeRef <MyNode>(); var newNodeRef = (NodeRef <MyNode>)nodeRef; }
//char *rcs_mem = "$Id: mem.c,v 1.5 1995/02/06 19:34:03 roberto Exp $"; //#include <stdlib.h> //#include <string.h> //#include "mem.h" //#include "lua.h" public static void luaI_free_NodeRef(NodeRef block) { block.set(null); //*((int *)block) = -1; /* to catch errors */ //free(block); }
public static void lua_next() { Hash a; Object_ o = lua_getparam(1); Object_ r = lua_getparam(2); if (o == null || r == null) { lua_error("too few arguments to function `next'"); return; } if (lua_getparam(3) != null) { lua_error("too many arguments to function `next'"); return; } if (tag(o) != Type.T_ARRAY) { lua_error("first argument of function `next' is not a table"); return; } a = avalue(o); if (tag(r) == Type.T_NIL) { firstnode(a, 0); return; } else { int h = head(a, r); if (h >= 0) { NodeRef n = list(a, h); while (n != null) { if (n.get()[email protected](r)) { if (n.get().next == null) { firstnode(a, h + 1); return; } else if (tag(n.get().next.get().val) != Type.T_NIL) { lua_pushobject(n.get().next.get().@ref); lua_pushobject(n.get().next.get().val); return; } else { NodeRef next = NodeRef.assign(n.get().next.get().next); while (next != null && tag(next.get().val) == Type.T_NIL) { next = NodeRef.assign(next.get().next); } if (next == null) { firstnode(a, h + 1); return; } else { lua_pushobject(next.get().@ref); lua_pushobject(next.get().val); } return; } } n = NodeRef.assign(n.get().next); } if (n == null) { lua_error("error in function 'next': reference not found"); } } } }
//#define list(t,i) ((t)->list[i]) private static NodeRef list(Hash t, int i) { return(NodeRef.assign(t.list[i])); }
internal static ArgumentOutOfRangeException InvalidNodeRef(string nodeRefName, NodeRef value) { return(new($"NodeRef {nodeRefName} is invalid ({value.Index})")); }
private IMDCommandReplicator GetCommandReplicator() { Node node = NodeRef.GetRef() as Node; return((IMDCommandReplicator)Member.GetValue(node)); }
public TopologyMonitor(EnvironmentApi api, NodeRef nodeRef) : base((int)TimeSpan.FromMinutes(5).TotalMilliseconds) { _api = api; _nodeRef = nodeRef; }