コード例 #1
0
ファイル: AnimationsManager.cs プロジェクト: Hugu3s/sonaris
 public void SetData(AssociativeArray <double> array)
 {
     data.Fill(array);
 }
コード例 #2
0
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     snapshot.DestroyArray(parentIndex);
 }
コード例 #3
0
 /// <inheritdoc />
 public override bool TryGetDescriptor(AssociativeArray arrayValue, out IArrayDescriptor descriptor)
 {
     return(arrayDescriptors.TryGetValue(arrayValue, out descriptor));
 }
コード例 #4
0
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            AssociativeArray arrayValue = worker.ProcessArrayValue(index, value);

            values.Add(arrayValue);
        }
コード例 #5
0
 /// <inheritdoc />
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     arrayVisitor.SetLeftOperand(value);
     visitor = arrayVisitor;
 }
コード例 #6
0
 /// <inheritdoc />
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     result = TypeConversion.ToBoolean(snapshot, value);
 }
コード例 #7
0
 /// <inheritdoc />
 public abstract void SetDescriptor(AssociativeArray arrayvalue, IArrayDescriptor descriptor);
コード例 #8
0
        /// <summary>
        /// Sets the array descriptor which contains information about defined indexes in the specified array.
        /// </summary>
        /// <param name="arrayvalue">The arrayvalue.</param>
        /// <param name="descriptor">The descriptor.</param>
        internal void SetDescriptor(AssociativeArray arrayvalue, ArrayDescriptor descriptor)
        {
            lockedTest();

            ArrayDescriptors[arrayvalue] = descriptor;
        }
コード例 #9
0
 /// <inheritdoc />
 public abstract bool TryGetArray(MemoryIndex index, out AssociativeArray arrayValue);
コード例 #10
0
 /// <inheritdoc />
 public abstract bool TryGetCallArraySnapshot(AssociativeArray array, out IEnumerable <Snapshot> snapshots);
コード例 #11
0
 /// <inheritdoc />
 public abstract IArrayDescriptor GetDescriptor(AssociativeArray arrayValue);
コード例 #12
0
 /// <inheritdoc />
 public abstract bool TryGetDescriptor(AssociativeArray arrayValue, out IArrayDescriptor descriptor);
コード例 #13
0
        /// <summary>
        /// Processes the merge operation.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="operationAccessor">The operation accessor.</param>
        /// <exception cref="System.Exception">
        /// Error merging structure in readonly mode - undefined index  + targetIndex
        /// or
        /// Error merging structure in readonly mode - target descriptor for  + targetIndex
        /// </exception>
        private void processMergeOperation(MergeOperation operation, TrackingMergeWorkerOperationAccessor operationAccessor)
        {
            MemoryIndex             targetIndex  = operation.TargetIndex;
            AssociativeArray        targetArray  = null;
            List <ContainerContext> sourceArrays = new List <ContainerContext>();
            bool arrayAlwaysDefined = !operation.IsUndefined;
            bool cotainsArray       = false;

            // Iterate sources
            foreach (MergeOperationContext operationContext in operation.Indexes)
            {
                // Retreive source context and definition
                MemoryIndex      sourceIndex      = operationContext.Index;
                SnapshotContext  context          = operationContext.SnapshotContext;
                IIndexDefinition sourceDefinition = context.SourceStructure.GetIndexDefinition(sourceIndex);

                // Provide custom operation for merge algorithm
                operationAccessor.addSource(operationContext, sourceDefinition);

                // Source array
                if (sourceDefinition.Array != null)
                {
                    // Becomes target array when not set
                    if (targetArray == null && sourceIndex.Equals(targetIndex))
                    {
                        targetArray = sourceDefinition.Array;
                    }
                    cotainsArray = true;

                    // Save source array to merge descriptors
                    IArrayDescriptor descriptor = context.SourceStructure.GetDescriptor(sourceDefinition.Array);
                    sourceArrays.Add(new ContainerContext(context, descriptor, operationContext.OperationType));

                    // Equeue all array indexes when whole subtree should be merged
                    if (operationContext.OperationType == MergeOperationType.WholeSubtree)
                    {
                        foreach (var index in descriptor.Indexes)
                        {
                            operation.TreeNode.GetOrCreateChild(index.Key);
                        }
                        operation.TreeNode.GetOrCreateAny();
                    }
                }
                else
                {
                    // Source do not contain array - at least one source is empty
                    arrayAlwaysDefined = false;
                }
            }

            IIndexDefinition targetDefinition;
            IArrayDescriptor targetArrayDescriptor = null;

            if (targetStructure.TryGetIndexDefinition(targetIndex, out targetDefinition))
            {
                // Index is set in target snapshot
                if (targetDefinition.Array != null)
                {
                    // Target contains array - continue merging
                    targetArray           = targetDefinition.Array;
                    targetArrayDescriptor = targetStructure.GetDescriptor(targetArray);
                }
            }
            else
            {
                // Index is not set in target snapshot - create it
                if (isStructureWriteable)
                {
                    writeableTargetStructure.NewIndex(targetIndex);
                }
                else
                {
                    throw new Exception("Error merging structure in readonly mode - undefined index " + targetIndex);
                }
            }

            // Provide custom operation for merge algorithm
            operationAccessor.provideCustomOperation(targetIndex);

            // Process next array
            if (cotainsArray)
            {
                if (targetArray == null)
                {
                    targetArray = targetSnapshot.CreateArray();
                }

                if (targetArrayDescriptor == null)
                {
                    // Target does not contain array - create and add new in target snapshot
                    if (isStructureWriteable)
                    {
                        targetArrayDescriptor = Factories.StructuralContainersFactories.ArrayDescriptorFactory.CreateArrayDescriptor(writeableTargetStructure, targetArray, targetIndex);
                        writeableTargetStructure.SetDescriptor(targetArray, targetArrayDescriptor);
                        writeableTargetStructure.NewIndex(targetArrayDescriptor.UnknownIndex);
                        writeableTargetStructure.SetArray(targetIndex, targetArray);
                    }
                    else
                    {
                        throw new Exception("Error merging structure in readonly mode - target descriptor for " + targetIndex);
                    }
                }

                // Create context and merge descriptors
                var arrayContext = new ArrayTargetContainerContext(writeableTargetStructure, targetArrayDescriptor);
                createAndEnqueueOperations(arrayContext, operation.TreeNode, sourceArrays, arrayAlwaysDefined);

                if (isStructureWriteable)
                {
                    // Ubdate current descriptor when changed
                    IArrayDescriptor currentDescriptor = arrayContext.getCurrentDescriptor();
                    if (currentDescriptor != targetArrayDescriptor)
                    {
                        writeableTargetStructure.SetDescriptor(targetArray, currentDescriptor);
                    }
                }
            }
        }
