Ejemplo n.º 1
0
        public void SetInOutput(NodeViewModel nodeView)
        {
            NodeModel node = nodeView.NodeModel;

            node.InPorts.RemoveAll((p) => { return(true); });
            for (int i = 0; i < this.Inputs.Count; i++)
            {
                string inputName    = this.Inputs[i];
                string inputToolTip = this.InputToolTips[i];

                PortData  portData  = new PortData(inputName, inputToolTip);
                PortModel inputPort = new PortModel(PortType.Input, node, portData);
                node.InPorts.Add(inputPort);
                PortModel startPort = StartConnectorPorts[i];
                if (startPort != null)
                {
                    inputPort.Connectors.Add(new ConnectorModel(startPort, node.InPorts.Last(), Guid.NewGuid()));
                }
            }

            node.OutPorts.RemoveAll((p) => { return(true); });
            string    outputName    = this.Output;
            string    outputToolTip = this.OutputToolTip;
            PortData  portdata      = new PortData(outputName, outputToolTip);
            PortModel outputPort    = new PortModel(PortType.Output, node, portdata);

            node.OutPorts.Add(outputPort);
            if (EndConnectorPort != null)
            {
                outputPort.Connectors.Add(new ConnectorModel(node.OutPorts.Last(), EndConnectorPort, Guid.NewGuid()));
            }
            node.RegisterAllPorts();
        }
Ejemplo n.º 2
0
    private string GetFlourishChampionNameText(PortData data)
    {
        string wordText = Globals.Instance.MDataTableManager.GetWordText(21800014);
        string val      = GUIFontColor.White + wordText + data.BasicData.HighestInvestorName;

        return(val);
    }
Ejemplo n.º 3
0
        protected IEnumerable <PortData> GetMaterialInputs(List <SerializableEdge> edges)
        {
            var portData = new PortData {
                identifier          = nameof(output),
                displayName         = "Output",
                acceptMultipleEdges = true,
            };

            switch (mode)
            {
            case AggregationMode.MergeResult:
                portData.displayType = typeof(MixtureMesh);
                break;

            case AggregationMode.List:
                portData.displayType = typeof(List <MixtureMesh>);
                break;

            default:
            case AggregationMode.None:
                portData.displayType = typeof(MixtureMesh);
                break;
            }

            yield return(portData);
        }
Ejemplo n.º 4
0
    private string GetFightChampionNameText(PortData data)
    {
        string wordText = Globals.Instance.MDataTableManager.GetWordText(21800015);
        string val      = GUIFontColor.White + wordText + data.BasicData.OccupierName;

        return(val);
    }
        private void GenerateImages()
        {
            if (PortData == null)
            {
                DataCollection = new SerialPortDataViewModel[0];
                return;
            }

            var dataCollection = new List <SerialPortDataViewModel>();

            foreach (var data in PortData.Take(CountOfNumbers))
            {
                var imageData = _imageDataCollection.SingleOrDefault(x => x.Number == data);

                if (imageData == null)
                {
                    continue;
                }

                var item = new SerialPortDataViewModel();

                if (File.Exists(imageData.Filepath))
                {
                    item.Init(imageData.Number, imageData.Filepath);
                }
                else
                {
                    item.Init(imageData.Number);
                }

                dataCollection.Add(item);
            }

            DataCollection = dataCollection.ToArray();
        }
