/// <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); }
/// <summary> /// Get the arguments from the Repeating Group /// </summary> /// <param name="context"></param> /// <returns></returns> public List <Tuple <string, string> > GetArgumentsFromSimio(IStepExecutionContext context) { List <Tuple <string, string> > argList = new List <Tuple <string, string> >(); string marker = ""; int numArguments = _prArguments.GetCount(context); int ii = -1; try { // Get the values of all the arguments (repeating group) for (ii = 0; ii < numArguments; ii++) { marker = $"Argument #{ii}"; using (IPropertyReaders argsRow = _prArguments.GetRow(ii, context)) { IExpressionPropertyReader prExpression = argsRow.GetProperty("ArgumentName") as IExpressionPropertyReader; string argName = prExpression.GetExpressionValue(context).ToString(); prExpression = argsRow.GetProperty("Expression") as IExpressionPropertyReader; string exprVal = prExpression.GetExpressionValue(context).ToString(); marker = $"{marker}: Name={argName} Value={exprVal}"; argList.Add(new Tuple <string, string>(argName, exprVal)); } } // for return(argList); } catch (Exception ex) { throw new ApplicationException($"Marker={marker}. Processing argument {ii} of {numArguments}. Err={ex.Message}"); } }
public UserStep1(IPropertyReaders properties) { _properties = properties; _propPala0 = (IStateProperty)_properties.GetProperty("Pala0"); _propPala1 = (IStateProperty)_properties.GetProperty("Pala1"); _propPala2 = (IStateProperty)_properties.GetProperty("Pala2"); _propPala3 = (IStateProperty)_properties.GetProperty("Pala3"); _propPala4 = (IStateProperty)_properties.GetProperty("Pala4"); _propPala5 = (IStateProperty)_properties.GetProperty("Pala5"); _propPala6 = (IStateProperty)_properties.GetProperty("Pala6"); _propPala7 = (IStateProperty)_properties.GetProperty("Pala7"); _propPala8 = (IStateProperty)_properties.GetProperty("Pala8"); _propPala9 = (IStateProperty)_properties.GetProperty("Pala9"); _propPala10 = (IStateProperty)_properties.GetProperty("Pala10"); _propPala11 = (IStateProperty)_properties.GetProperty("Pala11"); _propPala12 = (IStateProperty)_properties.GetProperty("Pala12"); _propPala13 = (IStateProperty)_properties.GetProperty("Pala13"); _propPala14 = (IStateProperty)_properties.GetProperty("Pala14"); _propPala15 = (IStateProperty)_properties.GetProperty("Pala15"); _propPala16 = (IStateProperty)_properties.GetProperty("Pala16"); _propPala17 = (IStateProperty)_properties.GetProperty("Pala17"); _propPala18 = (IStateProperty)_properties.GetProperty("Pala18"); _propPala19 = (IStateProperty)_properties.GetProperty("Pala19"); _propPala20 = (IStateProperty)_properties.GetProperty("Pala20"); vectores = new Vectores.Vect(); }
/// <summary> /// Method called when a process token executes the step. /// </summary> public ExitType Execute(IStepExecutionContext context) { // Get an array of double values from the repeat group's list of expressions object[] paramsArray = new object[_items.GetCount(context)]; for (int i = 0; i < _items.GetCount(context); i++) { // The thing returned from GetRow is IDisposable, so we use the using() pattern here using (IPropertyReaders row = _items.GetRow(i, context)) { // Get the expression property IExpressionPropertyReader expressionProp = row.GetProperty("Expression") as IExpressionPropertyReader; // Resolve the expression to get the value paramsArray[i] = expressionProp.GetExpressionValue(context); } } // set Excel data ExcelConnectElementEPPlus Excelconnect = (ExcelConnectElementEPPlus)_ExcelconnectElementProp.GetElement(context); if (Excelconnect == null) { context.ExecutionInformation.ReportError("ExcelConnectEPPlus element is null. Makes sure ExcelWorkbook is defined correctly."); } String worksheetString = _worksheetProp.GetStringValue(context); Int32 rowInt = (Int32)_rowProp.GetDoubleValue(context); Int32 startingColumnInt = Convert.ToInt32(_startingColumnProp.GetDoubleValue(context)); try { // for each parameter for (int ii = 0; ii < paramsArray.Length; ii++) { double doubleValue = TryAsDouble((Convert.ToString(paramsArray[ii], CultureInfo.InvariantCulture))); if (!System.Double.IsNaN(doubleValue)) { Excelconnect.WriteResults(worksheetString, rowInt, startingColumnInt + ii, doubleValue, DateTime.MinValue, String.Empty, context); } else { DateTime datetimeValue = TryAsDateTime((Convert.ToString(paramsArray[ii], CultureInfo.InvariantCulture))); if (datetimeValue > System.DateTime.MinValue) { Excelconnect.WriteResults(worksheetString, rowInt, startingColumnInt + ii, System.Double.MinValue, datetimeValue, String.Empty, context); } else { Excelconnect.WriteResults(worksheetString, rowInt, startingColumnInt + ii, System.Double.MinValue, System.DateTime.MinValue, (Convert.ToString(paramsArray[ii], CultureInfo.InvariantCulture)), context); } } } } catch (FormatException) { context.ExecutionInformation.ReportError("Bad format provided in Excel Write step."); } // We are done writing, have the token proceed out of the primary exit return(ExitType.FirstExit); }
/// <summary> /// Constructor. /// </summary> /// <param name="properties"></param> public EFInterfaceStep(IPropertyReaders properties) { _properties = properties; PropertyHelper = new SimioPropertyHelper(properties); //var prSqlConnectionString = _properties.GetProperty("SqlConnectionString"); }
/// <summary> /// Constructor. Initialize data. Called as a model with this Step loads. /// </summary> /// <param name="properties"></param> public SimioTableInterfaceStep(IPropertyReaders properties) { _props = properties; RandomGenerator = new Random(); CalcDataList = null; // new List<CalculationRow>(); }
public Cargabien(IPropertyReaders properties) { _properties = properties; _propTimenow = (IStateProperty)_properties.GetProperty("Timenow"); _propSalida = (IStateProperty)_properties.GetProperty("Salida"); _propAux = (IStateProperty)_properties.GetProperty("Aux"); vectores = new Vectores.Vect(); }
/// <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 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"); }
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"); }
public UserStep1(IPropertyReaders properties) { _properties = properties; _propTimenow = (IStateProperty)_properties.GetProperty("Timenow"); _propSalida = (IStateProperty)_properties.GetProperty("Salida"); _propAux = (IStateProperty)_properties.GetProperty("Aux"); _propAux2 = (IStateProperty)_properties.GetProperty("Aux2"); _propNumCam = (IStateProperty)_properties.GetProperty("NumCam"); _propNeedtime = (IStateProperty)_properties.GetProperty("Needtime"); _propLosttones = (IStateProperty)_properties.GetProperty("Losttones"); _propNeedch = (IStateProperty)_properties.GetProperty("Needch"); vectores = new Vectores.Vect(); }
public Vector(IPropertyReaders properties) { _properties = properties; _propTipo = (IStateProperty)_properties.GetProperty("TipoVector"); _propFila = (IStateProperty)_properties.GetProperty("Fila"); _propColumna = (IStateProperty)_properties.GetProperty("Columna"); _propPalas = (IStateProperty)_properties.GetProperty("Numerofilas"); _propCamiones = (IStateProperty)_properties.GetProperty("Numerocolumnas"); _propNV = (IStateProperty)_properties.GetProperty("NuevoValor"); _propLE = (IStateProperty)_properties.GetProperty("LeeoEscribe"); vectores = new Vect(); // }
/// <summary> /// Method called when a process token executes the step. /// </summary> public ExitType Execute(IStepExecutionContext context) { // Get Excel data ExcelConnectElementEPPlus Excelconnect = (ExcelConnectElementEPPlus)prExcelconnectElement.GetElement(context); if (Excelconnect == null) { context.ExecutionInformation.ReportError("ExcelConnectEPPlus element is null. Makes sure ExcelWorkbook is defined correctly."); } String worksheetString = prWorksheet.GetStringValue(context); Int32 rowInt = (Int32)prRow.GetDoubleValue(context); Int32 startingColumnInt = Convert.ToInt32(prStartingColumn.GetDoubleValue(context)); int numReadIn = 0; int numReadFailures = 0; for (int ii = 0; ii < rprStates.GetCount(context); ii++) { // Tokenize the input string resultsString = Excelconnect.ReadResults(worksheetString, rowInt, startingColumnInt + ii, context); // The thing returned from GetRow is IDisposable, so we use the using() pattern here using (IPropertyReaders row = rprStates.GetRow(ii, context)) { // Get the state property out of the i-th tuple of the repeat group IStateProperty stateprop = (IStateProperty)row.GetProperty("State"); // Resolve the property value to get the runtime state IState state = stateprop.GetState(context); if (TryAsNumericState(state, resultsString) || TryAsDateTimeState(state, resultsString) || TryAsStringState(state, resultsString)) { numReadIn++; } else { numReadFailures++; } } } string worksheetName = prWorksheet.GetStringValue(context); context.ExecutionInformation.TraceInformation($"Read from row={rowInt} worksheet={worksheetName} into {numReadIn} state columns. {numReadFailures} read failures"); // We are done reading, have the token proceed out of the primary exit return(ExitType.FirstExit); }
/// <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); } ////} }
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); ////} }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return(new Cargabien(properties)); }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return new Separation(properties); }
public Separation(IPropertyReaders properties) { _properties = properties; }
public IntersectionStep(IPropertyReaders properties) { _properties = properties; }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return(new IntersectionStep(properties)); }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return(new MqttPublishExpressionStep(properties)); }
public AlertStep(IPropertyReaders properties) { _propReaders = properties; _prMessage = _propReaders.GetProperty("Message"); }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return(new UserStep1(properties)); }
public SimioPropertyHelper(IPropertyReaders propReaders) { this._PropReaders = propReaders; }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return(new EntityWithDataStep(properties)); }
/// <summary> /// Method called to create a new instance of this step type to place in a process. /// Returns an instance of the class implementing the IStep interface. /// </summary> public IStep CreateStep(IPropertyReaders properties) { return(new AlertStep(properties)); }
public EntityWithDataStep(IPropertyReaders properties) { _properties = properties; }