This is just an Activity that shows up when the user first installs and runs the app. It shows our animated logo before proceeding to the main activity. We used an API to get the GIF to play.
This is where all the previous layers are connected. More importantly, this is where we plot the data sent from the Data Processing service. Here we initialize the plot (we used the API listed below for this). The plot graphs all data sent from the data service and then uses the bounded interface function to release the semaphore in the data service, this achieves the synchronization between the data processing thread and the plotting on the UI thread.
This takes care of handling all events and updates to and from the side menu user interface. This class also initializes all elements in the side menu, creating the animations for events on the menu, assigning the correct initial text and assigning on-click listeners for all buttons. The Side Menu class handles all updates between the pen and the main activity. A change in volt/div, for example, first begins in the Side Menu and is propagated down to the Scopen Comm Service class. An event from the pen is propagated from the Scopen Comm class to the Side Menu.
This is implemented as a bound service to the main activity. This allows the main activity to control the service using an interface class to send information such as current volt/div or time/div settings being used. To communicate to the main activity, the service uses a broadcast to send the data.
Here data (in bytes) is converted from a large buffer (10 to 20K bytes) to a double array with the corresponding voltage. After this, the thread determines (according to the time/div setting) how many points we need from the large array to send to the main activity. Once this is done, a semaphore is invoked and the sub array with the data to plot is sent out via broadcast to the main activity. The semaphore guarantees that the thread will lock in that spot until it is released. This guarantees that the thread will not send data to the main activity while it is being plotted. It is released by the main activity once the plotting is done via a function from the bounded interface.
This is implemented as a bound service to the main activity. This allows the main activity to control the service using an interface class. To communicate from the service to the main activity, we use a broadcast to transmit information such as when we are connected to the pen etc.
This code is mainly taken from the Java applet we worked on for the Capstone project. We had to adapt several things, however. For example, all of the networking had to be done on a different thread since Android doesn't allow networking to be done on the UI thread.
UDP datagram sends out a message to the network and our Scopen picks it up and replies via UDP with its network information
Transmit TCP socket handles all outgoing communication from the app to the Scopen
Receive TCP socket handles all incoming data from the Scopen to the app
This code handles reading all incoming and outgoing messages. All outgoing messages must be sent in a specific format. All incoming messages are parsed to see what the message contains (either data, commands, or battery status).
Features:
Interface callback functions tell us when data or commands are received