ATTENTIONThis 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 |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
|||
|
|||
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))); } } Quote:
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:
Has anyone managed to do this successfully? What am I missing? thanks, Daniel |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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))); } } Daniel |
Tags |
excel, timetable |
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 |