ShanxiKnowledgeBase/SXElectricityInformationAcq.../Assets/Scripts/InfoDataManager.cs

89 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using MotionFramework;
using UnityEngine;
public class InfoDataManager : ModuleSingleton<InfoDataManager>, IModule
{
private void ParseFileContent(string content)
{
// 首先按照 # 进行分割,获取日期和数据部分
var parts = content.Split('#');
if (parts.Length < 2)
{
Debug.LogError("Invalid file format.");
return;
}
// 日期部分
string date = parts[0];
Debug.Log("Date: " + date);
// 数据部分
string dataPart = parts[1];
// 进一步分割数据部分
var dataSections = dataPart.Split(';');
if (dataSections.Length < 2)
{
Debug.LogError("Invalid data format.");
return;
}
// 第一部分 sxfz://
string prefix = dataSections[0];
Debug.Log("Prefix: " + prefix);
// 第二部分 lyht,0,18,userId,username,token,90
string dataSection = dataSections[1];
var dataElements = dataSection.Split(',');
if (dataElements.Length < 7)
{
Debug.LogError("Invalid data section format.");
return;
}
string code = dataElements[0];
string value1 = dataElements[1];
string value2 = dataElements[2];
string userId = dataElements[3];
string username = dataElements[4];
string token = dataElements[5];
string value3 = dataElements[6];
Debug.Log("Code: " + code);
Debug.Log("Value 1: " + value1);
Debug.Log("Value 2: " + value2);
Debug.Log("User ID: " + userId);
Debug.Log("Username: " + username);
Debug.Log("Token: " + token);
Debug.Log("Value 3: " + value3);
MotionEngine.GetModule<DataConfigManager>().SetProcessMode(int.Parse(value1));
}
public void OnCreate(object createParam)
{
string content = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/info.ini");
ParseFileContent(content);
}
public void OnUpdate()
{
}
public void OnDestroy()
{
}
public void OnGUI()
{
}
}