// File: skyetheguy[P]gait_cycle_phase_detection/main.cpp
// Function: main
int main( )
{

	gaitCycle *mainCycle = new gaitCycle;

	int state; // Current state or phase of the gait cycle

	sensorData currentData;


	// OPEN FILE FOR READING
	ifstream infile;
	infile.open("./Data_files/walkData1.csv");

	// USED FOR READING FROM FILE
	string value; 
	vector<string> lineData;


	// WHILE NOT AT EOF KEEP READING LINES WHILE PROCESSING EACH AS WE READ
	while (infile.good())
	{

		for (int i = 0; i <= (CSV_LINE_LENGTH - 2); i++)
		{
			getline(infile, value, ',');
			lineData.push_back(value);

		}

		currentData.setTime( std::stoi(lineData[1], NULL, 10) );
		//cout << std::stoi(lineData[1], NULL, 10) << " ";
		currentData.setXAccel( std::stoi(lineData[2], NULL, 10) );
		//cout << std::stoi(lineData[2], NULL, 10) << " " ;
		currentData.setYAccel( std::stoi(lineData[3], NULL, 10) );
		//cout << std::stoi(lineData[3], NULL, 10) << " " ;
		currentData.setZAccel( std::stoi(lineData[4], NULL, 10) );
		//cout << std::stoi(lineData[4], NULL, 10) << " ";
		currentData.setXGyro( std::stoi(lineData[5], NULL, 10) );
		//cout << std::stoi(lineData[5], NULL, 10) << " " ;
		currentData.setYGyro( std::stoi(lineData[6], NULL, 10) );
		//cout << std::stoi(lineData[6], NULL, 10) << " ";
		currentData.setZGyro( std::stoi(lineData[7], NULL, 10) );
		//cout << std::stoi(lineData[7], NULL, 10) << endl;



		// PROCESS THE DATA JUST TAKEN IN
		state = mainCycle->processReadings(currentData);

		lineData.clear();
		sleep_for(nanoseconds(10000000));
	}


	infile.close(); // CLOSE FILE

   


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movl $0x0, -0x4(%rbp)
movl $0x278, %edi            # imm = 0x278
callq 0x2160
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2b8(%rbp)
callq 0x3b80
jmp 0x2460
movq -0x2b8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq -0x248(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x2180
movq -0x2c0(%rbp), %rdi
leaq 0x3b78(%rip), %rsi      # 0x6004
movl $0x8, %edx
callq 0x2100
jmp 0x2498
leaq -0x268(%rbp), %rdi
callq 0x2190
leaq -0x280(%rbp), %rdi
callq 0x2810
movq -0x248(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x248(%rbp,%rax), %rdi
callq 0x21f0
movb %al, -0x2c1(%rbp)
jmp 0x24d0
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x24df
jmp 0x27b2
movl $0x0, -0x284(%rbp)
cmpl $0x12, -0x284(%rbp)
jg 0x258f
leaq -0x248(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movl $0x2c, %edx
callq 0x2220
jmp 0x2510
leaq -0x280(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x2830
jmp 0x2525
jmp 0x2527
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0x24e9
movq -0x2b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x2140
jmp 0x27fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x27f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x29f0
leaq -0x268(%rbp), %rdi
callq 0x20f0
jmp 0x27f0
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2c8(%rbp)
jmp 0x25b9
movl -0x2c8(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5da0
jmp 0x25ca
leaq -0x280(%rbp), %rdi
movl $0x2, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2cc(%rbp)
jmp 0x25f4
movl -0x2cc(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5dc0
jmp 0x2605
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2d0(%rbp)
jmp 0x262f
movl -0x2d0(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5de0
jmp 0x2640
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2d4(%rbp)
jmp 0x266a
movl -0x2d4(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5e00
jmp 0x267b
leaq -0x280(%rbp), %rdi
movl $0x5, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2d8(%rbp)
jmp 0x26a5
movl -0x2d8(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5e20
jmp 0x26b6
leaq -0x280(%rbp), %rdi
movl $0x6, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2dc(%rbp)
jmp 0x26e0
movl -0x2dc(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5e40
jmp 0x26f1
leaq -0x280(%rbp), %rdi
movl $0x7, %esi
callq 0x28e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28a0
movl %eax, -0x2e0(%rbp)
jmp 0x271b
movl -0x2e0(%rbp), %esi
leaq -0x3c(%rbp), %rdi
callq 0x5e60
jmp 0x272c
movq -0x10(%rbp), %rdi
movups -0x3c(%rbp), %xmm0
movups -0x30(%rbp), %xmm1
movups %xmm1, -0x294(%rbp)
movaps %xmm0, -0x2a0(%rbp)
movups -0x294(%rbp), %xmm0
movq %rsp, %rax
movups %xmm0, 0xc(%rax)
movaps -0x2a0(%rbp), %xmm0
movups %xmm0, (%rax)
callq 0x3ca0
movl %eax, -0x2e4(%rbp)
jmp 0x276b
movl -0x2e4(%rbp), %eax
movl %eax, -0x20(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x2900
movl $0x989680, -0x2ac(%rbp) # imm = 0x989680
leaq -0x2a8(%rbp), %rdi
leaq -0x2ac(%rbp), %rsi
callq 0x29d0
jmp 0x279f
leaq -0x2a8(%rbp), %rdi
callq 0x2920
jmp 0x27ad
jmp 0x24b0
leaq -0x248(%rbp), %rdi
callq 0x2040
jmp 0x27c0
leaq -0x280(%rbp), %rdi
callq 0x29f0
leaq -0x268(%rbp), %rdi
callq 0x20f0
leaq -0x248(%rbp), %rdi
callq 0x2050
movl -0x4(%rbp), %eax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x248(%rbp), %rdi
callq 0x2050
movq -0x18(%rbp), %rdi
callq 0x2210
nopw %cs:(%rax,%rax)
nop