// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl $0x278, %edi            # imm = 0x278
callq 0x2140
movq %rax, -0x48(%rbp)
movq %rax, %rdi
callq 0x2a3c
leaq -0x298(%rbp), %rbx
movq %rbx, %rdi
callq 0x2150
leaq 0x1bf8(%rip), %rsi      # 0x4004
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x20e0
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x40(%rbp), %r14
andq $0x0, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq -0x298(%rbp), %r13
leaq -0x90(%rbp), %rbx
pushq $0x2c
popq %r15
movq -0x298(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x278(%rbp,%rax)
jne 0x2596
pushq $0x13
popq %r12
subl $0x1, %r12d
jb 0x2487
movq %r13, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x21f0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x261c
jmp 0x2466
movq -0x40(%rbp), %rdi
addq $0x20, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x3890
movq -0x40(%rbp), %rdi
addq $0x40, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x3898
movq -0x40(%rbp), %rdi
addq $0x60, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x38a2
movq -0x40(%rbp), %rdi
subq $-0x80, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x38ac
movq -0x40(%rbp), %rdi
movl $0xa0, %eax
addq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x38b6
movq -0x40(%rbp), %rdi
movl $0xc0, %eax
addq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x38c0
movq -0x40(%rbp), %rdi
movl $0xe0, %eax
addq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2657
leaq -0x68(%rbp), %rdi
movl %eax, %esi
callq 0x38ca
movups -0x68(%rbp), %xmm0
movups -0x5c(%rbp), %xmm1
movups %xmm1, 0xc(%rsp)
movups %xmm0, (%rsp)
movq -0x48(%rbp), %rdi
callq 0x2aec
movq %r14, %rdi
callq 0x2678
movq $0x989680, -0x70(%rbp)  # imm = 0x989680
leaq -0x70(%rbp), %rdi
callq 0x2685
jmp 0x2449
leaq -0x298(%rbp), %rdi
callq 0x2040
leaq -0x40(%rbp), %rdi
callq 0x26da
leaq -0x90(%rbp), %rdi
callq 0x20a0
leaq -0x298(%rbp), %rdi
callq 0x2050
xorl %eax, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25f0
movq %rax, %rbx
jmp 0x2608
movq %rax, %rbx
movq -0x48(%rbp), %rdi
callq 0x2120
jmp 0x2614
jmp 0x25f0
jmp 0x25f0
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x26da
leaq -0x90(%rbp), %rdi
callq 0x20a0
leaq -0x298(%rbp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21e0