100 lines
3.8 KiB
C#
100 lines
3.8 KiB
C#
using Aurora;
|
|
using Aurora.Api;
|
|
using Aurora.View;
|
|
using AuroraUIComponent.Sequence;
|
|
using AuroraUIComponent.UserControls.SequenceDrawer;
|
|
using CoreUnit.Scanner.UserControl.ScannerCanvas;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reactive.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
using VisionCommon;
|
|
using WeldingCommon.Recipes;
|
|
using WeldingCommon.Sequences;
|
|
using static WeldingCommon.Views.UCScannerObjectTeachingViewModel;
|
|
|
|
namespace WeldingCommon.Views
|
|
{
|
|
public class UCCommonAutoRunViewModel : NotifyPropertyChangedBase
|
|
{
|
|
private readonly Logger Log = new Logger("UCCommonAutoRunViewModel");
|
|
|
|
public delegate void ExternalRecipeUpdate(Logger log, IAuroraEnvironment aurora);
|
|
public static ExternalRecipeUpdate RecipeUpdate;
|
|
|
|
public ICommand CMD_VisibleChanged { get; }
|
|
|
|
private readonly IAuroraEnvironment _Aurora;
|
|
|
|
public UCWorkPosViewModel WorkPosViewModel { get; }
|
|
|
|
private UCSequenceDiagram _ContentDiagram;
|
|
public UCSequenceDiagram ContentDiagram { get => _ContentDiagram; set => SetProperty(ref _ContentDiagram, value); }
|
|
|
|
public UCCommonAutoRunViewModel(IAuroraEnvironment aurora, string sequenceId, ExternalRecipeUpdate externalRecipeUpdate)
|
|
{
|
|
_Aurora = aurora;
|
|
|
|
WorkPosViewModel = new UCWorkPosViewModel(aurora, sequenceId);
|
|
|
|
ContentDiagram = new UCSequenceDiagram();
|
|
ContentDiagram.SequenceID = sequenceId;
|
|
//ContentDiagram.DiagramType = eDiagramType.Layered;
|
|
ContentDiagram.DiagramType = eDiagramType.Tree;
|
|
ContentDiagram.LineType = eLineType.Straight;
|
|
ContentDiagram.ShowSubSequence = false;
|
|
ContentDiagram.SetVisibleKeys(new List<string>());
|
|
|
|
RecipeUpdate = externalRecipeUpdate;
|
|
|
|
_Aurora.EventObservable.AsObservable(CommonEventIds.EVENT_AUTO_RUN_START_REQUEST)
|
|
.ObserveOnDispatcher()
|
|
.Subscribe(x => OnAutoRunStartRequest());
|
|
|
|
_Aurora.EventObservable.AsObservable(CommonEventIds.EVENT_AUTO_RUN_STOP_REQUEST)
|
|
.ObserveOnDispatcher()
|
|
.Subscribe(x => OnAutoRunStopRequest());
|
|
|
|
//_Aurora.EventObservable.AsObservable(CommonEventIds.EVENT_AUTO_RUN_START_REQUEST)
|
|
// .ObserveOn(Application.Current.Dispatcher)
|
|
// .Subscribe(OnAutoRunStartRequest);
|
|
//_EventObservable.AsObservable(CommonEventIds.EVENT_AUTO_RUN_STOP_REQUEST)
|
|
// .ObserveOn(Application.Current.Dispatcher)
|
|
// .Subscribe(OnAutoRunStopRequest);
|
|
|
|
}
|
|
|
|
private void OnAutoRunStartRequest()
|
|
{
|
|
//현재 Activated된 Recipe를 화면에 표시한다.
|
|
WeldingRecipeManager.OnSaveRecipeForEditing();
|
|
//WeldingRecipeManager.OnActiveReloaded(); // [26.01.15] ubs.cmy - Recipe 덮어 씌우는 현상 방지
|
|
|
|
// TODO : RMS는 우선 주석 처리 해두고, 파라미터 정해지면 다시 구현한다
|
|
if (RecipeUpdate != null)
|
|
{
|
|
RecipeUpdate(Log, _Aurora);
|
|
}
|
|
else
|
|
{
|
|
//Log.W("Check Machine Type");
|
|
Log.W("Check OnAutoRunStartRequest and need function!!");
|
|
}
|
|
|
|
// RunState 가 idle 일 경우만 실행됨
|
|
_Aurora.EventPublisher.Publish(new EventMessage("CommonAutoRunViewModel", CommonEventIds.EVENT_SEQ_AUTO_RUN_START));
|
|
|
|
}
|
|
|
|
private void OnAutoRunStopRequest()
|
|
{
|
|
// RunState 가 start 일 경우만 멈춤을 실행
|
|
_Aurora.EventPublisher.Publish(new EventMessage("CommonAutoRunViewModel", CommonEventIds.EVENT_SEQ_AUTO_RUN_STOP));
|
|
}
|
|
|
|
}
|
|
}
|