123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814 |
- using Aitex.Core.Common;
- using Aitex.Sorter.Common;
- using System;
- using System.Globalization;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- using MECF.Framework.Common.Equipment;
- namespace Aitex.Sorter.UI.Controls
- {
- /// <summary>
- /// AtmRobot.xaml 的交互逻辑
- /// </summary>
- public partial class AtmRobot4LP : UserControl
- {
- private const int ms = 300;
- public int RotateAngle
- {
- get { return (int)GetValue(RotateAngleProperty); }
- set { SetValue(RotateAngleProperty, value); }
- }
- // Using a DependencyProperty as the backing store for RotateAngel. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty RotateAngleProperty =
- DependencyProperty.Register("RotateAngel", typeof(int), typeof(AtmRobot4LP), new PropertyMetadata(0));
- public int RobotWidth
- {
- get { return (int)GetValue(RobotWidthProperty); }
- set { SetValue(RobotWidthProperty, value); }
- }
- // Using a DependencyProperty as the backing store for RobotWidth. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty RobotWidthProperty =
- DependencyProperty.Register("RobotWidth", typeof(int), typeof(AtmRobot4LP), new PropertyMetadata(0));
- public int RobotHeight
- {
- get { return (int)GetValue(RobotHeightProperty); }
- set { SetValue(RobotHeightProperty, value); }
- }
- // Using a DependencyProperty as the backing store for RobotHeight. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty RobotHeightProperty =
- DependencyProperty.Register("RobotHeight", typeof(int), typeof(AtmRobot4LP), new PropertyMetadata(60));
- public int DockerWidth
- {
- get { return (int)GetValue(DockerWidthProperty); }
- set { SetValue(DockerWidthProperty, value); }
- }
- // Using a DependencyProperty as the backing store for DockerWidth. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty DockerWidthProperty =
- DependencyProperty.Register("DockerWidth", typeof(int), typeof(AtmRobot4LP), new PropertyMetadata(0));
- public WaferInfo Wafer1
- {
- get { return (WaferInfo)GetValue(Wafer1Property); }
- set { SetValue(Wafer1Property, value); }
- }
- // Using a DependencyProperty as the backing store for WaferItem. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty Wafer1Property =
- DependencyProperty.Register("Wafer1", typeof(WaferInfo), typeof(AtmRobot4LP), new PropertyMetadata(null));
- public WaferInfo Wafer2
- {
- get { return (WaferInfo)GetValue(Wafer2Property); }
- set { SetValue(Wafer2Property, value); }
- }
- // Using a DependencyProperty as the backing store for WaferItem. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty Wafer2Property =
- DependencyProperty.Register("Wafer2", typeof(WaferInfo), typeof(AtmRobot4LP), new PropertyMetadata(null));
- public ModuleName Station
- {
- get { return (ModuleName)GetValue(StationProperty); }
- set { SetValue(StationProperty, value); }
- }
- // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty StationProperty =
- DependencyProperty.Register("Station", typeof(ModuleName), typeof(AtmRobot4LP), new PropertyMetadata(ModuleName.Robot));
- public ICommand Command
- {
- get { return (ICommand)GetValue(CommandProperty); }
- set { SetValue(CommandProperty, value); }
- }
- // Using a DependencyProperty as the backing store for Command. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty CommandProperty =
- DependencyProperty.Register("Command", typeof(ICommand), typeof(AtmRobot4LP), new PropertyMetadata(null));
- public ModuleName RobotBladeTarget
- {
- get { return (ModuleName)GetValue(RobotBladeTargetProperty); }
- set { SetValue(RobotBladeTargetProperty, value); }
- }
- public static readonly DependencyProperty RobotBladeTargetProperty =
- DependencyProperty.Register("RobotBladeTarget", typeof(ModuleName), typeof(AtmRobot4LP), new FrameworkPropertyMetadata(ModuleName.System, FrameworkPropertyMetadataOptions.AffectsRender));
- public AtmRobot4LP()
- {
- InitializeComponent();
- root.DataContext = this;
- canvas1.Rotate(90);
- canvas2.Rotate(180);
- canvas3.Rotate(180);
- canvas23.Rotate(180);
- Blade1Status = BladeStatus4LP.Retract;
- Blade2Status = BladeStatus4LP.Retract;
- }
- protected override void OnRender(DrawingContext drawingContext)
- {
- base.OnRender(drawingContext);
- //var text = new FormattedText(RobotBladeTarget.ToString(), CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.Black);
- //drawingContext.DrawText(text, new Point(10, 0));
- if (Blade1Status == BladeStatus4LP.Extend && (RobotBladeTarget == ModuleName.System || RobotBladeTarget == ModuleName.Robot))
- {
- RetractBlade1();
- RetractBlade2();
- }
- if (Blade1Status == BladeStatus4LP.Retract && RobotBladeTarget != ModuleName.System && RobotBladeTarget != ModuleName.Robot)
- {
- ExtendBlade1();
- ExtendBlade2();
- }
- if (Blade1Status == BladeStatus4LP.Retract && Blade2Status == BladeStatus4LP.Retract)
- {
- MoveToHome();
- return;
- }
- if (Blade1Status == BladeStatus4LP.Extend || Blade2Status == BladeStatus4LP.Extend)
- {
- MoveRobot(RobotBladeTarget);
- }
- }
- private bool MoveRobot(ModuleName chamberSet)
- {
- switch (chamberSet)
- {
- case ModuleName.System:
- break;
- case ModuleName.LP1:
- return MoveToLP1();
- case ModuleName.LP2:
- return MoveToLP2();
- case ModuleName.LP3:
- return MoveToLP3();
- case ModuleName.LP4:
- return MoveToLP4();
- case ModuleName.Robot:
- return MoveToHome();
- case ModuleName.Aligner:
- return MoveToAligner();
- case ModuleName.Upender:
- return MoveToInvertion();
- default:
- break;
- }
- return false;
- }
- public RobotPostion4LP CurrentPosition
- {
- get; set;
- }
- public BladeStatus4LP Blade1Status
- {
- get; set;
- }
- public BladeStatus4LP Blade2Status
- {
- get; set;
- }
- private void MenuItem_Click(object sender, RoutedEventArgs e)
- {
- var cmd = ((MenuItem)sender).Tag;
- Command.Execute(new[] { Station.ToString(), cmd });
- }
- private bool MoveToLP1()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- HomeToLP1();
- return true;
- case RobotPostion4LP.LP1:
- break;
- case RobotPostion4LP.LP2:
- LP2ToLP1();
- return true;
- case RobotPostion4LP.LP3:
- LP3ToLP1();
- return true;
- case RobotPostion4LP.LP4:
- LP4ToLP1();
- return true;
- case RobotPostion4LP.Invertion:
- InvertionToLP1();
- return true;
- case RobotPostion4LP.Aligner:
- AlignerToLP1();
- return true;
- default:
- break;
- }
- return false;
- }
- private bool MoveToLP2()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- HomeToLP2();
- return true;
- case RobotPostion4LP.LP1:
- LP1ToLP2();
- return true;
- case RobotPostion4LP.LP2:
- break;
- case RobotPostion4LP.LP3:
- LP3ToLP2();
- return true;
- case RobotPostion4LP.LP4:
- LP4ToLP2();
- return true;
- case RobotPostion4LP.Invertion:
- InvertionToLP2();
- return true;
- case RobotPostion4LP.Aligner:
- AlignerToLP2();
- return true;
- default:
- break;
- }
- return false;
- }
- private bool MoveToLP3()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- HomeToLP3();
- return true;
- case RobotPostion4LP.LP1:
- LP1ToLP3();
- return true;
- case RobotPostion4LP.LP2:
- LP2ToLP3();
- return true;
- case RobotPostion4LP.LP3:
- break;
- case RobotPostion4LP.LP4:
- LP4ToLP3();
- return true;
- case RobotPostion4LP.Invertion:
- InvertionToLP3();
- return true;
- case RobotPostion4LP.Aligner:
- AlignerToLP3();
- return true;
- default:
- break;
- }
- return false;
- }
- private bool MoveToLP4()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- HomeToLP4();
- return true;
- case RobotPostion4LP.LP1:
- LP1ToLP4();
- return true;
- case RobotPostion4LP.LP2:
- LP2ToLP4();
- return true;
- case RobotPostion4LP.LP3:
- LP3ToLP4();
- return true;
- case RobotPostion4LP.LP4:
- break;
- case RobotPostion4LP.Invertion:
- InvertionToLP4();
- return true;
- case RobotPostion4LP.Aligner:
- AlignerToLP4();
- return true;
- default:
- break;
- }
- return false;
- }
- private bool MoveToInvertion()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- HomeToInvertion();
- return true;
- case RobotPostion4LP.LP1:
- LP1ToInvertion();
- break;
- case RobotPostion4LP.LP2:
- LP2ToInvertion();
- return true;
- case RobotPostion4LP.LP3:
- LP3ToInvertion();
- return true;
- case RobotPostion4LP.LP4:
- LP4ToInvertion();
- return true;
- case RobotPostion4LP.Aligner:
- AlignerToInvertion();
- return true;
- case RobotPostion4LP.Invertion:
- break;
- default:
- break;
- }
- return false;
- }
- private bool MoveToAligner()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- HomeToAligner();
- return true;
- case RobotPostion4LP.LP1:
- LP1ToAligner();
- return true;
- case RobotPostion4LP.LP2:
- LP2ToAligner();
- return true;
- case RobotPostion4LP.LP3:
- LP3ToAligner();
- return true;
- case RobotPostion4LP.LP4:
- LP4ToAligner();
- return true;
- case RobotPostion4LP.Invertion:
- InvertionToAligner();
- return true;
- case RobotPostion4LP.Aligner:
- break;
- default:
- break;
- }
- return false;
- }
- private bool MoveToHome()
- {
- switch (CurrentPosition)
- {
- case RobotPostion4LP.Home:
- break;
- case RobotPostion4LP.LP1:
- LP1ToHome();
- return true;
- case RobotPostion4LP.LP2:
- LP2ToHome();
- return true;
- case RobotPostion4LP.Aligner:
- AlignerToHome();
- return true;
- default:
- break;
- }
- return false;
- }
- private void ExtendBlade1()
- {
- canvas3.Rotate(0, true, ms);
- Blade1Status = BladeStatus4LP.Extend;
- }
- private void RetractBlade1()
- {
- canvas3.Rotate(180, true, ms);
- Blade1Status = BladeStatus4LP.Retract;
- }
- private void ExtendBlade2()
- {
- canvas23.Rotate(0, true, ms);
- Blade2Status = BladeStatus4LP.Extend;
- }
- private void RetractBlade2()
- {
- canvas23.Rotate(180, true, ms);
- Blade2Status = BladeStatus4LP.Retract;
- }
- private void RetractBlade()
- {
- canvas3.Rotate(180, true);
- canvas23.Rotate(180, true);
- }
- private void ExtendBlade(int angle)
- {
- canvas3.Rotate(angle, true);
- canvas23.Rotate(angle, true);
- }
- private void HomeToLP1()
- {
- ToLP1Start(ToLP1End);
- }
- private void LP1ToAligner()
- {
- ToLP1Start(() => ToAlignerStart(ToAlignerEnd));
- }
- private void LP3ToAligner()
- {
- ToLP3Start(() => ToAlignerStart(ToAlignerEnd));
- }
- private void LP4ToAligner()
- {
- ToLP4Start(() => ToAlignerStart(ToAlignerEnd));
- }
- private void InvertionToAligner()
- {
- ToAlignerStart(ToAlignerEnd);
- }
- private void LP1ToLP2()
- {
- ToLP1Start(() => ToLP2Start(ToLP2End));
- }
- private void LP3ToLP2()
- {
- ToLP3Start(() => ToLP2Start(ToLP2End));
- }
- private void LP4ToLP2()
- {
- ToLP4Start(() => ToLP2Start(ToLP2End));
- }
- private void HomeToLP2()
- {
- ToLP2Start(ToLP2End);
- }
- private void HomeToLP3()
- {
- ToLP3Start(ToLP3End);
- }
- private void LP1ToLP3()
- {
- ToLP1Start(() => ToLP3Start(ToLP3End));
- }
- private void LP2ToLP3()
- {
- ToLP2Start(() => ToLP3Start(ToLP3End));
- }
- private void LP4ToLP3()
- {
- ToLP4Start(() => ToLP3Start(ToLP3End));
- }
- private void HomeToLP4()
- {
- ToLP4Start(ToLP4End);
- }
- private void LP1ToLP4()
- {
- ToLP1Start(() => ToLP4Start(ToLP4End));
- }
- private void LP2ToLP4()
- {
- ToLP2Start(() => ToLP4Start(ToLP4End));
- }
- private void LP3ToLP4()
- {
- ToLP3Start(() => ToLP4Start(ToLP4End));
- }
- private void InvertionToLP1()
- {
- ToLP1Start(ToLP1End);
- }
- private void InvertionToLP2()
- {
- ToLP2Start(ToLP2End);
- }
- private void InvertionToLP3()
- {
- ToLP3Start(ToLP3End);
- }
- private void InvertionToLP4()
- {
- ToLP4Start(ToLP4End);
- }
- private void LP2ToLP1()
- {
- ToLP2Start(() => ToLP1Start(ToLP1End));
- }
- private void LP3ToLP1()
- {
- ToLP3Start(() => ToLP1Start(ToLP1End));
- }
- private void LP4ToLP1()
- {
- ToLP4Start(() => ToLP1Start(ToLP1End));
- }
- private void LP2ToAligner()
- {
- ToLP2Start(() =>
- {
- RetractBlade();
- ToAlignerStart(() =>
- {
- ExtendBlade(0);
- ToAlignerEnd();
- });
- });
- }
- private void HomeToAligner()
- {
- ToAlignerStart(ToAlignerEnd);
- }
- private void AlignerToLP1()
- {
- ToAlignerStart(() => ToLP1Start(ToLP1End));
- }
- private void AlignerToLP2()
- {
- ToAlignerStart(
- () =>
- {
- RetractBlade();
- ToLP2Start(() =>
- {
- ExtendBlade(90);
- ToLP2End();
- });
- }
- );
- }
- private void AlignerToLP3()
- {
- ToAlignerStart(() => ToLP3Start(ToLP3End));
- }
- private void AlignerToLP4()
- {
- ToAlignerStart(() => ToLP4Start(ToLP4End));
- }
- private void LP1ToHome()
- {
- ToLP1Start(ToHome);
- }
- private void LP2ToHome()
- {
- ToLP2Start(ToHome);
- }
- private void AlignerToHome()
- {
- ToAlignerStart(ToHome);
- }
- private void HomeToInvertion()
- {
- ToInvertionEnd();
- }
- private void LP1ToInvertion()
- {
- ToLP1Start(ToInvertionEnd);
- }
- private void LP2ToInvertion()
- {
- ToLP2Start(ToInvertionEnd);
- }
- private void LP3ToInvertion()
- {
- ToLP3Start(ToInvertionEnd);
- }
- private void LP4ToInvertion()
- {
- ToLP4Start(ToInvertionEnd);
- }
- private void AlignerToInvertion()
- {
- ToAlignerStart(ToInvertionEnd);
- }
- private void ToLP1Start(Action action = null)
- {
- canvas1.Rotate(80, true, ms, 0, 0, () => { if (action != null) action(); });
- canvas2.Rotate(280, true, ms, 0.5);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(270, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(270, true, ms);
- CurrentPosition = RobotPostion4LP.LP1;
- }
- private void ToLP2Start(Action action = null)
- {
- canvas1.Rotate(120, true, ms, 0, 0, () => { if (action != null) action(); });
- canvas2.Rotate(260, true, ms, 0.5);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(250, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(250, true, ms);
- CurrentPosition = RobotPostion4LP.LP2;
- }
- private void ToLP3Start(Action action = null)
- {
- canvas1.Rotate(50, true, ms, 0, 0, () => { if (action != null) action(); });
- canvas2.Rotate(130, true, ms, 0.5);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(90, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(90, true, ms);
- CurrentPosition = RobotPostion4LP.LP3;
- }
- private void ToLP4Start(Action action = null)
- {
- canvas1.Rotate(120, true, ms, 0, 0, () => { if (action != null) action(); });
- canvas2.Rotate(60, true, ms, 0.5);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(90, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(90, true, ms);
- CurrentPosition = RobotPostion4LP.LP4;
- }
- private void ToAlignerStart(Action action = null)
- {
- canvas1.Rotate(45, true, ms, 0, 0, () => { if (action != null) action(); });
- canvas2.Rotate(135, true, ms, 0);
- if (Blade1Status == BladeStatus4LP.Extend)
- canvas3.Rotate(0, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend)
- canvas23.Rotate(0, true, ms);
- CurrentPosition = RobotPostion4LP.Aligner;
- }
- private void ToLP1End()
- {
- canvas1.Rotate(40, true, ms, 0);
- canvas2.Rotate(290, true, ms, 0);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(300, true, ms, 0);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(300, true, ms, 0);
- CurrentPosition = RobotPostion4LP.LP1;
- }
- private void ToLP2End()
- {
- canvas1.Rotate(70, true, ms, 0);
- canvas2.Rotate(210, true, ms, 0);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(350, true, ms, 0);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(350, true, ms, 0);
- CurrentPosition = RobotPostion4LP.LP2;
- }
- private void ToLP3End()
- {
- canvas1.Rotate(100, true, ms, 0);
- canvas2.Rotate(150, true, ms, 0);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(20, true, ms, 0);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(20, true, ms, 0);
- CurrentPosition = RobotPostion4LP.LP3;
- }
- private void ToLP4End()
- {
- canvas1.Rotate(145, true, ms, 0);
- canvas2.Rotate(75, true, ms, 0);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(50, true, ms, 0);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(50, true, ms, 0);
- CurrentPosition = RobotPostion4LP.LP4;
- }
- private void ToAlignerEnd()
- {
- canvas1.Rotate(150, true, ms, 0);
- canvas2.Rotate(30, true, ms, 0);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(0, true, ms, 0);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(0, true, ms, 0);
- CurrentPosition = RobotPostion4LP.Aligner;
- }
- private void ToHome()
- {
- canvas1.Rotate(90, true, ms);
- canvas2.Rotate(180, true, ms);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(180, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(180, true, ms);
- CurrentPosition = RobotPostion4LP.Home;
- }
- private void ToInvertionEnd()
- {
- canvas1.Rotate(30, true, ms);
- canvas2.Rotate(120, true, ms);
- if (Blade1Status == BladeStatus4LP.Extend) canvas3.Rotate(300, true, ms);
- if (Blade2Status == BladeStatus4LP.Extend) canvas23.Rotate(300, true, ms);
- CurrentPosition = RobotPostion4LP.Invertion;
- }
- private void mnuToLP1_Click(object sender, RoutedEventArgs e)
- {
- MoveToLP1();
- }
- private void mnuToLP2_Click(object sender, RoutedEventArgs e)
- {
- MoveToLP2();
- }
- private void mnuToHome_Click(object sender, RoutedEventArgs e)
- {
- MoveToHome();
- }
- private void mnuToAligner_Click(object sender, RoutedEventArgs e)
- {
- MoveToAligner();
- }
- private void mnuToInvertion_Click(object sender, RoutedEventArgs e)
- {
- MoveToInvertion();
- }
- private void mnuToLP3_Click(object sender, RoutedEventArgs e)
- {
- MoveToLP3();
- }
- private void mnuToLP4_Click(object sender, RoutedEventArgs e)
- {
- MoveToLP4();
- }
- }
- public enum RobotPostion4LP
- {
- Home,
- LP1,
- LP2,
- LP3,
- LP4,
- Aligner,
- Invertion
- }
- public enum BladeStatus4LP
- {
- Extend,
- Retract
- }
- }
|