103 lines
3.6 KiB
C#
103 lines
3.6 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using Simulator.Config;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UVC.Core;
|
|
using UVC.Data;
|
|
using UVC.Data.Core;
|
|
using UVC.Data.Mqtt;
|
|
using UVC.Locale;
|
|
using UVC.Util;
|
|
|
|
namespace SampleProject
|
|
{
|
|
[DefaultExecutionOrder(100)]
|
|
public class AppMain : SingletonApp<AppMain>
|
|
{
|
|
|
|
public Action Initialized;
|
|
|
|
/// <summary>
|
|
/// 초기 화 메서드입니다.
|
|
/// Awake 메서드에서 호출되며, MonoBehaviour가 생성될 때 한 번만 실행됩니다.
|
|
/// </summary>
|
|
protected override async void Init()
|
|
{
|
|
Debug.Log("test");
|
|
// 플레이 모드가 아닐 경우, 초기화 로직을 실행하지 않습니다.
|
|
if (!Application.isPlaying) return;
|
|
|
|
//로깅 설정
|
|
//Log4netCodeConfigurator.Setup();
|
|
|
|
await SettupConfigAsync();
|
|
SetNetworkConfig();
|
|
if (Initialized != null)
|
|
{
|
|
Initialized.Invoke();
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
//Tester.RunAllTests();
|
|
}
|
|
|
|
private async UniTask SettupConfigAsync()
|
|
{
|
|
if (AppConfig.LoadConfig())
|
|
{
|
|
Application.targetFrameRate = AppConfig.Config.TargetFrameRate;
|
|
|
|
//기본 언어 설정
|
|
bool success = LocalizationManager.Instance.LoadDefaultLocalizationData(AppConfig.Config.Language);
|
|
Debug.Log($"LocalizationManager: LoadDefaultLocalizationData success: {success}");
|
|
if (!Application.isEditor && Application.platform == RuntimePlatform.WindowsPlayer)
|
|
{
|
|
//창 설정
|
|
if (AppConfig.Config.Window != null)
|
|
{
|
|
WindowTools.Instance.Init(AppConfig.Config.Window);
|
|
}
|
|
}
|
|
|
|
Constants.API_DOMAIN = AppConfig.Config.Api;
|
|
Constants.MQTT_DOMAIN = AppConfig.Config.Mqtt.Domain;
|
|
Constants.MQTT_PORT = AppConfig.Config.Mqtt.Port;
|
|
Constants.MQTT_DATA_KEY = AppConfig.Config.Mqtt.DataKey;
|
|
Constants.MQTT_MESSAGEPACK_ENABLED = AppConfig.Config.Mqtt.MessagePack;
|
|
}
|
|
|
|
//사용자 DataMask 설정 AppData에서 로드
|
|
await UserSetting.LoadFromAppData();
|
|
|
|
}
|
|
|
|
private void SetNetworkConfig()
|
|
{
|
|
|
|
URLList.Add("baseinfo", $"{Constants.API_DOMAIN}/baseinfo");
|
|
URLList.Add("playbackList", $"{Constants.API_DOMAIN}/playback/list");
|
|
URLList.Add("playbackFile", $"{Constants.API_DOMAIN}/playback");
|
|
|
|
|
|
//DataRepository.Instance.MqttReceiver.SetDomainPort("mqtt-input.flexing.ai", 3000);//VTM 외부망
|
|
//DataRepository.Instance.MqttReceiver.SetDomainPort("localhost", 1883);
|
|
//DataRepository.Instance.MqttReceiver.SetDataPicker(new MqttDataPicker(Constants.MQTT_DATA_KEY, Constants.MQTT_MESSAGEPACK_ENABLED));
|
|
DataRepository.Instance.MqttReceiver.SetDomainPort(Constants.MQTT_DOMAIN, Constants.MQTT_PORT);
|
|
DataRepository.Instance.MqttReceiver.AddTopic("AGV");
|
|
DataRepository.Instance.MqttReceiver.AddTopic("ALARM");
|
|
DataRepository.Instance.MqttReceiver.AddTopic("PORT");
|
|
//DataRepository.Instance.MqttReceiver.AddTopic("AGV_RECIPE");
|
|
|
|
//10초 후 정지
|
|
//UniTask.Delay(TimeSpan.FromSeconds(10)).ContinueWith(() =>
|
|
//{
|
|
// DataRepository.Instance.MqttReceiver.Exit();
|
|
//});
|
|
}
|
|
|
|
}
|
|
}
|