Beispiel #1
0
	private void DisableModule(RobotModule m)
	{		
		m.SetState(ModuleState.Shutdown);

		ControlMessage msg = ControlMessage.DisableMessage(m.name);

		Send (msg);
		print(name + " - disable module " + m.name);
	}
Beispiel #2
0
	private void EnableModule(RobotModule m)
	{		
		m.SetState(ModuleState.Initializing);

		ControlMessage msg = ControlMessage.EnableMessage (m.name, m.ModuleCall (), (ushort)m.CreationDelayMs ());

		print(name + " - enable module " + m.name);
		Send (msg);

	}
Beispiel #3
0
	protected virtual void Awake()
	{
		uiTransform = Instantiate<Transform>(UiTransform);
		moduleName = SafeInstantiateText(ModuleName, uiTransform, "module");
		moduleStateToggle = SafeInstantiate<Toggle>(ModuleStateToggle, uiTransform);
		moduleStateToggle.onValueChanged.AddListener(SetEnable);
		moduleState = moduleStateToggle.GetComponentInChildren<Text>();
		moduleState.text = ModuleState.Offline.ToString().ToLower();
		control = transform.parent.GetComponentInChildren<Control> ();
		module = GetComponent<RobotModule> ();
	}
Beispiel #4
0
	public void EnableDisableModule(string unique_module_name, bool enable)
	{
		if (replay.ReplayAny())
		{
			print(name + " - ignoring request to enable/disable " + unique_module_name + " (replay)");
			return;
		}

		RobotModule mod = modules.Find(m => (m.name == unique_module_name));

		if(enable)
			EnableModule(mod);
		else
			DisableModule(mod);

	}
Beispiel #5
0
	private void ProcessMessage(ControlMessage message)
	{
		ControlCommands cmd = message.GetCommand();

		switch (cmd)
		{
			case ControlCommands.KEEPALIVE:
				break;
			case ControlCommands.ENABLED:				
			case ControlCommands.DISABLED:
			case ControlCommands.FAILED: //failed has additional information on error code
				RobotModule module = modules.Find(m => (m.name == message.Attribute<string>(0)));
				print(name + " - " + module.name + " state changed to " + cmd.ToString());
				module.SetState(ModuleStateFromControlCommand(cmd));
				break;
			default:
				print(name + " - ignoring unsupported command " + message.GetType());
				break;
		}
	}