index and amount are relevant for communicating with the arduino library.
Index is used to keep a reference to the numerical index in the arduino array, independent from the js object "index" position (which can change).
It helps to minimize the SerialData traffic to just sending numbers.
By initializing the object, the server checks if a IOpoint with the added index exists.
If the name is identical it keeps the IOpoint and its data. If not, the IOpoint is deleted and a new IOpoint with the index is added.
To clear the objectValues, the arduino library sends the amount of IOpoints the server can count with.
The server deletes all IOpoints with a bigger index.
This is all done so that the existing values associated with the IOpoints are not overwritten every time the server restarts.
Because all the appearance of the IOpoint in the GUI and all relevant data about the IOpoint is saved in the objectValues and in a file on disk for the next program start, you need to keep track what is already existing the moment you run the initialization. Otherwise your GUI will reset with every start.
We can move the amount and index code in to the ArduinoYun interface. It is very specific and should not be in a generalized API.
I had a lookup table for the index before. We can bring this idea back. The lookup table simply keeps track of the arduino numerical index associated with the objectValues name index.
This will allow to remove the index from the objectValues and all the routines outside of the ArduinoYun hardware interface.
Never the less, the API should have some code to keep track what IOpoints are used, if they existed before and which IOpoints are obsolet and can be deleted.