private static bool PutCalculationRowObjectToSimioValues(IStepExecutionContext context, IPropertyReaders rowReader, CalculationRow calcRow) { try { IStateProperty stateReader = (IStateProperty)rowReader.GetProperty("StateField1"); IState state = stateReader.GetState(context); state.StateValue = calcRow.MyReal1; stateReader = (IStateProperty)rowReader.GetProperty("StateField2"); state = stateReader.GetState(context); state.StateValue = calcRow.MyReal2; stateReader = (IStateProperty)rowReader.GetProperty("StateField3"); state = stateReader.GetState(context); state.StateValue = calcRow.MyReal3; stateReader = (IStateProperty)rowReader.GetProperty("StateField4"); state = stateReader.GetState(context); state.StateValue = calcRow.MyReal4; return(true); } catch (Exception ex) { Logit(context, $"Err={ex.Message}"); return(false); } }
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(); }
public StatePropertyValue(IStateProperty property, int valueIndex) { Property = property ?? throw new ArgumentNullException(nameof(property)); ValueIndex = valueIndex; _hashCode = HashCode.Combine(Property, ValueIndex); }
private static bool PutSimioValuesToCalculationRowObject(IStepExecutionContext context, Random rand, IPropertyReaders rowReader, CalculationRow calcRow) { try { // Use the row reader to get a state reader IStateProperty stateReader = (IStateProperty)rowReader.GetProperty("StateField1"); IState state = stateReader.GetState(context); state.StateValue = (10 * calcRow.MyKey) + 1; // Mock to create a value for the state calcRow.MyReal1 = state.StateValue; stateReader = (IStateProperty)rowReader.GetProperty("StateField2"); state = stateReader.GetState(context); state.StateValue = (10 * calcRow.MyKey) + 2; // Mock to create a value for the State calcRow.MyReal2 = state.StateValue; stateReader = (IStateProperty)rowReader.GetProperty("StateField3"); state = stateReader.GetState(context); state.StateValue = (10 * calcRow.MyKey) + 3; // Mock to create a value for the State calcRow.MyReal3 = state.StateValue; stateReader = (IStateProperty)rowReader.GetProperty("StateField4"); state = stateReader.GetState(context); state.StateValue = (10 * calcRow.MyKey) + 4; // Mock to create a value for the State calcRow.MyReal4 = state.StateValue; return(true); } catch (Exception ex) { Logit(context, $"Err={ex.Message}"); return(false); } }
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(); }
public T GetTypedValue <T>(IStateProperty <T> property) { if (Values.TryGetValue(property.Name, out var value)) { return(property.ParseValue(value)); } return(default(T)); }
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(); // }
public bool TryGetProperty(Utf8Memory name, [MaybeNullWhen(false)] out IStateProperty property) { foreach (IStateProperty prop in _properties) { if (prop.Name == name) { property = prop; return(true); } } property = null; return(false); }
/// <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); }
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 T GetTypedValue <T>(IStateProperty <T> property) { if (Values.TryGetValue(property.Name, out var value)) { /*if (property.PropertyType.IsEquivalentTo(value.GetType())) * { * return (T)value; * } * else * {*/ return(property.ParseValue(value)); //} } return(property.GetDefaultValue()); }
public bool Equals(IStateProperty other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(other, this)) { return(true); } if (other is PowerState ps) { return(ps.Value == Value); } return(false); }
public static StatePropertyValue Create(IStateProperty property, int valueIndex) { if (property == null) { throw new ArgumentNullException(nameof(property)); } if (property is IStateProperty <bool> boolProp) { return(new StatePropertyValue <bool>(boolProp, valueIndex)); } if (property is IStateProperty <int> intProp) { return(new StatePropertyValue <int>(intProp, valueIndex)); } var propertyType = property.GetType(); if (propertyType.IsConstructedGenericType) { var genericTypeArgs = propertyType.GenericTypeArguments; if (genericTypeArgs.Length == 1) { var genericType = genericTypeArgs[0]; if (genericType.IsEnum && genericType.IsValueType) { var constructType = typeof(StatePropertyValue <>).MakeGenericType(genericType); var propertyValue = Activator.CreateInstance(constructType, property, valueIndex); if (propertyValue == null) { throw new Exception("Failed to create property value."); } return((StatePropertyValue)propertyValue); } } } return(new StatePropertyValue(property, valueIndex)); }
/// <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); ////} }
public static StatePropertyValue <T> GetPropertyValue <T>(this IStateProperty <T> property, Utf8Memory name) { return(property.GetPropertyValue(property.GetIndex(name))); }
public static StatePropertyValue <T> GetPropertyValue <T>(this IStateProperty <T> property, ReadOnlyMemory <char> name) { return(property.GetPropertyValue(property.GetIndex(name))); }
public static StatePropertyValue <T> GetPropertyValue <T>(this IStateProperty <T> property, int index) { return(new StatePropertyValue <T>(property, index)); }
/// <summary> /// Return the state of a function. /// </summary> /// <returns>True if such a state exists, false otherwise</returns> public bool TryGetFunctionState(LocFunction function, out IStateProperty <bool> state) { return(functionStates.TryGetValue(function, out state)); }
public StatePropertyValue(IStateProperty <T> property, int valueIndex) : base(property, valueIndex) { }
public bool Equals(IStateProperty other) { return(other.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase)); /*&& * other.PropertyType.IsEquivalentTo(PropertyType);*/ }
public PropertyValue(IStateProperty prop, string value) { _property = prop; _value = value; }
public LP(IPropertyReaders properties) { _properties = properties; _propTimenow = (IStateProperty)_properties.GetProperty("Timenow"); vectores = new Vectores.Vect(); }
public StatePropertyValue(IStateProperty property, int index) { Property = property ?? throw new ArgumentNullException(nameof(property)); Index = index; }
public static StatePropertyValue <T> GetPropertyValue <T>(this IStateProperty <T> property, string?name) { return(property.GetPropertyValue(name.AsMemory())); }
public static StatePropertyValue GetPropertyValue(this IStateProperty property, int index) { return(new StatePropertyValue(property, index)); }
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"); _propPala21 = (IStateProperty)_properties.GetProperty("Pala21"); _propPala22 = (IStateProperty)_properties.GetProperty("Pala22"); _propPala23 = (IStateProperty)_properties.GetProperty("Pala23"); _propPala24 = (IStateProperty)_properties.GetProperty("Pala24"); _propPala25 = (IStateProperty)_properties.GetProperty("Pala25"); _propPala26 = (IStateProperty)_properties.GetProperty("Pala26"); _propPala27 = (IStateProperty)_properties.GetProperty("Pala27"); _propPala28 = (IStateProperty)_properties.GetProperty("Pala28"); _propPala29 = (IStateProperty)_properties.GetProperty("Pala29"); _propPala30 = (IStateProperty)_properties.GetProperty("Pala30"); _propPala31 = (IStateProperty)_properties.GetProperty("Pala31"); _propPala32 = (IStateProperty)_properties.GetProperty("Pala32"); _propPala33 = (IStateProperty)_properties.GetProperty("Pala33"); _propPala34 = (IStateProperty)_properties.GetProperty("Pala34"); _propPala35 = (IStateProperty)_properties.GetProperty("Pala35"); _propPala36 = (IStateProperty)_properties.GetProperty("Pala36"); _propPala37 = (IStateProperty)_properties.GetProperty("Pala37"); _propPala38 = (IStateProperty)_properties.GetProperty("Pala38"); _propPala39 = (IStateProperty)_properties.GetProperty("Pala39"); _propPala40 = (IStateProperty)_properties.GetProperty("Pala40"); _propPala41 = (IStateProperty)_properties.GetProperty("Pala41"); _propPala42 = (IStateProperty)_properties.GetProperty("Pala42"); _propPala43 = (IStateProperty)_properties.GetProperty("Pala43"); _propPala44 = (IStateProperty)_properties.GetProperty("Pala44"); _propPala45 = (IStateProperty)_properties.GetProperty("Pala45"); _propPala46 = (IStateProperty)_properties.GetProperty("Pala46"); _propPala47 = (IStateProperty)_properties.GetProperty("Pala47"); _propPala48 = (IStateProperty)_properties.GetProperty("Pala48"); _propPala49 = (IStateProperty)_properties.GetProperty("Pala49"); _propPala50 = (IStateProperty)_properties.GetProperty("Pala50"); _propPala51 = (IStateProperty)_properties.GetProperty("Pala51"); _propPala52 = (IStateProperty)_properties.GetProperty("Pala52"); _propPala53 = (IStateProperty)_properties.GetProperty("Pala53"); _propPala54 = (IStateProperty)_properties.GetProperty("Pala54"); _propPala55 = (IStateProperty)_properties.GetProperty("Pala55"); _propPala56 = (IStateProperty)_properties.GetProperty("Pala56"); _propPala57 = (IStateProperty)_properties.GetProperty("Pala57"); _propPala58 = (IStateProperty)_properties.GetProperty("Pala58"); _propPala59 = (IStateProperty)_properties.GetProperty("Pala59"); _propPala60 = (IStateProperty)_properties.GetProperty("Pala60"); vectores = new Vectores.Vect(); }