Example #1
0
        //============================================================================
        /// <summary>
        /// Uses the copy constructor to make a clone of a typedvalue's structure.
        /// It is then added as a member to an array or record.
        /// this virtual function is expected to be overriden so that new members are
        /// of the child classes' type.
        /// </summary>
        /// <param name="bluePrintValue">Use this TTypedValue as the blue print.</param>
        // N.Herrmann Apr 2002
        //============================================================================
        public override void newMember(TTypedValue bluePrintValue)
        {
            TDDMLValue newElement;

            newElement = new TDDMLValue(bluePrintValue); //calls copy constructor
            addMember(newElement);                       //add the copy
        }
Example #2
0
        //=======================================================================
        /// <summary>
        /// Creates a driving property object using the XML describing the property.
        /// </summary>
        /// <param name="sXML">XML for the driving property containing the DDML type.</param>
        //=======================================================================
        public TCompDriver(String sXML)
        {
            TSDMLParser parser;
            XmlNode     anode;
            String      sBuf;

            sDescr     = "";
            sFullDescr = "";

            parser   = new TSDMLParser(sXML);
            anode    = parser.firstElementChild(parser.rootNode(), "type");
            initType = new TDDMLValue(parser, anode, "");

            FName         = parser.getAttrValue(parser.rootNode(), "name");
            initType.Name = FName;
            sDescr        = parser.getAttrValue(parser.rootNode(), "descr");

            FMinConn = 1; // Default
            sBuf     = parser.getAttrValue(parser.rootNode(), "minsrc");
            if (sBuf.Trim().Length > 0)
            {
                FMinConn = Convert.ToInt32(sBuf);
            }
            FMaxConn = 1; // Default
            sBuf     = parser.getAttrValue(parser.rootNode(), "maxsrc");
            if (sBuf.Trim().Length > 0)
            {
                FMaxConn = Convert.ToInt32(sBuf);
            }
            anode = parser.firstElementChild(parser.rootNode(), "description");
            if (anode != null)
            {
                sFullDescr = parser.getText(anode);
            }
        }
Example #3
0
        //==============================================================================
        /// <summary>
        /// Convert an init script into the relevant properties.
        /// </summary>
        /// <param name="sScriptName">Name of the script.</param>
        /// <param name="sScriptText">XML text of the init script
        /// &lt;initsection&gt;
        ///      &lt;init..... /&gt;
        ///   &lt;/initsection&gt;
        ///</param>
        // N.Herrmann Feb 2007
        //==============================================================================
        public void textToInitScript(string sScriptName, string sScriptText)
        {
            uint       initCount;
            string     buf;
            uint       i;
            TDDMLValue ddmlVal;
            TSDMLValue sdmlVal;

            Byte []     data;
            TInitParser initSection;

            int index = getScriptIndex(sScriptName);

            if (index < 0)
            {
                createInitScript(sScriptName);
            }

            scriptList[index].scriptText = sScriptText;          //set the text string for the script
            scriptList[index].propertyList.Clear();              //remove all the properties
            //now get all the sdml properties from the initsection
            initSection = new TInitParser(sScriptText);          //parse the <initsection>
            ddmlVal     = new TDDMLValue("<empty/>", "defined"); //used for getting the ddml type
            initCount   = initSection.initCount();
            for (i = 1; i <= initCount; i++)
            {                                                       //for each init value
                buf     = initSection.initText(i);                  //the sdml xml
                sdmlVal = new TSDMLValue(buf, "");                  //new sdml type
                data    = new Byte[sdmlVal.sizeBytes()];
                sdmlVal.getData(ref data);                          //get the datablock
                //add this property to the script. (a little inneficient here)
                valueToInitScript(sScriptName, sdmlVal.Name, ddmlVal.getText(sdmlVal, 0, 2), data);
            }
        }