コード例 #14
0
        private IEnumerable <Tuple <Snapshot, IArrayDescriptor> > getIArrayDescriptor(AssociativeArray array)
        {
            List <Tuple <Snapshot, IArrayDescriptor> > results = new List <Tuple <Snapshot, IArrayDescriptor> >();

            IArrayDescriptor       descriptor;
            IEnumerable <Snapshot> snapshots;

            if (targetSnapshot.Structure.Readonly.TryGetDescriptor(array, out descriptor))
            {
                results.Add(new Tuple <Snapshot, IArrayDescriptor>(targetSnapshot, descriptor));
            }
            else if (targetSnapshot.Structure.Readonly.TryGetCallArraySnapshot(array, out snapshots))
            {
                foreach (Snapshot snapshot in snapshots)
                {
                    IArrayDescriptor snapDescriptor = snapshot.Structure.Readonly.GetDescriptor(array);
                    results.Add(new Tuple <Snapshot, IArrayDescriptor>(snapshot, snapDescriptor));
                }
            }
            else
            {
                throw new Exception("Missing array descriptor");
            }

            return(results);
        }
コード例 #15
0
 /// <inheritdoc />
 public abstract void AddCallArray(AssociativeArray array, Snapshot snapshot);
コード例 #16
0
 /// <summary>
 /// Tries to get array descriptor which contains information about defined indexes in the specified array.
 /// </summary>
 /// <param name="arrayValue">The array value.</param>
 /// <param name="descriptor">The descriptor.</param>
 /// <returns>Array descriptor which contains information about defined indexes in the specified array.</returns>
 internal bool TryGetDescriptor(AssociativeArray arrayValue, out ArrayDescriptor descriptor)
 {
     return(ArrayDescriptors.TryGetValue(arrayValue, out descriptor));
 }
コード例 #17
0
 /// <inheritdoc />
 public abstract void RemoveArray(MemoryIndex index, AssociativeArray arrayValue);
コード例 #18
0
ファイル: Data.cs プロジェクト: Hugu3s/sonaris
 public void Add(AssociativeArray <double> aa)
 {
     data.Add(aa);
     length = data.Count;
 }
コード例 #19
0
 /// <inheritdoc />
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     result         = TypeConversion.ToString(OutSet, value);
     abstractResult = null;
 }
コード例 #20
0
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     // Skip visiting array value - already processed
 }
コード例 #21
0
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     //Nothing to do, arrays are resolved in snapshot entries
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArrayDescriptorBuilder"/> class.
 /// </summary>
 public ArrayDescriptorBuilder()
 {
     Indexes        = new Dictionary <string, MemoryIndex>();
     ArrayValue     = null;
     ParentVariable = null;
 }
コード例 #23
0
 /// <inheritdoc />
 public void SetArrayValue(AssociativeArray arrayValue)
 {
     this.arrayValue = arrayValue;
 }
