Menu Close

Repeated Error in Visual Studio

Syncrosim Forums ST-Sim & State-and-Transition Simulation Models Repeated Error in Visual Studio

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5725
    rsleeterrsleeter
    Participant

    I am learning Visual Studio to run rsyncrosim and I have been successful for the most part in re-building my model using this platform, however, I have run into an error that is confusing.

    Here is the error that I get after trying to build my Initial Stocks scenario within my model. The code is successful in building the scenario, the datasheet, and I am able to add rows, but when I get to the saveDatasheet line, I get this error.

    Error in .datasheets(x) : expecting SsimObject.

    I then tried to re-run code from yesterday that worked just fine and I get the same error, so it’s something global.

    Not sure if this all makes sense, and you might need more info, just seeing if someone else has run into this error before or if it rings a bell.

    Thanks,
    Rachel

    #5726
    colin-danielcolin-daniel
    Keymaster

    Hi Rachel – would really need to see your script in order to diagnose. That said it looks like the saveDatasheet function is expecting an SsimObject (for its first argument) and not getting it. An SsimObject is either a SsimLibrary, Project or Scenario. However if you are using the saveDatasheet fucntion to save a scenario-level datasheet (as you describe above), then this first argument must be a Scenario object. Perhaps check that this first argument is in fact a valid Scenario object before making the call to saveDatasheet function?

    So something like this:
    myScenario = scenario(myProject, scenario = “Test”)
    sheetName = “STSim_RunControl”
    mySheet = datasheet(myScenario,name=sheetName)
    myScenario # Add this line to check the scenario object is set correctly before calling saveDatasheet
    saveDatasheet(myScenario,mySheet,name=sheetName)

    #5727
    rsleeterrsleeter
    Participant

    Thanks Colin,

    My code is a bit different than yours on line 3, which is why I might have gotten the error, however, since getting the error I created a new library, project and sub-scenarios, and then went ahead and re-built my model with the existing code that I had, and did not get the error.
    I think the problem occurs when I close Visual Studio and re-open. I will let you know if I run into this problem again. Ben is helping me along as well.
    If you are curious, Here was the exact code (I did not include all of the addRow lines here though).

    # Initial Stocks
    initialStocks = scenario(myProject, “SF Initial Stocks”, overwrite = T)
    sheetName = “SF_InitialStockNonSpatial”
    sheetData = datasheet(myProject, name = sheetName, scenario = “SF Initial Stocks”, optional = T, empty = T)
    sheetData = addRow(sheetData, data.frame(StockTypeID = “Deadwood”, StateAttributeTypeID = “Carbon Initial Conditions: Deadwood”))
    sheetData = addRow(sheetData, data.frame(StockTypeID = “Dead Root”, StateAttributeTypeID = “Carbon Initial Conditions: Dead Root”))
    saveDatasheet(initialStocks, sheetData, sheetName, append = F)

    #5728
    colin-danielcolin-daniel
    Keymaster

    Hi Rachel – others here report similar problems on occasion with both RStudio and Visual Studio IDE’s for R – code that runs one day and then not the next. Solution seems to be resetting things somehow. I know in RStudio there is a way to clear all objects from the workspace that might help to reset things. I haven’t used VS so not sure, but I see online there is an option to reset a workspace: https://docs.microsoft.com/en-us/visualstudio/rtvs/r-workspaces-in-visual-studio#saving-and-resetting-a-workspace. Others have worked around the problem by uninstalling and reinstalling the rsyncrosim package (likely as a way to reset things somehow?).

    Let me know if any of these work for you. Colin

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.