Example #4
0
        //============================================================================
        /// <summary>
        /// Set the default value and range based on the scalar type.
        /// </summary>
        //============================================================================
        protected void makeDefaultAndRange()
        {
            if (FBaseType != TTypedValue.TBaseType.ITYPE_DEF)
            {                                                    // Default value is automatically set
                FDefault = new TDDMLValue("default", FBaseType); //   to zero/FALSE/null string
                parseRangeValue("defval", FDefault);
            }

            if ((FBaseType < TTypedValue.TBaseType.ITYPE_INT1) || (FBaseType > TTypedValue.TBaseType.ITYPE_DOUBLE))
            {  //Only numeric types have max & min values
                FMax = null;
                FMin = null;
            }
            else
            {
                FMax = new TDDMLValue("maxval", FBaseType);
                FMin = new TDDMLValue("minval", FBaseType);
                switch (FBaseType)
                {
                case TTypedValue.TBaseType.ITYPE_INT1:
                {
                    FMax.setValue(+VERYLARGE_I1);
                    FMin.setValue(-VERYLARGE_I1);
                } break;

                case TTypedValue.TBaseType.ITYPE_INT2:
                {
                    FMax.setValue(+VERYLARGE_I2);
                    FMin.setValue(-VERYLARGE_I2);
                } break;

                case TTypedValue.TBaseType.ITYPE_INT4:
                {
                    FMax.setValue(+VERYLARGE_I4);
                    FMin.setValue(-VERYLARGE_I4);
                } break;

                case TTypedValue.TBaseType.ITYPE_INT8:
                {
                    FMax.setValue(+VERYLARGE_I8);
                    FMin.setValue(-VERYLARGE_I8);
                } break;

                case TTypedValue.TBaseType.ITYPE_SINGLE:
                {
                    FMax.setValue(+1.0 * VERYLARGE_S);
                    FMin.setValue(-1.0 * VERYLARGE_S);
                } break;

                case TTypedValue.TBaseType.ITYPE_DOUBLE:
                {
                    FMax.setValue(VERYLARGE_D_POS);
                    FMin.setValue(VERYLARGE_D_NEG);
                } break;
                }
                parseRangeValue("maxval", FMax);
                parseRangeValue("minval", FMin);
            }
        }
Example #5
0
 //============================================================================
 /// <summary>
 /// Default constructor
 /// </summary>
 //============================================================================
 public TInitValue()
     : base("", "")
 {
     //FMax = null;
     //FMin = null;
     FDefault = null;
     FDescr   = "";
 }
Example #6
0
 //============================================================================
 /// <summary>
 /// Creates a one dimensional array of arbitrary items.
 /// </summary>
 /// <param name="sArrayName">Name of this array.</param>
 /// <param name="baseValue">Use as the base type of the array elements.</param>
 /// <param name="iNoElements">Create it with this number of elements.</param>
 //============================================================================
 public TInitValue(String sArrayName, TTypedValue baseValue, int iNoElements)
     : base(sArrayName, baseValue, iNoElements)
 {
     //FMax = null;
     //FMin = null;
     FDefault = null;
     newMember(baseValue);
     setElementCount((uint)iNoElements);
 }
Example #7
0
 //===========================================================================
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="bluePrintValue"></param>
 //===========================================================================
 public TCompDriver(TCompDriver bluePrintValue)
 {
     initType   = new TDDMLValue(bluePrintValue.initType);
     FMinConn   = bluePrintValue.MinConn;
     FMaxConn   = bluePrintValue.MaxConn;
     FConnCount = bluePrintValue.ConnCount;
     sDescr     = bluePrintValue.sDescr;
     sFullDescr = bluePrintValue.sFullDescr;
 }
Example #8
0
 //=======================================================================
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="bluePrintValue"></param>
 //=======================================================================
 public TCompEvent(TCompEvent bluePrintValue)
 {
     initType     = new TDDMLValue(bluePrintValue.initType);
     bIsEmpty     = bluePrintValue.isEmpty;
     sKind        = bluePrintValue.sKind;
     bIncSequence = bluePrintValue.bIncSequence;
     order        = bluePrintValue.order;
     sDescr       = bluePrintValue.sDescr;
     sFullDescr   = bluePrintValue.sFullDescr;
 }