コード例 #24
0
 /// <inheritdoc />
 public override void SetDescriptor(AssociativeArray arrayvalue, IArrayDescriptor descriptor)
 {
     arrayDescriptors[arrayvalue] = descriptor;
     changeTracker.ModifiedIndex(descriptor.ParentIndex);
 }
コード例 #25
0
        public IArrayDescriptor CreateArrayDescriptor(IWriteableSnapshotStructure targetStructure, AssociativeArray createdArray, MemoryIndex memoryIndex)
        {
            LazyCopyArrayDescriptor descriptor = new LazyCopyArrayDescriptor(targetStructure);

            descriptor.SetArrayValue(createdArray);
            descriptor.SetParentIndex(memoryIndex);
            descriptor.SetUnknownIndex(memoryIndex.CreateUnknownIndex());
            return(descriptor);
        }
コード例 #26
0
 /// <inheritdoc />
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     result = "Array";
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LazyCopyArrayDescriptor" /> class.
 /// </summary>
 /// <param name="associatedStrucutre">The associated strucutre.</param>
 /// <param name="parentIndex">Index of the parent.</param>
 /// <param name="arrayValue">The array value.</param>
 public LazyCopyArrayDescriptor(IWriteableSnapshotStructure associatedStrucutre, MemoryIndex parentIndex, AssociativeArray arrayValue)
 {
     this.associatedStrucutre = associatedStrucutre;
     this.parentIndex         = parentIndex;
     this.arrayValue          = arrayValue;
 }
コード例 #28
0
ファイル: Program.cs プロジェクト: tylermenezes/SerialServe
        static void listener_RequestReceived(object sender, RequestEventArgs e)
        {
            IHttpClientContext context = (IHttpClientContext)sender;
            IHttpRequest request = e.Request;
            IHttpResponse response = request.CreateResponse(context);
            StreamWriter writer = new StreamWriter(response.Body);

            response.AddHeader("Content-type", "text/plain");
            response.AddHeader("Access-Control-Allow-Methods", "*");
            response.AddHeader("Access-Control-Allow-Origin", "*");

            string endpoint = (request.UriParts.Length > 0? request.UriParts[0] : "");
            int to = 0;
            int.TryParse((request.UriParts.Length > 1 ? request.UriParts[1] : ""), out to);
            string id = "";
            AsyncSerial toSerial = null;

            if (to != 0)
            {
                if (request.QueryString.Contains("baud") || request.QueryString.Contains("parity") || request.QueryString.Contains("dataBits") ||
                            request.QueryString.Contains("stopBits") || request.QueryString.Contains("newLine"))
                {
                    // TODO
                    toSerial = bus.Connect(to);
                }
                else
                {
                    toSerial = bus.Connect(to);
                }
            }

            switch (endpoint)
            {
                case "":
                    writer.Write("SerialServe is running! Check out the documentation on GitHub.");
                    writer.Flush();
                    response.Send();
                    break;
                case "list":
                    writer.Write("[" + string.Join(",", bus.Ports) + "]");
                    writer.Flush();
                    response.Send();
                    break;
                case "write":
                    try
                    {
                        toSerial.Write(request.QueryString["toWrite"].ToString());
                        writer.Write("{\"success\":true}");
                        writer.Flush();
                        response.Send();
                    }
                    catch
                    {
                        response.Status = System.Net.HttpStatusCode.BadRequest;
                        writer.Write("{\"error\":\"Could not write to the requested port.\"}");
                        writer.Flush();
                        response.Send();
                    }
                    break;
                case "enable":
                case "disable":
                    try
                    {
                        if (endpoint == "enable")
                        {
                            toSerial.DtsEnable();
                        }
                        else
                        {
                            toSerial.DtsDisable();
                        }
                        writer.Write("{\"success\":true}");
                        writer.Flush();
                        response.Send();
                    }
                    catch
                    {
                        response.Status = System.Net.HttpStatusCode.BadRequest;
                        writer.Write("{\"error\":\"Could not change the state of the requested port.\"}");
                        writer.Flush();
                        response.Send();
                    }
                    break;
                case "read":
                    if (!longpollConnections.ContainsKey(to))
                    {
                        longpollConnections[to] = new AssociativeArray<string, List<IHttpResponse>>();
                    }

                    if (!longpollConnections[to].ContainsKey(id))
                    {
                        longpollConnections[to][id] = new List<IHttpResponse>();
                    }

                    longpollConnections[to][id].Add(response);
                    break;
                default:
                    response.Status = System.Net.HttpStatusCode.NotFound;
                    writer.Write("Not found!");
                    writer.Flush();
                    response.Send();
                    break;
            }
        }
コード例 #29
0
 public override void VisitAssociativeArray(AssociativeArray value)
 {
     ContainsArrayValue = true;
 }