Exemplo n.º 1
0
        public CyCustErr CustomizeShapes(
            ICyInstQuery_v1 instQuery,
            ICySymbolShapeEdit_v1 shapeEdit,
            ICyTerminalEdit_v1 termEdit)
        {
            CyCompDevParam width_param = instQuery.GetCommittedParam("Width");
            int            terminal_width;
            CyCustErr      err = width_param.TryGetValueAs <int>(out terminal_width);

            if (err.IsNotOk)
            {
                return(err);
            }

            // Shape the width of the data buses
            string suffix = (terminal_width > 1) ? string.Format("[{0}:0]", terminal_width - 1) : string.Empty;

            string term_name = termEdit.GetTermName("slope");

            termEdit.TerminalRename(term_name, term_name + suffix);

            term_name = termEdit.GetTermName("value");
            termEdit.TerminalRename(term_name, term_name + suffix);

            return(CyCustErr.OK);
        }
Exemplo n.º 2
0
        const string OUTPUT_TERM_NAME_2 = "out2"; //out2 terminal


        public CyCustErr CustomizeShapes(ICyInstQuery_v1 instQuery, ICySymbolShapeEdit_v1 shapeEdit,
                                         ICyTerminalEdit_v1 termEdit)
        {
            CyCustErr err;

            // We leave the symbol as it is for symbol preview
            if (instQuery.IsPreviewCanvas)
            {
                return(CyCustErr.OK);
            }

            //todo: if single output -> name it "out" instead of "out1"

            // Read Parameters
            CyCompDevParam outWidthParam1  = instQuery.GetCommittedParam("out1_width");
            byte           outWidth1       = byte.Parse(outWidthParam1.Value);
            byte           maxOutBitIndex1 = (byte)(outWidth1 - 1);
            string         outTermName1    = termEdit.GetTermName(OUTPUT_TERM_NAME_1);

            if (maxOutBitIndex1 != 0)
            {
                err = termEdit.TerminalRename(outTermName1, string.Format("{0}[{1}:0]", OUTPUT_TERM_NAME_1, maxOutBitIndex1.ToString()));
            }
            else
            {
                err = termEdit.TerminalRename(outTermName1, string.Format("{0}", OUTPUT_TERM_NAME_1));
            }

            if (err.IsNotOK)
            {
                return(err);
            }



            // Read Parameters
            CyCompDevParam outWidthParam2  = instQuery.GetCommittedParam("out2_width");
            byte           outWidth2       = byte.Parse(outWidthParam2.Value);
            byte           maxOutBitIndex2 = (byte)(outWidth2 - 1);
            string         outTermName2    = termEdit.GetTermName(OUTPUT_TERM_NAME_2);

            if (maxOutBitIndex2 != 0)
            {
                err = termEdit.TerminalRename(outTermName2, string.Format("{0}[{1}:0]", OUTPUT_TERM_NAME_2, maxOutBitIndex2.ToString()));
            }
            else
            {
                err = termEdit.TerminalRename(outTermName2, string.Format("{0}", OUTPUT_TERM_NAME_2));
            }

            if (err.IsNotOK)
            {
                return(err);
            }



            return(CyCustErr.OK);
        }