Example #9
0
 //============================================================================
 /// <summary>
 /// Creates a one dimensional array of scalar items.
 /// </summary>
 /// <param name="sArrayName">Name of this array.</param>
 /// <param name="aBaseType">Set the base type of this array.</param>
 /// <param name="iNoElements">Create it with this number of elements.</param>
 //============================================================================
 public TInitValue(String sArrayName, TBaseType aBaseType, int iNoElements)
     : base(sArrayName, aBaseType, iNoElements)
 {
     //FMax = null;
     //FMin = null;
     FDefault = null;
     //required in this derived class
     //add array elements which are scalars
     addScalar("", aBaseType);     //calls suitable virtual function
     setElementCount((uint)iNoElements);
 }
Example #10
0
 //============================================================================
 /// <summary>
 /// Creates a scalar of this iBaseType with sName.
 /// </summary>
 /// <param name="sName">Name of the scalar.</param>
 /// <param name="aBaseType">Base type of this scalar.</param>
 //============================================================================
 public TInitValue(String sName, TBaseType aBaseType)
     : base(sName, aBaseType)
 {
     //FMax = null;
     //FMin = null;
     FDefault = null;
     FDescr   = "";
     //required in this derived class
     //create a scalar type of TTypedValue
     constructScalar(sName, aBaseType); //calls suitable virtual functions
 }
Example #11
0
 //=======================================================================
 /// <summary>
 /// A copy constructor for the TMEvent.
 /// </summary>
 /// <param name="anEvent">Event to copy</param>
 //=======================================================================
 public TMEvent(TMEvent anEvent)
     : base(anEvent)
 {
     requestList = new List <uint>();
     //copy all the attributes of 'event'
     eventName      = anEvent.eventName;
     parentComp     = anEvent.parentComp;
     parentMgr      = anEvent.parentMgr;
     eventID        = anEvent.eventID;
     FParams        = anEvent.FParams; //should I be making a copy? (probably not. It is owned by the comp)
     waiting        = false;           //not waiting for msg returns
     nextEventState = anEvent.nextEventState;
 }
Example #12
0
        //============================================================================
        /// <summary>
        /// Construct this object using the parser already created in the parent. Also
        /// use the dom node, baseNode to be the root node of the document for this
        /// new typed value. Can also specify the base type using sBaseType.
        /// </summary>
        /// <param name="parentParser">The parent's parser.</param>
        /// <param name="baseNode">DOM node to use as the root node.</param>
        /// <param name="sBaseType">Used to set the base type.</param>
        //============================================================================
        public TInitValue(TSDMLParser parentParser, XmlNode baseNode, String sBaseType)
            : base(parentParser, baseNode, sBaseType)
        {
            //FMax = null;
            //FMin = null;
            FDefault = null;

            //required in this derived class
            buildType(parentParser, baseNode);  //calls suitable virtual functions

            if (isArray())                      // default array length is zero
            {
                setElementCount(0);
            }
        }
Example #13
0
        //============================================================================
        /// <summary>
        /// Adds a scalar to an array or record.
        /// </summary>
        /// <param name="sName">Name of the scalar.</param>
        /// <param name="aType">The basic type for this scalar.</param>
        /// <returns>A ref to the newly created scalar.</returns>
        //============================================================================
        public override TTypedValue addScalar(String sName, TBaseType aType)
        {
            TDDMLValue newScalar;

            TTypedValue result = null;

            if (FIsArray || FIsRecord)
            {
                newScalar = new TDDMLValue(sName, aType);
                addMember(newScalar);
                result = newScalar;
            }

            return(result);
        }
Example #14
0
        //============================================================================
        /// <summary>
        /// Constructs a typed value using an XML description.
        /// </summary>
        /// <param name="sXML">XML text description.</param>
        /// <param name="sBaseType">Set the base type of this object.</param>
        //============================================================================
        public TInitValue(String sXML, String sBaseType)
            : base(sXML, sBaseType)
        {
            //FMax = null;
            //FMin = null;
            FDefault = null;

            //required in this derived class
            buildType(sXML);                   //calls suitable virtual functions

            if (isArray())                     // default array length is zero
            {
                setElementCount(0);
            }
        }
