작업 조건 분석 기능 개발

This commit is contained in:
정영민
2025-03-10 16:42:23 +09:00
parent 840638c6e3
commit f2029fd8c9
2988 changed files with 569938 additions and 2342 deletions

View File

@@ -0,0 +1,81 @@
#define Graph_And_Chart_PRO
using UnityEngine;
using ChartAndGraph;
using System.Collections.Generic;
using System;
public partial class LargeDataFeed
{
public int RealtimeDownSampleCount = 10;
int currentDownSampleCount = 0;
DoubleVector3 DownSampleSum = new DoubleVector3();
partial void OnDataLoaded()
{
RestartDownSampleCount();
}
public void AppendRealtimeWithDownSampling(double x, double y, double slideTime = 0f)
{
if (graph == null)
return;
bool show = graph.AutoScrollHorizontally;
if (mData.Count == 0)
show = true;
else
{
double viewX = mData[mData.Count - 1].x;
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
double pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
if (viewX >= pageStartThreshold && viewX <= pageEndThreshold)
show = true;
}
var v = new DoubleVector2(x, y);
mData.Add(v);
if (show)
{
if (currentDownSampleCount >= RealtimeDownSampleCount)
{
RestartDownSampleCount();
graph.DataSource.AddPointToCategoryRealtime(Category, x, y, slideTime);
}
DownSampleSum += v.ToDoubleVector3();
currentDownSampleCount++;
var avarage = DownSampleSum * 1.0 / (double)currentDownSampleCount;
if(currentDownSampleCount != 1)
graph.DataSource.UpdateLastPointInCategoryRealtime(Category, avarage.x, avarage.y, slideTime);
}
else
RestartDownSampleCount();
}
void RestartDownSampleCount()
{
currentDownSampleCount = 0;
DownSampleSum = new DoubleVector3();
}
public void AppendPointRealtime(double x, double y, double slideTime = 0f)
{
if (graph == null)
return;
bool show = graph.AutoScrollHorizontally;
if (mData.Count == 0)
show = true;
else
{
double viewX = mData[mData.Count - 1].x;
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
double pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
if (viewX >= pageStartThreshold && viewX <= pageEndThreshold)
show = true;
}
mData.Add(new DoubleVector2(x, y));
if (show)
{
mSlideEndThreshold = x;
graph.DataSource.AddPointToCategoryRealtime(Category, x, y, slideTime);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1063c1a4134dbbc4b8d80e7b09a9c377
timeCreated: 1560596740
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,325 @@
#define Graph_And_Chart_PRO
using UnityEngine;
using ChartAndGraph;
using System.Collections.Generic;
using System;
using System.IO;
public partial class LargeDataFeed : MonoBehaviour, IComparer<DoubleVector2>
{
public string Category = "Player 1";
public int DownSampleToPoints = 100;
List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
double pageSize = 2f;
double currentPagePosition = 0.0;
double currentZoom = 0f;
GraphChartBase graph;
double mCurrentPageSizeFactor = double.NegativeInfinity;
public bool LoadExample = true;
public bool ControlViewPortion = false;
double? mSlideEndThreshold = null;
int mStart = 0;
[HideInInspector]
public GraphChartBase AlternativeGraph = null;
void Start()
{
graph = GetComponent<GraphChartBase>();
if (AlternativeGraph != null)
graph = AlternativeGraph;
if (LoadExample)
SetInitialData();
else
SetData(mData);
}
public DoubleVector2 GetLastPoint()
{
if (mData.Count == 0)
return new DoubleVector2();
return mData[mData.Count - 1];
}
/// <summary>
/// called with Start(). These will be used to load the data into the large data feed. You should replace this with your own loading logic.
/// </summary>
void SetInitialData()
{
List<DoubleVector2> data = new List<DoubleVector2>(250000);
double x = 0f;
double y = 200f;
for (int i = 0; i < 25000; i++) // initialize with random data
{
data.Add(new DoubleVector2(x, y));
y += UnityEngine.Random.value * 10f - 5f;
x += UnityEngine.Random.value;
}
SetData(data);
}
public void SaveToFile(string path)
{
using (StreamWriter file = new StreamWriter(path))
{
file.WriteLine(mData.Count);
for (int i = 0; i < mData.Count; i++)
{
DoubleVector2 item = mData[i];
file.WriteLine(item.x);
file.WriteLine(item.y);
}
}
}
public void LoadFromFile(string path)
{
try
{
List<DoubleVector2> data = new List<DoubleVector2>();
using (StreamReader file = new StreamReader(path))
{
int count = int.Parse(file.ReadLine());
for (int i = 0; i < count; i++)
{
double x = double.Parse(file.ReadLine());
double y = double.Parse(file.ReadLine());
data.Add(new DoubleVector2(x, y));
}
}
SetData(data);
}
catch (Exception)
{
throw new Exception("Invalid file format");
}
}
/// <summary>
/// vertify's that the graph data is sorted so it can be searched using a binary search.
/// </summary>
/// <returns></returns>
bool VerifySorted(List<DoubleVector2> data)
{
if (data == null)
return true;
for (int i = 1; i < data.Count; i++)
{
if (data[i].x < data[i - 1].x)
return false;
}
return true;
}
partial void OnDataLoaded();
/// <summary>
/// set the data of the large data graph
/// </summary>
/// <param name="data"></param>
public void SetData(List<DoubleVector2> data)
{
if (data == null)
data = new List<DoubleVector2>(); // set up an empty list instead of null
if (VerifySorted(data) == false)
{
Debug.LogWarning("The data used with large data feed must be sorted acoording to the x value, aborting operation");
return;
}
mData = data;
OnDataLoaded();
LoadPage(currentPagePosition); // load the page at position 0
}
int FindClosestIndex(double position) // if you want to know what is index is currently displayed . use binary search to find it
{
//NOTE :: this method assumes your data is sorted !!!
int res = mData.BinarySearch(new DoubleVector2(position, 0.0), this);
if (res >= 0)
return res;
return ~res;
}
double PageSizeFactor
{
get
{
return pageSize * graph.DataSource.HorizontalViewSize;
}
}
void AdjustVerticalView()
{
int start, end;
findAdjustPosition(graph.HorizontalScrolling,graph.DataSource.HorizontalViewSize,out start,out end);
double minY = double.MaxValue, maxY = double.MinValue;
bool show = graph.AutoScrollHorizontally;
if (mData.Count == 0)
show = true;
else
{
double viewX = mData[mData.Count - 1].x;
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
double pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
if (viewX >= pageStartThreshold && viewX <= pageEndThreshold)
show = true;
}
if (show)
--end;
for (int i=start; i<=end; i++)
{
double y = mData[i].y;
minY = Math.Min(y, minY);
maxY = Math.Max(y, maxY);
}
if(show)
{
DoubleVector3 p;
if (graph.DataSource.GetLastPoint(Category, out p))
{
minY = Math.Min(p.y, minY);
maxY = Math.Max(p.y, maxY);
}
}
graph.VerticalScrolling = minY;
graph.DataSource.VerticalViewSize = maxY - minY;
}
void findAdjustPosition(double position,double size,out int start,out int end)
{
int index = FindClosestIndex(position); // use binary search to find the closest position to the current scroll point
double endPosition = position + size;
start = index;
for (end = index; end < mData.Count; end++)
{
if (mData[end].x > endPosition) // take the first point that is out of the page
break;
}
}
void findPointsForPage(double position, out int start, out int end) // given a page position , find the right most and left most indices in the data for that page.
{
int index = FindClosestIndex(position); // use binary search to find the closest position to the current scroll point
double endPosition = position + PageSizeFactor;
double startPosition = position - PageSizeFactor;
//starting from the current index , we find the page boundries
for (start = index; start > 0; start--)
{
if (mData[start].x < startPosition) // take the first point that is out of the page. so the graph doesn't break at the edge
break;
}
for (end = index; end < mData.Count; end++)
{
if (mData[end].x > endPosition) // take the first point that is out of the page
break;
}
}
public void Update()
{
if (graph != null)
{
//check the scrolling position of the graph. if we are past the view size , load a new page
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
double pageEnd = currentPagePosition + mCurrentPageSizeFactor;
if (mSlideEndThreshold.HasValue)
pageEnd = Math.Max(mSlideEndThreshold.Value, pageEnd);
double pageEndThreshold = pageEnd - graph.DataSource.HorizontalViewSize*1.0001;
if (graph.HorizontalScrolling < pageStartThreshold || graph.HorizontalScrolling > pageEndThreshold || currentZoom >= graph.DataSource.HorizontalViewSize * 2f)
{
currentZoom = graph.DataSource.HorizontalViewSize;
mCurrentPageSizeFactor = PageSizeFactor * 0.9f;
LoadPage(graph.HorizontalScrolling);
}
if (ControlViewPortion)
AdjustVerticalView();
}
}
void LoadWithoutDownSampling(int start, int end)
{
for (int i = start; i < end; i++) // load the data
{
graph.DataSource.AddPointToCategory(Category, mData[i].x, mData[i].y);
}
}
void LoadWithDownSampling(int start, int end)
{
int total = end - start;
if (DownSampleToPoints >= total)
{
LoadWithoutDownSampling(start, end);
return;
}
double sampleCount = ((double)total) / (double)DownSampleToPoints;
// graph.DataSource.AddPointToCategory(Category, mData[start].x, mData[start].y);
for (int i = 0; i < DownSampleToPoints; i++)
{
int fractionStart = start + (int)(i * sampleCount); // the first point with a fraction
int fractionEnd = start + (int)((i + 1) * sampleCount); // the first point with a fraction
fractionEnd = Math.Min(fractionEnd, mData.Count - 1);
double x = 0, y = 0;
double divide = 0.0;
for (int j = fractionStart; j < fractionEnd; j++) // avarge the points
{
x += mData[j].x;
y += mData[j].y;
divide++;
}
if (divide > 0.0)
{
x /= divide;
y /= divide;
graph.DataSource.AddPointToCategory(Category, x, y);
}
else
Debug.Log("error");
}
// graph.DataSource.AddPointToCategory(Category, mData[last].x, mData[last].y);
}
public int GetIndex(int inGraphIndex)
{
return mStart + inGraphIndex;
}
void LoadPage(double pagePosition)
{
mSlideEndThreshold = null;
if (graph != null)
{
Debug.Log("Loading page :" + pagePosition);
graph.DataSource.StartBatch(); // call start batch
graph.DataSource.HorizontalViewOrigin = 0;
int start, end;
findPointsForPage(pagePosition, out start, out end); // get the page edges
graph.DataSource.ClearCategory(Category); // clear the cateogry
mStart = start;
if (DownSampleToPoints <= 0)
LoadWithoutDownSampling(start, end);
else
LoadWithDownSampling(start, end);
graph.DataSource.EndBatch();
graph.HorizontalScrolling = pagePosition;
}
currentPagePosition = pagePosition;
}
public int Compare(DoubleVector2 x, DoubleVector2 y)
{
if (x.x < y.x)
return -1;
if (x.x > y.x)
return 1;
return 0;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 858eac91acdb9154ea539c6c801e5624
timeCreated: 1500217865
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
#define Graph_And_Chart_PRO
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RealtimeAppend : MonoBehaviour
{
float time = 1f;
double x = -1 , y = -1;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
time -= Time.deltaTime;
if(time <= 0f)
{
time = 1f;
var feed = GetComponent<LargeDataFeed>();
if (feed != null)
{
if (x == -1)
{
var v = feed.GetLastPoint();
x = v.x;
y = v.y;
}
y += UnityEngine.Random.value * 10f - 5f;
x += UnityEngine.Random.value;
feed.AppendRealtimeWithDownSampling(x, y, 1f);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2040fcec7bc19c4b87961fc8d69a146
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 55211ec481c096c448afc8e78647e441
timeCreated: 1500217865
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: graphSettings
serializedVersion: 6
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 1
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentImportanceSampling: 0
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c2e3132bc38c5c949b79c6fee1ec02f2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dea45a3b0a59b0647b2bd8fb5255994e
timeCreated: 1500217865
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: realtimeSettings
serializedVersion: 6
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 1
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentImportanceSampling: 0
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d1fe1f7b9eabcd047a2032ed17ae823f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant: