# !!! WORK IN PROGRESS !!!

Personalization scripts for Beyond hardware.

For the Beyond Cushion:
1. Collection and conversion of customer face scan files.
2. Conversion from the 3D scan data to "gcode" output that can be used to generate a mould for producing the actual finished cushion.


# Jobs

1. When order is created, attach a fullfilment plan, which is a list of jobIds that have to be completed before we can fulfil the order (i.e. fulfil = complete all items in the order and ship it to a customer).
2. Each job has a type, a state machine associated with the type of job, and an initial state.
3. A "job" is a long running task with various discrete states.
4. A job can be locked by any service while that service is doing something with the job. The lock is associated with a state transition for the job.
5. With the job, each state transition is function with a timeout attached (i.e if the function succeeds, the job state changes to the next step, otherwise return to the previous state with an error code, or invalidate the job completely.)
6. 

Initial cushion job life cycle:
1. State: waiting for customer scan
2. State: running scan.
3. State: Scan completed or error
4. State: Scan verified.
5. State: Ready for toolpath.
6. State: Allocating wax id.
6. State: Running toopath.
7. State: Toolpath failed.
8. State: Toolpath success.
9. State: Toolpath verified.
10. Ready for manufacture.

Mold and manufacture
11. Create mold
12. Check mold
13. Allocated NFT code.
14. Create 

## Toolpath Process

1. Loop checks job ids with status "ready for toolpath". If one or more present, pull one off the top, sets status to "processing toolpath" within critical section.
2. Spawn fusion server with the job id.
3. Server gets the job info, downloads the input files from the job id file location.
4. Runs the toolpath generator in Fusion360 until done.
5. If the Fusion360 job failed, then set state to "toolpath failed" and attach error logs.
6. If the Fusion360 toolpath job succeeded, the Uploads the files to S3.
6. Updates the job with the status of the build "toolpath success" or .
7. Loop updates the job to "ready for mold creation".