Example #15
0
        //============================================================================
        /// <summary>
        /// Builds the list of children typed values.
        /// </summary>
        //============================================================================
        protected override void getFldElemList()
        {
            TDDMLValue newMember;
            XmlNode    memberNode;

            //builds the child list using the parent's parser and just shifts the
            //parser's topElement domnode respectively.
            memberNode = parser.firstMember(parser.rootNode());
            while (memberNode != null)
            {
                newMember = new TDDMLValue(parser, memberNode, "");
                FMembers.Add(newMember);  //add to the list of children

                memberNode = parser.nextMember(memberNode);
            }
        }
Example #16
0
        //============================================================================
        /// <summary>
        /// Begins the event processing. Assumes that the event is IDLE.
        /// </summary>
        /// <param name="evParams">Parameters that have been sent for this event.</param>
        //============================================================================
        public void beginEvent(TDDMLValue evParams)
        {
            if (getCurrentState() == IDLE)
            {
                FParams = evParams;                 //store the event parameters from the doEvent --who owns this? (the comp)

                startMachine();                     //set currentState to the next state
                nextEventState = getCurrentState(); //set the state to resume from

                resume();                           //restarts the state processing at the nextEventState
            }
            else
            {
                throw (new ApplicationException("Error in beginEvent(). You cannot begin a running event!"));
            }
        }
Example #17
0
        //==============================================================================
        /// <summary>
        /// Add the property. If it exists then overwrite it.
        /// </summary>
        /// <param name="sScriptName">Name of the script.</param>
        /// <param name="sPropertyName">Name of the property.</param>
        /// <param name="sTypeDDML">DDML type</param>
        /// <param name="pValueData">Data block.</param>
        // N.Herrmann Feb 2007
        //==============================================================================
        public void valueToInitScript(string sScriptName, string sPropertyName, string sTypeDDML, Byte [] pValueData)
        {
            TScriptProperty prop;
            TDDMLValue      ddmlVal;
            uint            blocksize;
            int             i;

            int index = getScriptIndex(sScriptName);

            if (index >= 0)
            {
                prop = new TScriptProperty();

                prop.ddmlType = sTypeDDML;                        //store a copy of the type descr
                prop.name     = sPropertyName;
                ddmlVal       = new TDDMLValue(sTypeDDML, "");
                ddmlVal.setData(pValueData, pValueData.Length, 0);   //store the ddml value
                prop.sdmlType  = FSDMLWriter.getText(ddmlVal, 2, 2); //store the sdml value description
                blocksize      = ddmlVal.sizeBytes();                //now I know the size of the type
                prop.datablock = new Byte[blocksize];                //allocate mem
                for (i = 0; i < blocksize; i++)
                {
                    prop.datablock[i] = pValueData[i];            //copy the bytes
                }

                //add/overwrite the property values
                //search firstly for the property item that may exist
                int propIndex = getProperty(scriptList[index], sPropertyName);
                if (propIndex < 0)
                {
                    (scriptList[index]).propertyList.Add(prop); //and add it to the list
                }
                else
                {
                    (scriptList[index]).propertyList[index] = prop;
                }

                if (FRunningRebuild)
                {
                    buildScript(index);                           //update the scriptText
                }
                else
                {
                    (scriptList[index]).propertyChanged = true;
                }
            }
        }
