<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def publish_mainswitch_state(self, state):
 """publish changed mainswitch state"""

        self.sequence_number += 1
        self.publisher.send_multipart(msgs.MessageBuilder.mainswitch_state(self.sequence_number, state))
        return self.sequence_number