choieigun d31020df72 LbadAvg
- NaN = 미수신
- 0.0은 수신됐으나 측정값 0

Add WeldingLog
2026-03-10 16:37:19 +09:00

80 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeldingCommon.Utils
{
public class ChangeChecker
{
private static Dictionary<string, bool> mapping = new Dictionary<string, bool>();
public static bool IsChangedBool(string Resource, bool value, bool defaultVal = false)
{
if (mapping.ContainsKey(Resource) == false) {
mapping[Resource] = defaultVal;
return false;
}
if (mapping[Resource] == value) {
return false;
}
mapping[Resource] = value;
return true;
}
public static bool IsChangedBoolMonitoring(string Resource, bool value, bool MonitoringValue, bool defaultVal = false)
{
if (mapping.ContainsKey(Resource) == false) {
mapping[Resource] = defaultVal;
return false;
}
if (mapping[Resource] == value) {
return false;
}
mapping[Resource] = value;
if(mapping[Resource] == MonitoringValue)
return true;
return false;
}
private static Dictionary<string, int> mappingInt = new Dictionary<string, int>();
public static bool IsChangedInt(string Resource, int value, int defaultVal = 0)
{
if (mappingInt.ContainsKey(Resource) == false) {
mappingInt[Resource] = defaultVal;
return false;
}
if (mappingInt[Resource] == value) {
return false;
}
mappingInt[Resource] = value;
return true;
}
public static bool IsChangedInt(string Resource, int value, out int prevalue, int defaultVal = 0)
{
if (mappingInt.ContainsKey(Resource) == false) {
mappingInt[Resource] = defaultVal;
prevalue = mappingInt[Resource];
return false;
}
if (mappingInt[Resource] == value) {
prevalue = value;
return false;
}
prevalue = mappingInt[Resource];
mappingInt[Resource] = value;
return true;
}
}
}