/// <summary>
        /// The constructor for the element.
        /// Called at runtime when the element is first referenced.
        /// </summary>
        /// <param name="data"></param>
        public MqttSubscriberElement(IElementData data)
        {
            _data = data;

            _props = _data.Properties;

            // The IElementData contains a reference to the execution context
            var context = _data.ExecutionContext;

            prServerElement = (IElementProperty)_props.GetProperty("MqttServer");
            MqttConnector   = (MqttSubscribeConnector)prServerElement.GetElement(context);

            // Get the Property Readers
            IPropertyReader prTopic = _data.Properties.GetProperty("Topic");

            // Place simio events into a lookup array that will be used at runtime.
            TopicEventList = new List <IEvent>();

            foreach (var eventDef in _data.Events)
            {
                TopicEventList.Add(eventDef);
            }

            LogIt($"SubscriberElement Start: Url={MqttConnector.ServerUrl} Port={MqttConnector.ServerPort} ");

            SubscribeTopic = prTopic.GetStringValue(_data.ExecutionContext);
        }
Exemple #2
0
        /// <summary>
        /// Constructor. Create property readers
        /// Called when this Step is inserted into a Process.
        /// Create all of the needed Property Readers.
        /// </summary>
        /// <param name="properties"></param>
        public MqttPublishExpressionStep(IPropertyReaders properties)
        {
            _props = properties;

            prServerElement = (IElementProperty)_props.GetProperty("MqttServer");
            prTopic         = (IPropertyReader)_props.GetProperty("MqttTopic");
            prPayload       = (IPropertyReader)_props.GetProperty("MqttPayload");
        }
 public ExcelWriteStep(IPropertyReaders properties)
 {
     _props                   = properties;
     _worksheetProp           = _props.GetProperty("Worksheet");
     _rowProp                 = _props.GetProperty("Row");
     _startingColumnProp      = _props.GetProperty("StartingColumn");
     _ExcelconnectElementProp = (IElementProperty)_props.GetProperty("ExcelConnectEPPlus");
     _items                   = (IRepeatingPropertyReader)_props.GetProperty("Items");
 }
Exemple #4
0
 public ExcelReadStep(IPropertyReaders properties)
 {
     _propReaders          = properties;
     prWorksheet           = _propReaders.GetProperty("Worksheet");
     prRow                 = _propReaders.GetProperty("Row");
     prStartingColumn      = _propReaders.GetProperty("StartingColumn");
     prExcelconnectElement = (IElementProperty)_propReaders.GetProperty("ExcelConnectEPPlus");
     rprStates             = (IRepeatingPropertyReader)_propReaders.GetProperty("States");
 }
Exemple #5
0
 public AgentWaitStep(IPropertyReaders properties)
 {
     _properties      = properties;
     _agentProperty   = (IElementProperty)_properties.GetProperty("AgentConnection");
     _statesProperty  = (IRepeatingPropertyReader)_properties.GetProperty("States");
     _actionProperty  = (IStateProperty)_properties.GetProperty("Action");
     _rewardProperty  = (IStateProperty)_properties.GetProperty("Reward");
     _episodeProperty = (IStateProperty)_properties.GetProperty("EpisodeNumber");
     _statusProperty  = (IStateProperty)_properties.GetProperty("Status");
 }
Exemple #6
0
        /// <summary>
        /// Method called when a process token executes the step.
        /// </summary>
        public ExitType Execute(IStepExecutionContext context)
        {
            // Example of how to get the value of a step property.
            IPropertyReader myExpressionProp = _properties.GetProperty("MyExpression") as IPropertyReader;
            string myExpressionPropStringValue = myExpressionProp.GetStringValue(context);
            double myExpressionPropDoubleValue = myExpressionProp.GetDoubleValue(context);

            // Example of how to get an element reference specified in an element property of the step.
            IElementProperty myElementProp = (IElementProperty)_properties.GetProperty("UserElementName");
            //UserElement myElement = (UserElement)myElementProp.GetElement(context);

            // Example of how to display a trace line for the step.
            context.ExecutionInformation.TraceInformation(String.Format("The value of expression '{0}' is '{1}'.", myExpressionPropStringValue, myExpressionPropDoubleValue));

            return ExitType.FirstExit;
        }
        /// <summary>
        /// Method called when a process token executes the step.
        /// </summary>
        public ExitType Execute(IStepExecutionContext context)
        {
            bool intersects = false;

            // Example of how to get the value of a step property.
            IPropertyReader myExpressionProp            = _properties.GetProperty("MyExpression") as IPropertyReader;
            string          myExpressionPropStringValue = myExpressionProp.GetStringValue(context);
            double          myExpressionPropDoubleValue = myExpressionProp.GetDoubleValue(context);

            // Example of how to get an element reference specified in an element property of the step.
            IElementProperty myElementProp = (IElementProperty)_properties.GetProperty("UserElementName");
            UserElement      myElement     = (UserElement)myElementProp.GetElement(context);

            // Example of how to display a trace line for the step.
            context.ExecutionInformation.TraceInformation(String.Format("The value of expression '{0}' is '{1}'.", myExpressionPropStringValue, myExpressionPropDoubleValue));

            origin[0] = _properties.GetProperty("Ox").GetDoubleValue(context);
            origin[1] = _properties.GetProperty("Oy").GetDoubleValue(context);
            origin[2] = _properties.GetProperty("Oz").GetDoubleValue(context);

            ray[0] = _properties.GetProperty("Rx").GetDoubleValue(context);
            ray[1] = _properties.GetProperty("Ry").GetDoubleValue(context);
            ray[2] = _properties.GetProperty("Rz").GetDoubleValue(context);

            boxMin[0] = _properties.GetProperty("B0x").GetDoubleValue(context);
            boxMin[1] = _properties.GetProperty("B0y").GetDoubleValue(context);
            boxMin[2] = _properties.GetProperty("B0z").GetDoubleValue(context);

            boxMax[0] = _properties.GetProperty("B1x").GetDoubleValue(context);
            boxMax[1] = _properties.GetProperty("B1y").GetDoubleValue(context);
            boxMax[2] = _properties.GetProperty("B1z").GetDoubleValue(context);

            double tmin = (boxMin[0] - origin[0]) / ray[0];
            double tmax = (boxMax[0] - origin[0]) / ray[0];

            if (tmin > tmax)
            {
                Swap <double>(ref tmin, ref tmax);
            }

            double tymin = (boxMin[1] - origin[1]) / ray[1];
            double tymax = (boxMax[1] - origin[1]) / ray[1];

            if (tymin > tymax)
            {
                Swap <double>(ref tymin, ref tymax);
            }

            if ((tmin > tymax) || (tymin > tmax))
            {
                return(ExitType.AlternateExit);
            }

            if (tymin > tmin)
            {
                tmin = tymin;
            }
            if (tymax < tmax)
            {
                tmax = tymax;
            }

            double tzmin = (boxMin[2] - origin[2]) / ray[2];
            double tzmax = (boxMax[2] - origin[2]) / ray[2];

            if (tzmin > tzmax)
            {
                Swap <double>(ref tzmin, ref tzmax);
            }

            if ((tmin > tzmax) || (tzmin > tmax))
            {
                return(ExitType.AlternateExit);
            }

            if (tzmin > tmin)
            {
                tmin = tzmin;
            }

            if (tzmax < tmax)
            {
                tmax = tzmax;
            }



            if (intersects)
            {
                return(ExitType.FirstExit);
            }
            else
            {
                return(ExitType.AlternateExit);
            }
        }