Example #1
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");
 }
 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");
 }
Example #3
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");
 }
        /// <summary>
        /// Method called when a process token executes the step.
        /// </summary>
        public ExitType Execute(IStepExecutionContext context)
        {
            rgReader = (IRepeatingPropertyReader)_props.GetProperty("MyMappedFields");

            // If not set up (e.g. this is the first time), create the CalcDataList
            // Since the RG references the table the count is the number of rows.
            if (CalcDataList == null)
            {
                CalcDataList = new List <CalculationRow>();

                int tableRowCount = rgReader.GetCount(context);
                for (int ri = 0; ri < tableRowCount; ri++)
                {
                    CalculationRow cr = new CalculationRow();
                    cr.MyKey = ri;
                    CalcDataList.Add(cr);
                }
            }

            //// Create values and put them in the CalculationRow objects
            foreach (CalculationRow cr in CalcDataList)
            {
                using (IPropertyReaders rowReader2 = rgReader.GetRow(cr.MyKey, context))
                {
                    PutSimioValuesToCalculationRowObject(context, RandomGenerator, rowReader2, cr);
                }
            } // next table row

            //======= Run a mock calculator/optimizer/whatever ==============
            if (RunMockCalculator(CalcDataList, out string explanation))
            {
                // Put the data back into Simio
                foreach (CalculationRow cr in CalcDataList)
                {
                    using (IPropertyReaders rowReader2 = rgReader.GetRow(cr.MyKey, context))
                    {
                        PutCalculationRowObjectToSimioValues(context, rowReader2, cr);
                    }
                }
                return(ExitType.FirstExit);
            }
            else
            {
                Logit(context, $"Calculation Err={explanation}");
                return(ExitType.AlternateExit);
            }

            ////}
        }
Example #5
0
        private List <double> ReadRepeatingProperty(IStepExecutionContext context, IRepeatingPropertyReader rp, string propertyname)
        {
            var result = new List <double>();

            for (int i = 0; i < rp.GetCount(context); i++)
            {
                using (IPropertyReaders row = rp.GetRow(i, context))
                {
                    IStateProperty stateprop = (IStateProperty)row.GetProperty(propertyname);
                    IState         state     = stateprop.GetState(context);
                    result.Add(state.StateValue);
                }
            }
            return(result);
        }
 public RunExecutable(IPropertyReaders properties)
 {
     try
     {
         _properties           = properties;
         _prExecutableLocation = _properties.GetProperty("ExecutableLocation");
         _prArguments          = (IRepeatingPropertyReader)_properties.GetProperty("Arguments");
         _prWaitForExit        = _properties.GetProperty("WaitForExecutableToExit");
         _prCreateWindow       = _properties.GetProperty("CreateWindow");
         _prArgLogic           = _properties.GetProperty("ArgumentLogic");
         _prDelimiter          = _properties.GetProperty("Delimiter");
         _prUseShellExecute    = _properties.GetProperty("UseShellExecute");
     }
     catch (Exception ex)
     {
         throw new ApplicationException($"RunExecutables. Perhaps a misnamed Property? Err={ex.Message}");
     }
 }
        /// <summary>
        /// Constructor called as the run begins.
        /// </summary>
        /// <param name="data"></param>
        public SimioTableElement(IElementData data)
        {
            _Data    = data;
            _Props   = _Data.Properties;       // Property readers
            _Context = _Data.ExecutionContext; // run-time execution context

            rprTableFields  = (IRepeatingPropertyReader)_Props.GetProperty(MyStrings.TableColumnMappingsName);
            prTableRowIndex = (IStateProperty)_Props.GetProperty(MyStrings.TableIndexName);

            IExpressionPropertyReader prExpression = (IExpressionPropertyReader)_Props.GetProperty(MyStrings.TableRowCountName);
            double tableRowCount = (double)prExpression.GetExpressionValue(data.ExecutionContext);

            // Build a structure to hold data??
            ////CalcDataList = new List<CalculationRow>();

            ////for (int tr = 1; tr <= NbrTableRows; tr++)
            ////{
            ////    CalculationRow cr = new CalculationRow();
            ////    cr.MyKey = tr;
            ////    CalcDataList.Add(cr);
            ////}
        }