Jump to content

Welcome to the Simio Forum

Welcome to the Simio Forum! Experience the full experience of the forum by becoming a Simio Insider!


New Software Release

Our latest release, Simio 10.174, will be live in July 2018!

Save the Date!

Simio Sync is May 14-15, 2018! More details coming next month.


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About fpeschiera


  • ICQ
  1. fpeschiera

    Reading and writing on state variables from a custom step

    Hello again, Thank you for your reply, it was really helpful and the example provided in the other thread proved to be a nice example of what was needed! In case it helps any future user, I'll post the model and the code. It is a very simple example (all I wanted is to figure out how to write on states): I created a subclass of the server object, so I could modify its behaviour: I added a State Variable called "StateToModify" I added a personal step in the OnEnteredProcessing process. The variable must be referenced in the step. What I aimed to do is reading that state and modify it in the step. To keep the model as simple as possible, I'd just read the value, add one and write it on the state. Every time the state is read, it is also displayed on a MessageBox. This way, the value of the state variable is shown every time a ModelEntity enters the server. The key to success, I found out, is reading the value as a property (IPropertyReader) and later casting it to a IStateProperty. Once this is done, the value can be set. Thank you for the kind answer and the help provided! PS: to use the code attached, just unzip the code, extract the .dll located in (...)\PersonalStep\PersonalStep\bin\Debug and place it into (SIMIO Instalation path)/SIMIO/UserExtensions. Then, open the model and run it. StepModStateVariable.spfx PersonalStep.zip
  2. Hi! I am currently working on a model in SIMIO and struggling with the custom steps. In the model I need some calculations to happen outside of SIMIO, based on the values of state variables which change values during the simulation. What I would like to do is a custom step which executes this calculations outside of SIMIO. It would read the necessary values from the state variables (in the object which holds the procedure) and then overwrite some other state variables with the result of the calculations. Essentially, what I need to find out is if it is possible to read, through the API using a custom step, the value a certain state variable has, perform some calculations and then set the value for that (or another) state variable according to those calculations, and how to do it. What I got so far is to read the state properties of the ModelEntity which launches the process, but not the ones from the Object actually holding the procedure. I don't know either how to change the value for the state variables. I hope you can help me with this issue, Best regards,
  3. fpeschiera


    Thank you both for you answer, i finally resolved the issue with a mix of your suggestions. Here is the code if anyone is interested. Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace WindowsFormsApplication1 { static class Program { /// /// Punto de entrada principal para la aplicación. /// [sTAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } Form1.cs using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; using SimioAPI; using SimioAPI.Extensions; using SpreadsheetLight; using DocumentFormat; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { SLDocument ExportFile = new SLDocument(); ExportFile.SetCellValue(1, 1, "Type of user"); ExportFile.SetCellValue(1, 2, "Change or not"); ExportFile.SetCellValue(1, 3, "Object type"); ExportFile.SetCellValue(1, 4, "Property type"); ExportFile.SetCellValue(1, 5, "Property name"); ExportFile.SetCellValue(1, 6, "Default value"); ExportFile.SetCellValue(1, 7, "Unit of default value"); ExportFile.SetCellValue(1, 8, "Switch property name"); ExportFile.SetCellValue(1, 9, "Switch Value"); ExportFile.SetCellValue(1, 10, "Display name"); ExportFile.SetCellValue(1, 11, "Category name"); ExportFile.SetCellValue(1, 12, "Description"); ExportFile.SetCellValue(1, 13, "Visible"); ExportFile.SetCellValue(1, 14, "Commonly used"); var getFile = new OpenFileDialog(); getFile.Filter = "Simio Project Files(*.spfx)|*.spfx"; if (getFile.ShowDialog() == DialogResult.Cancel) { MessageBox.Show("Canceled by user.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { textBox1.Text = getFile.FileName; } ISimioProject project; // Set extension folder path to Simio Extensions SimioProjectFactory.SetExtensionsPath(@"C:\Program Files (x86)\Simio\UserExtensions"); // Open project string[] warnings; project = SimioProjectFactory.LoadProject(getFile.FileName, out warnings); this.Close(); int i = 2; foreach (IModel model in project.Models) { foreach(IPropertyDefinition propdef in model.PropertyDefinitions) { ExportFile.SetCellValue(i, 1, ""); ExportFile.SetCellValue(i, 2, ""); ExportFile.SetCellValue(i, 3, model.Name); ExportFile.SetCellValue(i, 4, ""); ExportFile.SetCellValue(i, 5, propdef.Name); ExportFile.SetCellValue(i, 6, propdef.DefaultString); ExportFile.SetCellValue(i, 7, ""); ExportFile.SetCellValue(i, 8, propdef.SwitchPropertyName); ExportFile.SetCellValue(i, 9, propdef.SwitchValues); ExportFile.SetCellValue(i, 10, propdef.DisplayName); ExportFile.SetCellValue(i, 11, propdef.CategoryName); ExportFile.SetCellValue(i, 12, propdef.Description); i++; } } ExportFile.SaveAs("C:\\Users\\User\\Desktop\\Properties.xlsx"); } } } Probably you could do this in a much cleaner and easier way but this works for me. It prints all the properties of all objects and their configuration. Again, the excel integration was made with http://spreadsheetlight.com/
  4. fpeschiera


    Hi, I'm trying to make an add-in that would export all the properties of my defined objects and their configuration to an excel file. Looking at the SIMIO API reference guide I have seen that IPropertyDefinition allows me to get the DefaultValue, Description, DisplayName, SwitchPropertyName and SwitchValues, as opposed to IProperty that only gets me Name and Value (not the default one). I've have tried to use the next code: but it gives me the next error (i guess related to the use of IPropertyDefinition): If I use IProperty with the next code: it runs smoothly but i can only get the PropertyName and I need to export the rest of the information about the properties. I am using the next library :http://spreadsheetlight.com/ for the excel integration. Thank you!
  5. Sorry to bring an old post but I think we are having a behavior similar to the explained here: We have test this with Simio 106. We have a data table being read from Excel. This specific table has 3 columns: node_in, node_out and probability (with the two first being keys). In Simio we plan to use the table in the following way: Every time an entity arrives at node "node_in" we want to assign the entity a destination taken from "node_out" with the probability "probability", this will be stored in the entity "node_in" for later use. Our main problem is that we do not understand how to do this query. We have used the "randomRow" function before to pick a random row from a table with just one key but we have not arrived to mix this with a "search" function to get a subset of the rows with the correct "node_in" before doing the randomRow. Our Search step (that executes inside the "node_in") has the following content: Match condition: Data.node_in==currentnode Search Expression: Data.probability.RandomRow As a test, we assigned the probability of 100 for a given row but Simio returns all (any) rows in the search step. any help is greatly appreciated.
  6. fpeschiera

    Get position of tail of transporter (train)

    Thanks both for the feedback. I think our problem is caused by the fact the our links are not "on scale". We have done this to avoid having very long (and boring) pieces of rail in our model. Your aproach works only when everything is on scale, as far as I know. So, our links and trains have all the correct lengths but the graphical distance does not correspond to the property. Is there a way to still take advantage of these triggers in nodes when working without graphical scaling? On a related question: is there a way to give as input the lengths of the links from external sources? So far, we can only modify them inside Simio and we would like to tie them to a data table read from csv/ excel. thanks again!
  7. Hello everyone, I am modelling a train going through stations and pieces of track. At some point, I need to trigger some logic when the trains "finishes to pass through a certain point". This means: when the tail of the train has just passed a node. There are other situations need to be addressed that would be easier to do having this reference, for example: to calculate distances between tails and heads of consecutive trains. One way is to use the length and the heads position (which is known) to do calculations. But I was wondering if there was a more elegant solution. So, it would be very nice to hear feedback regarding: 1. The possibility to get the position of the tail of the train and use it to trigger events and calculate distances. 2. An alternative way to solve these particular problems I am having. thanks in advance.
  8. Good day to everyone, We are building our first complex simio models right now. We are having problems with units in one of our models, specifically with speed units. When we open simio, we have a standard unit for speed (km/h for example). When we change the unit in an object's properties (e.g. a transporter's MovementRate) to, for example to "m/s", the change is not saved and we continue to have the object with the standard units (km/h). Shouldn't simio internally manage all the different units regardless of not being exactly the same for all objects? Maybe it is something we are doing wrong... How do units are taken into account and compared inside a simio model? thanks!
  9. Hello everyone, This question has probably been answered before but i could not find any post making mention. I would like to know if it is possible to edit the position (x, y, z) of a given object via some kind of procedure or using some state to govern these values. Specifically, we would like to assign specific coordinates to nodes in a graph (so we know for example all links are scaled correctly with their size) and we would like to get the positions of the nodes from an external data source (Excel, .txt files). We would only touch these values at the beginning of the simulation (as initialization). thanks