Ejemplo n.º 6
0
        public override void Draw()
        {
            //skip the first port data because it's the family instances
            for (int i = 1; i < InPortData.Count; i++)
            {
                PortData pd = InPortData[i];

                if (pd.Object != null)
                {
                    //parameter value keys are the tooltip - the name
                    //of the parameter
                    //set the objects on the parameter map
                    parameterMap[pd.ToolTipString] = pd.Object;

                    DataTree familyInstTree = InPortData[0].Object as DataTree;

                    if (familyInstTree != null)
                    {
                        if (pd.Object.GetType() == typeof(DataTree))
                        {
                            DataTree doubleTree = pd.Object as DataTree;
                            //get the parameter represented by the port data
                            Process(familyInstTree.Trunk, doubleTree.Trunk, pd.ToolTipString);
                        }
                        else
                        {
                            double d = Convert.ToDouble(pd.Object);
                            Process(familyInstTree.Trunk, d, pd.ToolTipString);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public WebExtControl(WebCtrlExtension ext, SimFeedbackExtensionFacade facade)
        {
            webCtrlExt     = ext;
            Globals.facade = facade;

            InitializeComponent();

            try
            {
                PortData.ReadFile();
                Globals.facade.LogDebug($"Got ports from PortData file - http '{PortData.Instance.httpPort}' - websvc '{PortData.Instance.webSvcPort}'");
            } catch (Exception e)
            {
                Globals.facade.LogDebug($"Couldn't read PortData file: '{e.Message}'");
            }

            HttpPortBox1.Validating   += new CancelEventHandler(Number_Validating);
            HttpPortBox1.Text          = PortData.Instance.httpPort.ToString();
            WebSvcPortBox1.Validating += new CancelEventHandler(Number_Validating);
            WebSvcPortBox1.Text        = PortData.Instance.webSvcPort.ToString();

            SFBCtrlWebservices sfbCtrl = new SFBCtrlWebservices();

            _ = sfbCtrl.StartWebServicesAsync();
        }
Ejemplo n.º 8
0
    private string GetNeedFeatText(PortData data)
    {
        string wordText = Globals.Instance.MDataTableManager.GetWordText(21800013);
        string val      = GUIFontColor.PureRed + wordText + data.BasicData.FeatRequire;

        return(val);
    }
Ejemplo n.º 9
0
 protected MultipleElementSelectionBase(PortData outData)
 {
     OutPortData.Add(outData);
     RegisterAllPorts();
     dynSettings.Controller.DynamoViewModel.PropertyChanged += DynamoViewModel_PropertyChanged;
     CanSelect = true;
 }
Ejemplo n.º 10
0
    private string GetFlourishLevelText(PortData data)
    {
        string wordText = Globals.Instance.MDataTableManager.GetWordText(21800006);
        string val      = GUIFontColor.Orange + wordText + data.FlourishData.FlourishLevel;

        return(val);
    }
Ejemplo n.º 11
0
        protected SelectionBase(PortData outPortData)
        {
            OutPortData.Add(outPortData);
            RegisterAllPorts();

            dynRevitSettings.Controller.RevitDocumentChanged += Controller_RevitDocumentChanged;
        }
Ejemplo n.º 12
0
        public override PortData GetPortData(byte port)
        {
            // 0x31, 0x33 // VIN
            // 0x31, 0x34 // VVOut12
            // 0x31, 0x35 // VVout5
            // 0x31, 0x36 // VVOut33
            // 0x31, 0x37 // VIOut12
            // 0x31, 0x38 // VIOut5
            // 0x31, 0x39 // VIOut33
            // 0x31, 0x3a // Temp
            // 0x31, 0x3b // FanSpeed
            // WATTS = VVOut33 * VIOut33
            // EFF = (int)((VVOut12 * VIOut12 + VVOut5 * VIOut5 + VVOut33 * VIOut33) / 10.0)

            byte[] GetData(byte b) => Device.WriteReadBytes(0x31, b).Take(2).ToArray();
            string GetDataAsString(byte b) => $"{string.Concat(GetData(b).Select(x => x.ToString("X2")))}";

            var data = new PortData()
            {
                ["VIN"]      = GetDataAsString(0x33),
                ["VVOut12"]  = GetDataAsString(0x34),
                ["VVout5"]   = GetDataAsString(0x35),
                ["VVOut33"]  = GetDataAsString(0x36),
                ["VIOut12"]  = GetDataAsString(0x37),
                ["VIOut5"]   = GetDataAsString(0x38),
                ["VIOut33"]  = GetDataAsString(0x39),
                ["Temp"]     = GetDataAsString(0x3a),
                ["FanSpeed"] = GetDataAsString(0x3b)
            };

            return(data);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// The constructor for your type is where you define inputs and outputs.
        /// </summary>
        /// <param name="nickName"></param>
        public TestNode()
        {
            //System.Uri resourceLocater = new System.Uri("/dynElement.xaml", UriKind.Relative);
            //System.Windows.Application.LoadComponent(this, resourceLocater);

            //Define the data for the input ports
            //For each port you'll define an object value - this is usually null to start,
            //a short name which will appear on the node, a tooltip which appears when
            //you hover over the node, and a type which will keep nodes from connecting to
            //others of the wrong type
            InPortData.Add(new PortData("A", "The first port", typeof(dynElement)));
            InPortData.Add(new PortData("B", "The second port", typeof(dynElement)));
            InPortData.Add(new PortData("C", "The third port", typeof(dynElement)));

            //The ouput data looks very similar
            OutPortData = new PortData("me", "The result of this node.", typeof(dynElement));

            //make the first output port's object the tree
            //from this object. this isn't required yet by the interface, but it's
            //nice if you want the results of this node to be
            //a tree.
            //Don't worry about creating the tree, that's done in the base class.
            //OutPortData[0].Object = this.Tree;

            //tell the base type to setup for
            //the number of inputs and outputs
            base.RegisterInputsAndOutputs();
        }
Ejemplo n.º 14
0
        private void Number_Validating(object sender, CancelEventArgs e)
        {
            int     val;
            TextBox tb = sender as TextBox;

            if (int.TryParse(tb.Text, out val))
            {
                if (val > 1023 && val < 65536)
                {
                    if (tb.Name == "HttpPortBox1")
                    {
                        PortData.Instance.httpPort = val;
                        Globals.facade.LogDebug($"Got Http Port num '{PortData.Instance.httpPort}'");
                        PortData.WriteFile();
                        return;
                    }
                    else if (tb.Name == "WebSvcPortBox1")
                    {
                        PortData.Instance.webSvcPort = val;
                        Globals.facade.LogDebug($"Got Http Port num '{PortData.Instance.webSvcPort}'");
                        PortData.WriteFile();
                        return;
                    }
                    else
                    {
                        Globals.facade.LogDebug($"Got invalid TextBox name '{tb.Name}'");
                    }
                }
            }
            tb.Undo();
            e.Cancel = true;
        }
Ejemplo n.º 15
0
        public async Task <ActionResult <PortData> > Get(string host)
        {
            var validatedIp = NetUtils.GetIpAddress(host);

            if (validatedIp == null)
            {
                var msg = "Invalid host or host could not be reached";
                _logger.LogError(msg);
                return(BadRequest(msg));
            }

            var ipAddress = validatedIp.ToString();
            var client    = _clientFactory.CreateClient();

            var viewDnsRepository = new ViewDnsRepository(client);

            _logger.LogDebug("Getting Port data...");
            var portData = await viewDnsRepository.GetPortStatusData(ipAddress);

            _logger.LogDebug("Port data result: {1}", portData);

            var output = new PortData
            {
                Host  = portData.Query["host"],
                Ports = new List <PortData.StatusData>()
            };

            foreach (var status in portData.Response.Port)
            {
                output.Ports.Add(new PortData.StatusData(Convert.ToInt32(status.Number), status.Service,
                                                         status.Status));
            }

            return(Ok(output));
        }
Ejemplo n.º 16
0
        public void AddPort(string portName, string monitorName)
        {
            IntPtr printerHandle;
            var    defaults = new PrinterDefaults
            {
                pDataType     = IntPtr.Zero,
                pDevMode      = IntPtr.Zero,
                DesiredAccess = PrinterAccess.ServerAdmin
            };

            if (!OpenPrinter(",XcvMonitor " + monitorName, out printerHandle, ref defaults))
            {
                ////List<Monitor> monitors = GetInstalledMonitors();
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            var portData = new PortData {
                sztPortName = portName
            };
            var    size    = (uint)Marshal.SizeOf(portData);
            IntPtr pointer = Marshal.AllocHGlobal((int)size);

            Marshal.StructureToPtr(portData, pointer, true);

            uint status;

            try
            {
                IntPtr outputData;
                uint   outputNeeded;
                bool   isSuccess = XcvDataW(printerHandle, "AddPort", pointer, size, out outputData, 0, out outputNeeded, out status);

                if (!isSuccess)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }
            }
            finally
            {
                ClosePrinter(printerHandle);
                Marshal.FreeHGlobal(pointer);
            }

            if (status == 0)
            {
                return;
            }

            // HACK: Compensate for an incorrect error message from Windows.
            if (status == 183)
            {
                // TODO: Rexamine this case closer.
                // Swallow this error and keep going.
                //throw new Win32Exception("Cannot create a file when that file already exists.");
                return;
            }

            throw new Win32Exception(Marshal.GetLastWin32Error());
        }
Ejemplo n.º 17
0
        public void AddPortData(FieldInfo fi)
        {
            PortData pd = new PortData()
            {
                memberInfo = fi
            };

            portDatas.Add(pd);
        }
Ejemplo n.º 18
0
    IEnumerable <PortData> GetPortsForInputs(List <SerializableEdge> edges)
    {
        PortData pd = new PortData();

        foreach (var portData in portDatas)
        {
            yield return(portData);
        }
    }
Ejemplo n.º 19
0
        public void AddPortData(ValueInputDefinition vid)
        {
            PortData pd = new PortData()
            {
                vid = vid
            };

            portDatas.Add(pd);
        }
Ejemplo n.º 20
0
        public void AddPortData(PropertyInfo pi, IUnitPort unitPort)
        {
            PortData pd = new PortData()
            {
                memberInfo = pi,
                unitPort   = unitPort
            };

            portDatas.Add(pd);
        }
Ejemplo n.º 21
0
        /// <summary>
        ///     Complete a definition for a proxy custom node instance
        ///     by adding input and output ports as far as we don't have
        ///     a corresponding custom node workspace
        /// </summary>
        /// <param name="funcID">Identifier of the custom node instance</param>
        /// <param name="inputs">Number of inputs</param>
        /// <param name="outputs">Number of outputs</param>
        internal void LoadNode(Guid nodeId, int inputs, int outputs)
        {
            GUID = nodeId;

            // make the custom node instance be in sync
            // with its definition if it's needed
            if (!Controller.IsInSyncWithNode(this))
            {
                Controller.SyncNodeWithDefinition(this);
            }
            else
            {
                PortData data;
                if (outputs > 0)
                {
                    // create outputs for the node
                    for (int i = 0; i < outputs; i++)
                    {
                        data = new PortData("", "Output #" + (i + 1));
                        if (OutPortData.Count > i)
                        {
                            OutPortData[i] = data;
                        }
                        else
                        {
                            OutPortData.Add(data);
                        }
                    }
                }

                if (inputs > 0)
                {
                    // create inputs for the node
                    for (int i = 0; i < inputs; i++)
                    {
                        data = new PortData("", "Input #" + (i + 1));
                        if (InPortData.Count > i)
                        {
                            InPortData[i] = data;
                        }
                        else
                        {
                            InPortData.Add(data);
                        }
                    }
                }

                RegisterAllPorts();
            }

            //argument lacing on functions should be set to disabled
            //by default in the constructor, but for any workflow saved
            //before this was the case, we need to ensure it here.
            ArgumentLacing = LacingStrategy.Disabled;
        }
Ejemplo n.º 22
0
        public override PortData GetPortData(byte port)
        {
            float GetData(byte b)
            {
                var bytes = Device.WriteReadBytes(0x31, b)?.Skip(3).Take(2).ToArray();

                if (bytes == null || bytes.Length == 0)
                {
                    return(float.NaN);
                }

                var value    = bytes[1] << 8 | bytes[0];
                var exponent = (value & 0x7800) >> 11;
                var sign     = (value & 0x8000) >> 15;
                var fraction = (value & 0x7ff);

                if (sign == 1)
                {
                    exponent -= 16;
                }

                return((float)Math.Pow(2.0, exponent) * fraction);
            }

            var vin     = GetData(0x33);
            var vvOut12 = GetData(0x34);
            var vvOut5  = GetData(0x35);
            var vvOut33 = GetData(0x36);
            var viOut12 = GetData(0x37);
            var viOut5  = GetData(0x38);
            var viOut33 = GetData(0x39);
            var temp    = GetData(0x3a);
            var fanRpm  = GetData(0x3b);

            var watts = vvOut12 * viOut12 + vvOut5 * viOut5 + vvOut33 * viOut33;
            //var efficiency = lut[(int)(watts / 10.0)];

            var data = new PortData()
            {
                Temperature = temp,
                Rpm         = (int)fanRpm,
                ["VIN"]     = vin,
                ["VVOut12"] = vvOut12,
                ["VVOut5"]  = vvOut5,
                ["VVOut33"] = vvOut33,
                ["VIOut12"] = viOut12,
                ["VIOut5"]  = viOut5,
                ["VIOut33"] = viOut33,
                ["Watts"]   = watts,
            };

            return(data);
        }
Ejemplo n.º 23
0
        private void CreateNewConnection(Type connectionType, PortData sourcePortData, PortData targetPortData)
        {
            var connection = CreateInstance(connectionType) as NodeConnection;

            if (connection == null)
            {
                Debug.LogError("Create connection failed: " + connectionType);
                return;
            }

            connection.name  = connectionType.Name;
            connection.Graph = LoadedGraph;

            Node inNode;
            Node outNode;

            // add ports & modes
            if (sourcePortData.Direction == PortDirection.In)
            {
                connection.InPortId  = sourcePortData.PortId;
                connection.OutPortId = targetPortData.PortId;
                inNode  = LoadedGraph.Nodes[sourcePortData.NodeDataId].Node;
                outNode = LoadedGraph.Nodes[targetPortData.NodeDataId].Node;
            }
            else
            {
                connection.InPortId  = targetPortData.PortId;
                connection.OutPortId = sourcePortData.PortId;
                inNode  = LoadedGraph.Nodes[targetPortData.NodeDataId].Node;
                outNode = LoadedGraph.Nodes[sourcePortData.NodeDataId].Node;
            }

            // add nodes
            connection.FieldName = sourcePortData.FieldName;
            connection.OnConnect(outNode, inNode);

            // create ConnectionData
            var connectionData = new ConnectionData(connection, sourcePortData.FieldName);

            // add connection datas
            outNode.Outputs.Add(connectionData);
            inNode.Inputs.Add(connectionData);

            sourcePortData.Connections.Add(connectionData.ConnectionId);
            targetPortData.Connections.Add(connectionData.ConnectionId);
            LoadedGraph.Connections.Add(connectionData.ConnectionId, connectionData);

            AssetDatabase.AddObjectToAsset(connection, LoadedGraph);
            EditorUtility.SetDirty(LoadedGraph);
            AssetDatabase.SaveAssets();

            Repaint();
        }
Ejemplo n.º 24
0
    private string GetNeedCampText(PortData data)
    {
        PlayerData actorData = Globals.Instance.MGameDataManager.MActorData;

        string wordText = Globals.Instance.MDataTableManager.GetWordText(21800007);
        string col      = GUIFontColor.White;
        string val      = wordText;

        switch ((CampType)data.BasicData.CampRequire)
        {
        case CampType.ALLIED_POWERS:
        {
            wordText = Globals.Instance.MDataTableManager.GetWordText(21800008);

            if (actorData.BasicData.CampID == CampType.AXIS_POWSERS)
            {
                col = GUIFontColor.BloodRed;
            }
            break;
        }

        case CampType.AXIS_POWSERS:
        {
            wordText = Globals.Instance.MDataTableManager.GetWordText(21800009);

            if (actorData.BasicData.CampID == CampType.ALLIED_POWERS)
            {
                col = GUIFontColor.BloodRed;
            }
            break;
        }

        case CampType.NEUTRAL:
        {
            wordText = Globals.Instance.MDataTableManager.GetWordText(21800010);

            // if (actorData.PlayerCampID == CampType.AXIS_POWSERS)
            //  col = GUIFontColor.BloodRed;
            break;
        }

        case CampType.UNLIMIT:
        {
            wordText = Globals.Instance.MDataTableManager.GetWordText(21800011);
            break;
        }
        }

        val = val + col + wordText;
        return(val);
    }
Ejemplo n.º 25
0
        public ScanList(WorkspaceModel workspace) : base(workspace)
        {
            reductorPort = new PortData(
                "reductor",
                "Reductor Function: accepts one item from each list being reduced, and the current accumulated value, result is the new accumulated value.");

            InPortData.Add(reductorPort);
            InPortData.Add(new PortData("seed", "Starting accumulated value, to be passed into the first call to the Reductor function."));
            InPortData.Add(new PortData("list1", "List #1"));

            OutPortData.Add(new PortData("scanned", "Scanned lists"));

            RegisterAllPorts();
        }
Ejemplo n.º 26
0
        public override PortData GetPortData(byte port)
        {
            var result = Device.WriteReadBytes(0x33, 0x51, port);

            var data = new PortData
            {
                PortId      = result[3],
                Speed       = result[5],
                Rpm         = (result[7] << 8) + result[6],
                ["Unknown"] = result[4]
            };

            return(data);
        }
Ejemplo n.º 27
0
 public void Load(PortData data)
 {
     type       = data.type;
     connected  = data.connected;
     cable      = data.cable;
     device     = data.device;
     ip         = data.ip;
     mac        = data.mac;
     endPortMAC = data.endPortMAC;
     arpTable   = data.arpTable;
     //pc.Load(data.pc);
     //swit.Load(data.swit);
     //router.Load(data.router);
 }
Ejemplo n.º 28
0
    protected void Awake()
    {
        MActorData = new PlayerData();
        MEnemyData = new PlayerData();

        MCurrentSeaAreaData = new SeaAreaData();
        // Just for easy call
        MCurrentPortData = MCurrentSeaAreaData.MPortData;
        MCurrentCopyData = MCurrentSeaAreaData.MCurrentCopyData;

        MSeaAreaDataList = new Dictionary <int, SeaAreaData>();

        produceTeches   = new List <GameData.TechInfo>();
        warTeches       = new List <GameData.TechInfo>();
        formationTeches = new List <GameData.TechInfo>();
    }
Ejemplo n.º 29
0
    private string GetFightPropertyText(PortData data)
    {
        string val = "";

        if (data.BasicData.IsCanContest)
        {
            switch ((CampType)data.BasicData.CampID)
            {
            case CampType.ALLIED_POWERS:
            {
                val += GUIFontColor.Orange + Globals.Instance.MDataTableManager.GetWordText(21800004);
                break;
            }

            case CampType.AXIS_POWSERS:
            {
                val += GUIFontColor.Orange + Globals.Instance.MDataTableManager.GetWordText(21800005);
                break;
            }

            case CampType.NEUTRAL:
            {
                val += GUIFontColor.PureRed + Globals.Instance.MDataTableManager.GetWordText(21800003);
                break;
            }
            }
        }
        else
        {
            switch ((CampType)data.BasicData.CampID)
            {
            case CampType.ALLIED_POWERS:
            {
                val += GUIFontColor.Orange + Globals.Instance.MDataTableManager.GetWordText(21800001);
                break;
            }

            case CampType.AXIS_POWSERS:
            {
                val += GUIFontColor.Orange + Globals.Instance.MDataTableManager.GetWordText(21800002);
                break;
            }
            }
        }

        return(val);
    }
Ejemplo n.º 30
0
        private void _CompileToAstNodes(NodeModel node, List <AssociativeNode> resultList, bool isDeltaExecution)
        {
            var inputAstNodes = new List <AssociativeNode>();

            foreach (int index in Enumerable.Range(0, node.InPortData.Count))
            {
                Tuple <int, NodeModel> inputTuple;

                if (node.TryGetInput(index, out inputTuple))
                {
                    int             outputIndexOfInput = inputTuple.Item1;
                    NodeModel       inputModel         = inputTuple.Item2;
                    AssociativeNode inputNode          = inputModel.GetAstIdentifierForOutputIndex(outputIndexOfInput);
                    inputAstNodes.Add(inputNode);
                }
                else
                {
                    PortData port = node.InPortData[index];
                    inputAstNodes.Add(
                        port.HasDefaultValue
                            ? AstFactory.BuildPrimitiveNodeFromObject(port.DefaultValue)
                            : new NullNode());
                }
            }

            //TODO: This should do something more than just log a generic message. --SJE
            if (node.State == ElementState.Error)
            {
                dynSettings.Controller.DynamoLogger.Log("Error in Node. Not sent for building and compiling");
            }

            if (isDeltaExecution)
            {
                OnAstNodeBuilding(node.GUID);
            }

            IEnumerable <AssociativeNode> astNodes = node.BuildAst(inputAstNodes);

            if (astNodes != null && isDeltaExecution)
            {
                OnAstNodeBuilt(node.GUID, astNodes);
            }

            resultList.AddRange(astNodes ?? new AssociativeNode[0]);
        }
Ejemplo n.º 31
0
      /// <summary>
      /// Gets the result value from formula input field.
      /// The formula has a format like: [2](4) + [3](5), meaning take the first 4 characters from parameter with id #2
      /// and concatenate it with the first 5 characters of parameter with id #3.
      /// </summary>
      /// <param name="port">The test bench com port.</param>
      /// <param name="param">The parameter.</param>
      /// <returns>
      /// The concatenated result value.
      /// </returns>
      private static string GetResultValueFromFormula(PortData port, Parameter param)
      {
         var numberElements = param.TargetValue.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
         var resultValue = string.Empty;
         foreach (var token in numberElements)
         {
            var paramIdText = token.Substring(
               token.LastIndexOf('[') + 1, token.Length - token.LastIndexOf(']') - 3);
            paramIdText = paramIdText.Replace("[", string.Empty);
            paramIdText = paramIdText.Replace("]", string.Empty);
            long paramId;
            if (!long.TryParse(paramIdText, out paramId))
            {
               continue;
            }

            // find referenced parameter value by param id
            var refValue = port.ParameterList.FirstOrDefault(p => p.Id == (ParameterId)paramId);
            if (refValue == null)
            {
               continue;
            }

            // take the desired number of characters from the referenced parameter value
            var characterCountText = token.Substring(
               token.LastIndexOf('(') + 1, (token.LastIndexOf(')') - token.LastIndexOf('(') - 1));

            int characterCount;
            if (!int.TryParse(characterCountText, out characterCount))
            {
               continue;
            }

            // take not more characters as available to avoid ArgumentOutOfRangeException
            characterCount = refValue.TargetValue.Length < characterCount ? refValue.TargetValue.Length : characterCount;

            var s = refValue.TargetValue.Substring(0, characterCount);
            resultValue += s;
         }

         return resultValue;
      }
Ejemplo n.º 32
0
        public void AddDeletePrinterPort(string portName, string monitorName, bool deletePort = false)
        {
            IntPtr printerHandle;
            PrinterDefaults defaults = new PrinterDefaults { DesiredAccess = PrinterAccess.ServerAdmin };
            if (!OpenPrinter(",XcvMonitor " + monitorName, out printerHandle, ref defaults))
                throw new Exception("Could not open printer for the monitor port " + monitorName + "!");

            try
            {
                PortData portData = new PortData { sztPortName = portName };
                uint size = (uint)Marshal.SizeOf(portData);
                IntPtr pointer = Marshal.AllocHGlobal((int)size);
                Marshal.StructureToPtr(portData, pointer, true);
                IntPtr outputData;
                UInt32 outputNeeded, status;
                if (!XcvDataW(printerHandle, deletePort ? "DeletePort" : "AddPort", pointer, size, out outputData, 0, out outputNeeded, out status))
                    throw new Exception(status.ToString());
            }
            finally
            {
                ClosePrinter(printerHandle);
            }
        }
Ejemplo n.º 33
0
            public override void LoadElement(XmlNode elNode)
            {
                foreach (XmlNode subNode in elNode.ChildNodes)
                {
                    if (subNode.Name.Equals("Name"))
                    {
                        NickName = subNode.Attributes[0].Value;
                    }
                }

                foreach (XmlNode subNode in elNode.ChildNodes)
                {
                    if (subNode.Name.Equals("ID"))
                    {
                        Symbol = subNode.Attributes[0].Value;

                        Guid funcId;
                        Guid.TryParse(Symbol, out funcId);

                        // if the dyf does not exist on the search path...
                        if (!dynSettings.Controller.CustomNodeLoader.Contains(funcId))
                        {
                            var proxyDef = new FunctionDefinition(funcId);
                            proxyDef.Workspace = new FuncWorkspace(NickName, BuiltinNodeCategories.SCRIPTING_CUSTOMNODES);
                            proxyDef.Workspace.FilePath = null;

                            this.SetInputs(new List<string>());
                            this.SetOutputs(new List<string>());
                            this.RegisterAllPorts();
                            this.State = ElementState.ERROR;

                            var user_msg = "Failed to load custom node: " + NickName +
                                           ".  Replacing with proxy custom node.";

                            DynamoLogger.Instance.Log(user_msg);

                            // tell custom node loader, but don't provide path, forcing user to resave explicitly
                            dynSettings.Controller.CustomNodeLoader.SetFunctionDefinition(funcId, proxyDef);
                            Definition = dynSettings.Controller.CustomNodeLoader.GetFunctionDefinition(funcId);
                            ArgumentLacing = LacingStrategy.Disabled;
                            return;
                        }
                    }
                }

                foreach (XmlNode subNode in elNode.ChildNodes)
                {
                    if (subNode.Name.Equals("Outputs"))
                    {
                        int i = 0;
                        foreach (XmlNode outputNode in subNode.ChildNodes)
                        {
                            var data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1), typeof(object));

                            if (OutPortData.Count > i)
                            {
                                OutPortData[i] = data;
                            }
                            else
                            {
                                OutPortData.Add(data);
                            }

                            i++;
                        }
                    }
                    else if (subNode.Name.Equals("Inputs"))
                    {
                        int i = 0;
                        foreach (XmlNode inputNode in subNode.ChildNodes)
                        {
                            var data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1), typeof(object));

                            if (InPortData.Count > i)
                            {
                                InPortData[i] = data;
                            }
                            else
                            {
                                InPortData.Add(data);
                            }

                            i++;
                        }
                    }
                    #region Legacy output support
                    else if (subNode.Name.Equals("Output"))
                    {
                        var data = new PortData(subNode.Attributes[0].Value, "function output", typeof(object));

                        if (OutPortData.Any())
                            OutPortData[0] = data;
                        else
                            OutPortData.Add(data);
                    }
                    #endregion
                }

                RegisterAllPorts();

                //argument lacing on functions should be set to disabled
                //by default in the constructor, but for any workflow saved
                //before this was the case, we need to ensure it here.
                ArgumentLacing = LacingStrategy.Disabled;

                // we've found a custom node, we need to attempt to load its guid.
                // if it doesn't exist (i.e. its a legacy node), we need to assign it one,
                // deterministically
                Guid funId;
                try
                {
                    funId = Guid.Parse(Symbol);
                }
                catch
                {
                    funId = GuidUtility.Create(GuidUtility.UrlNamespace, elNode.Attributes["nickname"].Value);
                    Symbol = funId.ToString();
                }

                Definition = dynSettings.Controller.CustomNodeLoader.GetFunctionDefinition(funId);
            }
Ejemplo n.º 34
0
            public override void LoadElement(XmlNode elNode)
            {
                foreach (XmlNode subNode in elNode.ChildNodes)
                {
                    if (subNode.Name.Equals("ID"))
                    {
                        Symbol = subNode.Attributes[0].Value;
                        //Definition = dynSettings.FunctionDict.Values.FirstOrDefault(
                        //    x => x.Workspace.Name == subNode.Attributes[0].Value);
                    }
                    else if (subNode.Name.Equals("Name"))
                    {
                        NickName = subNode.Attributes[0].Value;
                    }
                    else if (subNode.Name.Equals("Outputs"))
                    {
                        int i = 0;
                        foreach (XmlNode outputNode in subNode.ChildNodes)
                        {
                            var data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1), typeof(object));

                            if (OutPortData.Count > i)
                            {
                                OutPortData[i] = data;
                            }
                            else
                            {
                                OutPortData.Add(data);
                            }

                            i++;
                        }
                    }
                    else if (subNode.Name.Equals("Inputs"))
                    {
                        int i = 0;
                        foreach (XmlNode inputNode in subNode.ChildNodes)
                        {
                            var data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1), typeof(object));

                            if (InPortData.Count > i)
                            {
                                InPortData[i] = data;
                            }
                            else
                            {
                                InPortData.Add(data);
                            }

                            i++;
                        }
                    }
                    #region Legacy output support
                    else if (subNode.Name.Equals("Output"))
                    {
                        var data = new PortData(subNode.Attributes[0].Value, "function output", typeof(object));

                        if (OutPortData.Any())
                            OutPortData[0] = data;
                        else
                            OutPortData.Add(data);
                    }
                    #endregion
                }

                RegisterAllPorts();
            }