Example #18
0
        //============================================================================
        /// <summary>
        /// Copy constructor. This constructor makes a copy of the source's structure.
        /// For specialised child classes, this constructor should be overriden.
        /// </summary>
        /// <param name="typedValue">TTypedValue to use as the source.</param>
        //============================================================================
        public TInitValue(TTypedValue typedValue)
            : base(typedValue)
        {
            //FMax = null;
            //FMin = null;
            FDefault = null;
            FDescr   = "";
            //required in this derived class
            initTypeCopy(typedValue);  //calls suitable virtual functions

            TInitValue other = (TInitValue)typedValue;

            if (other != null)
            {
                if (other.FDefault != null)
                {
                    if (FDefault == null)
                    {
                        FDefault = new TDDMLValue("defval", FBaseType);
                    }
                    FDefault.copyFrom(other.FDefault);
                }
                if (other.FMin != null)
                {
                    if (FMin == null)
                    {
                        FMin = new TDDMLValue("minval", FBaseType);
                    }
                    FMin.copyFrom(other.FMin);
                }
                if (other.FMax != null)
                {
                    if (FMax == null)
                    {
                        FMax = new TDDMLValue("maxval", FBaseType);
                    }
                    FMax.copyFrom(other.FMax);
                }
                setDescr(other.getDescr(), 255);
            }
        }
Example #19
0
        //=======================================================================
        /// <summary>
        /// Construct a component event object using XML description.
        /// </summary>
        /// <param name="sXML">XML description that contains the DDML of the type.</param>
        //=======================================================================
        public TCompEvent(String sXML)
        {
            TXMLParser parser;
            XmlNode    anode;
            String     typeText;

            parser     = new TXMLParser(sXML);
            sDescr     = "";
            sFullDescr = "";

            //build a DDML type from the values in the event description
            typeText = "<type>";
            anode    = parser.firstElementChild(parser.rootNode(), "field");
            bIsEmpty = (anode == null);
            while (anode != null)
            {
                typeText = typeText + parser.docToString(anode);
                anode    = parser.nextElementSibling(anode, "field");
            }
            typeText = typeText + "</type>";

            initType = new TDDMLValue(typeText, "");                   //create as a DDML type
            Name     = parser.getAttrValue(parser.rootNode(), "name"); //set this object's attributes
            sKind    = parser.getAttrValue(parser.rootNode(), "kind");
            sDescr   = parser.getAttrValue(parser.rootNode(), "descr");

            if (sKind.Length < 1)
            {
                sKind = "published";      // Default when not specified
            }
            order = 0;                    //init to an invalid value
            anode = parser.firstElementChild(parser.rootNode(), "description");
            if (anode != null)
            {
                sFullDescr = parser.getText(anode);
            }
        }
Example #20
0
        //============================================================================
        /// <summary>
        /// Starts an execution of an event. If an event object exists and is idle, it
        /// is started. To allow for threaded processing, a new event object will be
        /// created if none are found to be idle.
        /// </summary>
        /// <param name="iRegID">ID of the event.</param>
        /// <param name="iSender">Component ID requesting the event.</param>
        /// <param name="iPublisher">Component that published this event.</param>
        /// <param name="iMsgID">Message ID of this event msg.</param>
        /// <param name="dataParams">Param data.</param>
        /// <param name="bNotify"> </param>
        //============================================================================
        public void beginEvent(int iRegID, uint iSender, uint iPublisher, uint iMsgID, TDDMLValue dataParams, bool bNotify)
        {
            bool    found       = false;
            TMEvent anEvent     = null;
            TMEvent eventToCopy = null;

            string errorMsg;

            int i = 0;

            //look through the list of defined events to see if one is available to run
            while ((!found) && (i < eventList.Count))
            {
                anEvent = (TMEvent)eventList[i];
                if ((uint)(anEvent.getEventID()) == iRegID)                    //if the event is the correct type
                {
                    found = (anEvent.getCurrentState() == TStateMachine.IDLE); //if it is idle, use this event
                    if (!found)
                    {
                        eventToCopy = anEvent;
                    }
                }
                i++;
            }

            //create a copy of a non idle event if necessary
            if (!found)
            {
                if (eventToCopy == null)
                {
                    errorMsg = String.Format("No event registered for {0}", iRegID);
                    throw (new ApplicationException(errorMsg));
                }
                anEvent = new TMEvent(eventToCopy);
            }

            anEvent.iPublisher = iPublisher;
            anEvent.bNotify    = bNotify;    // set up info for later acknowledgement
            anEvent.iNotifyTo  = iSender;
            anEvent.iNotifyMsg = iMsgID;
            anEvent.beginEvent(dataParams);  //now activate the event
        }