Simultaneous H bridge shield code (SIMULINK) and WiFi shield code(IDE) deploying

I have a arduino MEGA 2560. I am using an arduino wifi shield along with it. Since my application (production of heat using heat bulbs)required a current of 8A, I used a dual channel H Bridge shield on top of the arduino board which was able to withstand and provide the supply.

I have separately tried out the Simulink code and it works perfectly. I now want to transfer the data of the control of temperature achieved using the H BRIDGE sheld(Simulink program) to the internet using arduino WiFi shield.

How do I program the wifi shield and the h bridge shield simultaneously. The arduino mega 2560 board is where the code gets written into. How can I make both the codes run at the same time? Does not the arduino erase the code stored in it while accepting a new code?

The H Bridge shield and Wifi shield are stacked and mounted upon the MEGA 2560 in the same order. Kindly guide me as to how I should proceed with this.

How do I program the wifi shield and the h bridge shield simultaneously.

You can't program either one of them. The WiFi shield and library includes all the programming it needs. The H bridge is not programmable.

Both are CONTROLLABLE, not programmable.

How can I make both the codes run at the same time?

You can't. You can merge the two programs to create one program that can be run, that does both things sort of at the same time.

Kindly guide me as to how I should proceed with this.

The general advice is to POST YOUR CODE!

Please provide me a sample code which merges wifi program with a motor shield program