| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using System.Threading;
- using GSG.NET.Concurrent;
- using GSG.NET.Logging;
- using GSG.NET.Utils;
- using VehicleControlSystem.ControlLayer.IO;
- namespace VehicleControlSystem.ControlLayer
- {
- public class Conveyor
- {
- Logger logger = Logger.GetLogger();
- EzIO ezIO = null;
- public Conveyor(EzIO io)
- {
- this.ezIO = io;
- }
- public int OnOffConveyor( bool isOn, bool isLoad = false )
- {
- this.SetConveyorSpeed( isLoad ); //Load 시 속도를 조금 더 빠르게 하기 위해.
- if ( isLoad )
- this.ezIO.OutputOn( "OUT_CV_CWCCW" );
- else
- this.ezIO.OutputOff( "OUT_CV_CWCCW" );
- if ( isOn )
- this.ezIO.OutputOn( "OUT_CV_RUN" );
- else
- this.ezIO.OutputOff( "OUT_CV_RUN" );
- LockUtils.Wait(500);
- if (this.IsInverterError())
- {
- this.ezIO.OutputOff("OUT_CV_RUN");
- return 16;
- }
-
- return 0;
- }
- public void SetConveyorSpeed( bool IsLoad )
- {
- if ( IsLoad )
- this.ezIO.WriteOutputIO( "OUT_CV_DA", true );
- else
- this.ezIO.WriteOutputIO( "OUT_CV_DA", false );
- }
- public bool IsCvRun() => this.ezIO.IsOn( "OUT_CV_RUN" );
- public bool IsCvCWCCW() => this.ezIO.IsOn( "OUT_CV_CWCCW" );
- /// <summary>
- /// 입구 감지 로딩시 감속 사용
- /// </summary>
- /// <returns></returns>
- public bool IsDetectedLoadStart() => this.ezIO.IsOn( "IN_CV_DETECT_00" );
- /// <summary>
- /// 실물 감지
- /// </summary>
- /// <returns></returns>
- public bool IsDetectedCenter() => this.ezIO.IsOn( "IN_CV_DETECT_01" );
- public bool IsDetectedLoadStop() => this.ezIO.IsOn( "IN_CV_DETECT_02" );
- public bool IsInverterError() => !this.ezIO.IsOn( "IN_CV_ERROR" ); //Normal Close 로 생각 됨.
- public bool IsLifterPositinCheck() => this.ezIO.IsOn( "IN_LIFTER_POSITION_DETECT" );
- public bool IsLifterDuplication() => this.ezIO.IsOn( "IN_LIFTER_DUPLICATION_DETECT" );
- public bool IsPIOInterLockOn() => this.ezIO.IsOn( "IN_PIO_INTERLOCK" );
- public int ConveyorLoad()
- {
- if ( IsDetectedCenter() )
- return 9;
- logger.D( "[Manual Load] - Conveyor On" );
- OnOffConveyor( true, true );
- bool isStartDetected = false;
- long sTime = SwUtils.CurrentTimeMillis;
- while ( true )
- {
- if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
- {
- OnOffConveyor( false, true );
- return 10;
- }
- if ( this.IsDetectedLoadStart() && !isStartDetected )
- isStartDetected = true;
- if ( !this.IsDetectedLoadStart() && isStartDetected )
- {
- //this.SetConveyorSpeed( false );
- logger.D( "[Manual Load] - Conveyor Slow State" );
- }
- if ( IsDetectedLoadStop() )
- break;
- }
- OnOffConveyor( false );
- logger.D( "[Manual Load] - Conveyor Off" );
- return 0;
- }
- public int ConveyorUnload()
- {
- if ( !IsDetectedCenter() )
- return 11;
- logger.D( "[Manual Unload] - Conveyor On" );
- OnOffConveyor( true, false );
- long sTime = SwUtils.CurrentTimeMillis;
- while ( true )
- {
- if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) ) //Wait 20Sec
- {
- OnOffConveyor( false, false );
- return 12;
- }
- if ( !IsDetectedLoadStart() && !IsDetectedCenter() )
- break;
- }
- Thread.Sleep( 2000 );
- OnOffConveyor( false );
- logger.D( "[Manual Unload] - Conveyor Off" );
- return 0;
- }
- }
- }
|