ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2011
Daniel Braund Daniel Braund is offline
Flexsim User
 
Join Date: Sep 2009
Location: Cumbria, UK
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Daniel Braund is on a distinguished road
Default Importing Timetables/Shift Patterns into Flexsim from Excel

Hi all,
I have a model that imports from Excel using ODBC after compiling. I have added Shift Patterns (in the same table format as Flexsim uses), and had hoped/assumed that pulling them into Flexsim would be as simple as using something like this:
Code:
//TimeTable xxx
dbchangetable("odbc_tt_xxx");
//define position in tree where xxx Timetable exists....
time_table = node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts>variables/table");
//Added the import of these variables, after I noticed that they weren't being updated after import:
setnodenum(node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts>variables/repeattime"),gettablenum("Data_ShiftPeriod",2,3));
setnodenum(node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts>variables/rows"),gettablenum("Data_ShiftPeriod",2,4));
max_row = dbgetnumrows();
max_col = dbgetnumcols();
row_loop = 2;
max_row_timetable = 2;
while ((stringtonum(dbgettablecell(row_loop,1)) > 0)&&(row_loop<=dbgetnumrows()))
{   
    max_row_timetable = row_loop;
    row_loop++;
}
settablesize(time_table,max_row_timetable,dbgetnumcols(),DATATYPE_NUMBER);
for(row = 1; row <= max_row; row++)
{
    for(col = 1; col <= max_col; col++)
    {
            settablenum(time_table,row,col,stringtonum(dbgettablecell(row, col)));
    }
}
The importer seems to work as far as putting the new timetable data in the TimeTable table, but the TimeTable object then does not seem to pick up the new contents of the TimeTable table correctly, and for example when a shorter Shift pattern is imported (say 21 rows rather than 42 rows), an exception occurs:
Quote:
ime: 870.000000exception: Exception Caught in ObjectFunction245__project_library_TimeTable_behav iour_eventfunctions_OnTimerEvent object: /Tools/TimeTables/xxx_Shifts class: /Tools/TimeTables/MAGNOX_Shifts

LINK PARITY ERROR(step)
LINK PARITY ERROR(lastitem)
time: 1080.000000exception: Exception Caught in ObjectFunction245__project_library_TimeTable_behav iour_eventfunctions_OnTimerEvent object: /Tools/TimeTables/xxx_Shifts class: /Tools/TimeTables/MAGNOX_Shifts

time: 1350.000000exception: Exception Caught in ObjectFunction245__project_library_TimeTable_behav iour_eventfunctions_OnTimerEvent object: /Tools/TimeTables/xxx_Shifts class: /Tools/TimeTables/MAGNOX_Shifts

time: 1350.000000exception: Exception Caught in ObjectFunction245__project_library_TimeTable_behav iour_eventfunctions_OnTimerEvent object: /Tools/TimeTables/xxx_Shifts class: /Tools/TimeTables/xxx_Shifts

time: 2055.000000exception: Exception Caught in ObjectFunction245__project_library_TimeTable_behav iour_eventfunctions_OnTimerEvent object: /Tools/TimeTables/xxx_Shifts class: /Tools/TimeTables/MAGNOX_Shifts

LINK PARITY ERROR(step)
LINK PARITY ERROR(lastitem)
The exceptions are occuring on the times present in the old timetable.
This makes me think that I need to run some code to update the TimeTable object with the new timetable table data. I tried adding
Quote:
function_s(node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts"),"OnReset");
but this had no effect. I assume that some code is called by flexsim when the Apply or OK buttons are pressed in the TimeTable dialog, but I haven't been able to figure out where it is.

Has anyone managed to do this successfully? What am I missing?

thanks,
Daniel
Reply With Quote
  #2  
Old 08-18-2011
Daniel Braund Daniel Braund is offline
Flexsim User
 
Join Date: Sep 2009
Location: Cumbria, UK
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Daniel Braund is on a distinguished road
Default

I have done some more testing, and it appears that the problem occurs on any of our workstations running Flexsim 5.1.2 under Windows XP 32-bit, but does not appear on workstations running Flexsim 5.1.2 under Windows 7 64-bit.
In both instances Microsoft Visual C++ 2008 Express is installed, and being pointed to correctly in the compiler options.

Very strange.

Daniel
Reply With Quote
  #3  
Old 08-19-2011
Daniel Braund Daniel Braund is offline
Flexsim User
 
Join Date: Sep 2009
Location: Cumbria, UK
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Daniel Braund is on a distinguished road
Default

Big thanks to Juan Segui at Saker Solutions, who has kindly pointed out that I have tied myself in knots with my Table resizing. Once simplified, the code works:
Code:
//TimeTable xxx dbchangetable("odbc_tt_xxx"); //define position in tree where xxx Timetable exists.... time_table = node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts>variables/table"); //Added the import of these variables, after I noticed that they weren't being updated after import: setnodenum(node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts>variables/repeattime"),gettablenum("Data_ShiftPeriod",2,3)); setnodenum(node("MAIN:/project/model/Tools/TimeTables/xxx_Shifts>variables/rows"),gettablenum("Data_ShiftPeriod",2,4)); max_row = dbgetnumrows(); max_col = dbgetnumcols();  settablesize(time_table,max_row,max_col,DATATYPE_NUMBER); for(row = 1; row <= max_row; row++) {     for(col = 1; col <= max_col; col++)     {             settablenum(time_table,row,col,stringtonum(dbgettablecell(row, col)));     } }
thanks,
Daniel
Reply With Quote
Reply

Tags
excel, timetable

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timetables & MTEI in Flexsim 5.04 michaelsmith Gripes and Goodies 2 02-10-2011 11:09 AM
Shift work m matias Q&A 2 02-21-2010 01:12 PM
Excel File Importing John Kim Container Terminal (CT) Library 0 08-06-2009 03:21 PM
Excel 2002 vs. Excel 2007 Nico Zahn Q&A 2 04-27-2009 01:47 AM
Problem with importing Excel data David Chan Q&A 5 03-05-2009 01:49 AM


All times are GMT -6. The time now is 06:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.