Psyclone starts and detains all the informations and parameters about ALL the modules that are going to connect to it. A module starts (either the Market or an Industry) knowing only his ”<name>”. The module will get its parameters giving its name to Psyclone. In details the market will get its name (“Double Auction Market”) and its country (for this version just “is”) and will start to listen to the industries.
The main body of the market now is a simple loop that always returns back to listent to the industries, and once a message is received it parse it by getting the type:
An offer from a seller (according to the message content) will be stored into a dynamic array that will contain a list of < name | units | price > for every industry that posted a “sell” message. These industries will be waiting for the “sold” response from the market. They are waiting for someone to catch their offer.
If the Market receives a “buy” message and the “offers” array is not empty it will immediately scan this list to look for an offer that fits this bid:
if offer number N has enough units AND the price is lower than my max price
..that industry will get the carbon quotas it asked for.
If the Market gets a “buy” message but NO offers are in the list then a response will be immediately given. The content will contain the field “bought” set to “No”.
So that industry will go back to calculate its stuff (e.g. “how much is my amount right now? what do I have to do? buy or sell?..”)
The industry class is a skeleton for all of the industries since all of them have the same formulas. The only difference comes from the psySpec.xml file, which in a way behaves like the Government sending out rules and inital values to both the industries and the market.
The industries can send two kinds of messages:
And they listen to all messages from the market of the form:
In this first version the industries are able to get the initial values from the psySpec file. They can decide upon if they want to sell or buy carbon quotas.
To make the decision they do this simple calculation: amount = ((capacity * carbonRelease) - ownedQuota)