What are the components of the Pain System, and what is the function of each component?

What are the components of the Pain System, and what is the function of each component? How does each component know whether to increase or decrease its functioning?