286 lines
11 KiB
C#
286 lines
11 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using Aurora.View;
|
|
using ILSOS_PrismaticGun.Recipes;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Reactive;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static ILSOS_PrismaticGun.Recipes.MainRecipe;
|
|
|
|
namespace ILSOS_PrismaticGun.Recipes
|
|
{
|
|
public class MainRecipe : NotifyPropertyChangedBase, IRecipeItem, ICloneable
|
|
{
|
|
public enum eOutType
|
|
{
|
|
AnalogCtrlVelocityRatio, // V
|
|
PulseCtrlEncoderSamePitch, // hz
|
|
PulseCtrlPulseWidth
|
|
}
|
|
public MainRecipe()
|
|
{
|
|
CurveParam = new LineParameter();
|
|
StraightParam = new LineParameter();
|
|
PFMParam = new PulsePFMParameter();
|
|
PWMParam = new PulsePWMParameter();
|
|
|
|
CurveParam.PropertyChanged += ParameterChanged;
|
|
StraightParam.PropertyChanged += ParameterChanged;
|
|
}
|
|
|
|
private void ParameterChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName == nameof(LineParameter.CorePowerW) || e.PropertyName == nameof(LineParameter.RingPowerW)) {
|
|
CurveParam.RingPowerW = CurveParam.CorePowerW * (100 - GetCoreRatio()) / GetCoreRatio();
|
|
}
|
|
}
|
|
// Laser Parameter
|
|
|
|
public eOutType OutputType { get => _OutputType; set => SetProperty(ref _OutputType, value); }
|
|
private eOutType _OutputType;
|
|
public LineParameter CurveParam { get; set; }
|
|
public LineParameter StraightParam { get; set; }
|
|
public PulsePFMParameter PFMParam { get; set; }
|
|
public PulsePWMParameter PWMParam { get; set; }
|
|
|
|
// Motion Parameter
|
|
public double CurveVelocity { get; set; }
|
|
public double StraightVelocity { get; set; }
|
|
public double WeldingAcc { get; set; }
|
|
//public double AxisTPosition { get; set; }
|
|
public double AxisZPosition { get; set; }
|
|
|
|
public ProcessUnit StartPos { get; set; } = new ProcessUnit();
|
|
public ProcessUnit EndPos { get; set; } = new ProcessUnit();
|
|
|
|
public ProcessUnit MarkPos { get; set; } = new ProcessUnit();
|
|
public double MarkVoltage { get; set; }
|
|
public int MarkShotTimeMsec { get; set; }
|
|
|
|
//Binding된 객체가 []로 호출 시, 최초 데이터를 저장(생성)하지 못함.
|
|
//public ObservableCollection<ProcessArc> Arc { get; set; } = new ObservableCollection<ProcessArc>(new List<ProcessArc>(4));
|
|
public ProcessArc Arc1 { get; set; } = new ProcessArc();
|
|
public ProcessArc Arc2 { get; set; } = new ProcessArc();
|
|
public ProcessArc Arc3 { get; set; } = new ProcessArc();
|
|
public ProcessArc Arc4 { get; set; } = new ProcessArc();
|
|
public ObservableCollection<ProcessUnit> Units { get; set; } = new ObservableCollection<ProcessUnit>(new List<ProcessUnit>(8));
|
|
|
|
public bool HeightMeasureSkip { get; set; }
|
|
/*
|
|
장변 편차 (인덱스 번호 1번-4번, 5번-8번 편차)
|
|
단변 편차(인덱스 번호 1번-5번, 4번-8번 편차)
|
|
4 3 2 1
|
|
8 7 6 5
|
|
*/
|
|
public double JudgeLimit { get; set; }
|
|
public ObservableCollection<HeightMeareUnit> HeightSensorMeasurePoints { get; set; } = new ObservableCollection<HeightMeareUnit>();
|
|
|
|
public double LaserOnPosition { get; set; }
|
|
//public double LaserOnPositionOffset { get; set; }
|
|
//public double LaserOffPosition { get; set; }
|
|
//public double LaserOffPositionOffset { get; set; }
|
|
//public double RampingOnStartPos { get; set; }
|
|
public double RampingOnOverlapDist { get; set; }
|
|
public double RampingOnStartPower { get; set; }
|
|
public double RampingOffStartPos { get; set; }
|
|
public double RampingOffOverlapDist { get; set; }
|
|
public double RampingOffEndPower { get; set; }
|
|
// Min, Max 고민 필요
|
|
public double N2PressMFC { get; set; }
|
|
|
|
// notused Laser
|
|
public bool IsReviewMode { get => _IsReviewMode; set => SetProperty(ref _IsReviewMode, value); }
|
|
private bool _IsReviewMode;
|
|
public bool IsMarkMode { get; set; } = false;
|
|
|
|
|
|
// %
|
|
internal int GetCoreRatio() => (int)((StraightParam.CorePowerW / (StraightParam.CorePowerW + StraightParam.RingPowerW)) * 100);
|
|
public void UpdateCurveRingPower() => CurveParam.RingPowerW = CurveParam.CorePowerW * (100 - GetCoreRatio()) / GetCoreRatio();
|
|
|
|
public object Clone()
|
|
{
|
|
MainRecipe newRecipe = new MainRecipe();
|
|
newRecipe.CurveParam = CurveParam.Clone() as LineParameter;
|
|
newRecipe.StraightParam = StraightParam.Clone() as LineParameter;
|
|
newRecipe.PFMParam = PFMParam.Clone() as PulsePFMParameter;
|
|
newRecipe.PWMParam = PWMParam.Clone() as PulsePWMParameter;
|
|
newRecipe.WeldingAcc = WeldingAcc;
|
|
newRecipe.AxisZPosition = AxisZPosition;
|
|
newRecipe.StartPos = StartPos.Clone() as ProcessUnit;
|
|
newRecipe.EndPos = EndPos.Clone() as ProcessUnit;
|
|
newRecipe.MarkPos = MarkPos.Clone() as ProcessUnit;
|
|
newRecipe.MarkVoltage = MarkVoltage;
|
|
newRecipe.MarkShotTimeMsec = MarkShotTimeMsec;
|
|
newRecipe.Arc1 = Arc1.Clone() as ProcessArc;
|
|
newRecipe.Arc2 = Arc2.Clone() as ProcessArc;
|
|
newRecipe.Arc3 = Arc3.Clone() as ProcessArc;
|
|
newRecipe.Arc4 = Arc4.Clone() as ProcessArc;
|
|
|
|
for (int i = 0; i < Units.Count; i++)
|
|
newRecipe.Units.Add(Units[i].Clone() as ProcessUnit);
|
|
|
|
newRecipe.HeightMeasureSkip = HeightMeasureSkip;
|
|
newRecipe.JudgeLimit = JudgeLimit;
|
|
|
|
for (int i = 0; i < HeightSensorMeasurePoints.Count; i++)
|
|
newRecipe.HeightSensorMeasurePoints.Add(HeightSensorMeasurePoints[i].Clone() as HeightMeareUnit);
|
|
|
|
newRecipe.LaserOnPosition = LaserOnPosition;
|
|
newRecipe.RampingOnOverlapDist = RampingOnOverlapDist;
|
|
newRecipe.RampingOnStartPower = RampingOnStartPower;
|
|
newRecipe.RampingOffStartPos = RampingOffStartPos;
|
|
newRecipe.RampingOffOverlapDist = RampingOffOverlapDist;
|
|
newRecipe.RampingOffEndPower = RampingOffEndPower;
|
|
newRecipe.N2PressMFC = N2PressMFC;
|
|
newRecipe.IsReviewMode = IsReviewMode;
|
|
newRecipe.IsMarkMode = IsMarkMode;
|
|
|
|
return newRecipe;
|
|
}
|
|
/*
|
|
var coreRatio = _mainRecipe.StraightParam.StraightCorePowerW / (_mainRecipe.StraightParam.StraightCorePowerW + _mainRecipe.StraightParam.StraightCorePowerW);
|
|
var Max = 3000;
|
|
var CoreMax = Max * coreRatio;
|
|
var StraightVoltage = (_mainRecipe.StraightParam.StraightCorePowerW / CoreMax) * 10;
|
|
var CornerVoltage = (_mainRecipe.StraightParam.CornerCorePowerW / CoreMax) * 10;
|
|
_mainRecipe.StraightParam.CornerRingPowerW = _mainRecipe.StraightParam.CornerRingPowerW * (1 - coreRatio / coreRatio);
|
|
|
|
_laser.SetData(csWriteNodeNo.IW03, (int)coreRatio);
|
|
*/
|
|
}
|
|
}
|
|
public class LineParameter : NotifyPropertyChangedBase, ICloneable
|
|
{
|
|
public double ShotTime { get => _ShotTime; set => _ShotTime = value; }
|
|
private double _ShotTime;
|
|
// Min, Max 고민 필요
|
|
public double Velocity { get; set; }
|
|
|
|
public double CorePowerW { get => _CorePowerW; set => SetProperty(ref _CorePowerW, value); }
|
|
public double _CorePowerW;
|
|
public double RingPowerW { get => _RingPowerW; set => SetProperty(ref _RingPowerW, value); }
|
|
public double _RingPowerW;
|
|
|
|
public object Clone()
|
|
{
|
|
LineParameter newItem = new LineParameter();
|
|
newItem.ShotTime = ShotTime;
|
|
newItem.Velocity = Velocity;
|
|
newItem.CorePowerW = CorePowerW;
|
|
newItem.RingPowerW = RingPowerW;
|
|
return newItem;
|
|
}
|
|
}
|
|
|
|
public class PulsePFMParameter : NotifyPropertyChangedBase, ICloneable
|
|
{
|
|
//public double PowerW { get => _PowerW; set => SetProperty(ref _PowerW, value); }
|
|
//public double _PowerW;
|
|
|
|
// EncoderSamePitch
|
|
public double PfmPulseWidth { get => _PfmPulseWidth; set => SetProperty(ref _PfmPulseWidth, value); }
|
|
private double _PfmPulseWidth;
|
|
public double PfmPulseInterval { get => _PfmPulseInterval; set => SetProperty(ref _PfmPulseInterval, value); }
|
|
private double _PfmPulseInterval;
|
|
public object Clone()
|
|
{
|
|
PulsePFMParameter newItem = new PulsePFMParameter();
|
|
//newItem.PowerW = PowerW;
|
|
newItem.PfmPulseWidth = PfmPulseWidth;
|
|
newItem.PfmPulseInterval = PfmPulseInterval;
|
|
return newItem;
|
|
}
|
|
}
|
|
|
|
public class PulsePWMParameter : NotifyPropertyChangedBase, ICloneable
|
|
{
|
|
//public double PowerW { get => _PowerW; set => SetProperty(ref _PowerW, value); }
|
|
//public double _PowerW;
|
|
public double PwmPulseFrequency { get => _PwmPulseFrequency; set => SetProperty(ref _PwmPulseFrequency, value); }
|
|
private double _PwmPulseFrequency;
|
|
public double PwmMaxPulseWidth { get => _PwmMaxPulseWidth; set => SetProperty(ref _PwmMaxPulseWidth, value); }
|
|
private double _PwmMaxPulseWidth;
|
|
public double PwmMinPulseWidth { get => _PwmMinPulseWidth; set => SetProperty(ref _PwmMinPulseWidth, value); }
|
|
private double _PwmMinPulseWidth;
|
|
public object Clone()
|
|
{
|
|
PulsePWMParameter newItem = new PulsePWMParameter();
|
|
//newItem.PowerW = PowerW;
|
|
newItem.PwmPulseFrequency = PwmPulseFrequency;
|
|
newItem.PwmMaxPulseWidth = PwmMaxPulseWidth;
|
|
newItem.PwmMinPulseWidth = PwmMinPulseWidth;
|
|
return newItem;
|
|
}
|
|
}
|
|
|
|
public class ProcessUnit : NotifyPropertyChangedBase, ICloneable
|
|
{
|
|
public int Index { get => _Index; set => SetProperty(ref _Index, value); }
|
|
private int _Index;
|
|
|
|
public double PosX { get => _PosX; set => SetProperty(ref _PosX, value); }
|
|
private double _PosX;
|
|
|
|
public double PosY { get => _PosY; set => SetProperty(ref _PosY, value); }
|
|
private double _PosY;
|
|
|
|
public object Clone()
|
|
{
|
|
ProcessUnit newItem = new ProcessUnit();
|
|
newItem.Index = Index;
|
|
newItem.PosX = PosX;
|
|
newItem.PosY = PosY;
|
|
return newItem;
|
|
}
|
|
}
|
|
|
|
public class ProcessArc : NotifyPropertyChangedBase, ICloneable
|
|
{
|
|
public int Index { get => _Index; set => SetProperty(ref _Index, value); }
|
|
private int _Index;
|
|
|
|
public double Size { get => _Size; set => SetProperty(ref _Size, value); }
|
|
private double _Size;
|
|
|
|
public object Clone()
|
|
{
|
|
ProcessArc newItem = new ProcessArc();
|
|
newItem.Index = Index;
|
|
newItem.Size = Size;
|
|
return newItem;
|
|
}
|
|
}
|
|
|
|
public class HeightMeareUnit : NotifyPropertyChangedBase, ICloneable
|
|
{
|
|
public int Index { get => _Index; set => SetProperty(ref _Index, value); }
|
|
private int _Index;
|
|
|
|
public double PosX { get => _PosX; set => SetProperty(ref _PosX, value); }
|
|
private double _PosX;
|
|
|
|
public double PosY { get => _PosY; set => SetProperty(ref _PosY, value); }
|
|
private double _PosY;
|
|
|
|
public object Clone()
|
|
{
|
|
HeightMeareUnit newItem = new HeightMeareUnit();
|
|
newItem.Index = Index;
|
|
newItem.PosX = PosX;
|
|
newItem.PosY = PosY;
|
|
return newItem;
|
|
}
|
|
|
|
//public double LoadDirRefBase { get => _LoadDirRefBase; set => SetProperty(ref _LoadDirRefBase, value); }
|
|
//private double _LoadDirRefBase;
|
|
|
|
//public double UnloadDirRefBase { get => _UnloadDirRefBase; set => SetProperty(ref _UnloadDirRefBase, value); }
|
|
//private double _UnloadDirRefBase;
|
|
} |