|
|
@@ -84,56 +84,56 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
get => this.isConnectError;
|
|
|
set
|
|
|
{
|
|
|
- if (this.isConnectError == value)
|
|
|
+ if ( this.isConnectError == value )
|
|
|
return;
|
|
|
this.isConnectError = value;
|
|
|
|
|
|
- if (isConnectError)
|
|
|
- this.qQ.Enqueue(new QoDiconnected());
|
|
|
+ if ( isConnectError )
|
|
|
+ this.qQ.Enqueue( new QoDiconnected() );
|
|
|
else
|
|
|
- this.qQ.Enqueue(new QoConnected());
|
|
|
+ this.qQ.Enqueue( new QoConnected() );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- TsMap<string, SyncObject> ddWaitChgBlock = new TsMap<string, SyncObject>();
|
|
|
+ TsMap<string, SyncObject> ddWaitChgBlock = new TsMap<string, SyncObject>();
|
|
|
|
|
|
#region Pull Thread
|
|
|
- public TsQueue<QueueObject> qQ = new TsQueue<QueueObject>(512);
|
|
|
+ public TsQueue<QueueObject> qQ = new TsQueue<QueueObject>( 512 );
|
|
|
public Thread pullThread;
|
|
|
#endregion
|
|
|
|
|
|
#region public Method
|
|
|
- public int GetBit(uint usIOAddr, bool pbval)
|
|
|
+ public int GetBit( uint usIOAddr, bool pbval )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int GetBit(string strIOAddr, bool pbVal)
|
|
|
+ public int GetBit( string strIOAddr, bool pbVal )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int GetByte(uint usIOAddr, byte pcValue)
|
|
|
+ public int GetByte( uint usIOAddr, byte pcValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int GetByte(string strIOAddr, byte pcValue)
|
|
|
+ public int GetByte( string strIOAddr, byte pcValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int GetWord(uint usIOAddr, short pwValue)
|
|
|
+ public int GetWord( uint usIOAddr, short pwValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int GetWord(string strIOAddr, short pwValue)
|
|
|
+ public int GetWord( string strIOAddr, short pwValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int Initialize(List<EzBoard> ezBoards)
|
|
|
+ public int Initialize( List<EzBoard> ezBoards )
|
|
|
{
|
|
|
this.BoardList = ezBoards;
|
|
|
|
|
|
@@ -141,7 +141,7 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
this._outcomingBuffer = new ushort[ezBoards.Count];
|
|
|
|
|
|
this.IsThreadAlive = true;
|
|
|
- _readThread = new Thread(this.IOThread);
|
|
|
+ _readThread = new Thread( this.IOThread );
|
|
|
this._readThread.IsBackground = true;
|
|
|
this._readThread.Start();
|
|
|
|
|
|
@@ -155,23 +155,23 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public bool IsOff(uint usIOAddr)
|
|
|
+ public bool IsOff( uint usIOAddr )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public bool IsOff(string ioTag, bool isInput = true)
|
|
|
+ public bool IsOff( string ioTag, bool isInput = true )
|
|
|
{
|
|
|
BitBlock bit = null;
|
|
|
- if (isInput)
|
|
|
- bit = this._inPutIOList.Where(x => ioTag.Equals(x.Tag)).FirstOrDefault();
|
|
|
+ if ( isInput )
|
|
|
+ bit = this._inPutIOList.Where( x => ioTag.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
else
|
|
|
- bit = this._outPutIOList.Where(x => ioTag.Equals(x.Tag)).FirstOrDefault();
|
|
|
+ bit = this._outPutIOList.Where( x => ioTag.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
|
|
|
return !bit.IsBitOn;
|
|
|
}
|
|
|
|
|
|
- public bool IsOn(uint usIOAddr)
|
|
|
+ public bool IsOn( uint usIOAddr )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
@@ -187,80 +187,80 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
// return 0;
|
|
|
//}
|
|
|
|
|
|
- public bool IsOn(string ioTag, bool isInput = true)
|
|
|
+ public bool IsOn( string ioTag, bool isInput = true )
|
|
|
{
|
|
|
BitBlock bit = null;
|
|
|
- if (isInput)
|
|
|
- bit = this._inPutIOList.Where(x => ioTag.Equals(x.Tag)).FirstOrDefault();
|
|
|
+ if ( isInput )
|
|
|
+ bit = this._inPutIOList.Where( x => ioTag.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
else
|
|
|
- bit = this._outPutIOList.Where(x => ioTag.Equals(x.Tag)).FirstOrDefault();
|
|
|
+ bit = this._outPutIOList.Where( x => ioTag.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
|
|
|
return bit.IsBitOn;
|
|
|
}
|
|
|
|
|
|
- public bool WaitChangeInputIO(bool exp, int timeout, string tag)
|
|
|
+ public bool WaitChangeInputIO( bool exp, int timeout, string tag )
|
|
|
{
|
|
|
- if (exp == IsOn(tag))
|
|
|
+ if ( exp == IsOn( tag ) )
|
|
|
return true;
|
|
|
|
|
|
- Assert.IsFalse(ddWaitChgBlock.ContainsKey(tag), "WaitChg InputIO already waiting:{0}", tag);
|
|
|
+ Assert.IsFalse( ddWaitChgBlock.ContainsKey( tag ), "WaitChg InputIO already waiting:{0}", tag );
|
|
|
try
|
|
|
{
|
|
|
var so = new SyncObject { };
|
|
|
- ddWaitChgBlock.Add(tag, so);
|
|
|
+ ddWaitChgBlock.Add( tag, so );
|
|
|
so.Lock();
|
|
|
- return so.Await(timeout);
|
|
|
+ return so.Await( timeout );
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
- this.ddWaitChgBlock.Remove(tag);
|
|
|
+ this.ddWaitChgBlock.Remove( tag );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public int LoadIOMap(string strFileName)
|
|
|
+ public int LoadIOMap( string strFileName )
|
|
|
{
|
|
|
- var bl = new ExcelMapper(strFileName).Fetch<EzBoard>("BOARD").ToList();
|
|
|
+ var bl = new ExcelMapper( strFileName ).Fetch<EzBoard>( "BOARD" ).ToList();
|
|
|
this.BoardList = bl;
|
|
|
|
|
|
- var il = new ExcelMapper(strFileName).Fetch<BitBlock>("IN_IO").ToList();
|
|
|
- var inputIO = il.Where(x => !string.IsNullOrEmpty(x.Tag)).ToList();
|
|
|
+ var il = new ExcelMapper( strFileName ).Fetch<BitBlock>( "IN_IO" ).ToList();
|
|
|
+ var inputIO = il.Where( x => !string.IsNullOrEmpty( x.Tag ) ).ToList();
|
|
|
this._inPutIOList = inputIO;
|
|
|
|
|
|
- var ol = new ExcelMapper(strFileName).Fetch<BitBlock>("OUT_IO").ToList();
|
|
|
- var outputIO = ol.Where(x => !string.IsNullOrEmpty(x.Tag)).ToList();
|
|
|
+ var ol = new ExcelMapper( strFileName ).Fetch<BitBlock>( "OUT_IO" ).ToList();
|
|
|
+ var outputIO = ol.Where( x => !string.IsNullOrEmpty( x.Tag ) ).ToList();
|
|
|
this._outPutIOList = outputIO;
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- public int OutputOff(uint usIOAddr)
|
|
|
+ public int OutputOff( uint usIOAddr )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int OutputOff(string strIOAddr)
|
|
|
+ public int OutputOff( string strIOAddr )
|
|
|
{
|
|
|
int result = 0;
|
|
|
|
|
|
- var outIO = this._outPutIOList.Where(x => strIOAddr.Equals(x.Tag)).FirstOrDefault();
|
|
|
- var boardType = this.BoardList.Where(x => x.BoardID == outIO.BoardNo).FirstOrDefault().Type;
|
|
|
+ var outIO = this._outPutIOList.Where( x => strIOAddr.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
+ var boardType = this.BoardList.Where( x => x.BoardID == outIO.BoardNo ).FirstOrDefault().Type;
|
|
|
|
|
|
uint bitMask = 0;
|
|
|
- if (boardType == E_EzboardType.Servo)
|
|
|
+ if ( boardType == E_EzboardType.Servo )
|
|
|
{
|
|
|
bitMask = this.servoAmpOutputBitMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetIOOutput(outIO.BoardNo, 0, bitMask);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetIOOutput( outIO.BoardNo, 0, bitMask );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bitMask = bitOnMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetOutput(outIO.BoardNo, 0, bitMask);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetOutput( outIO.BoardNo, 0, bitMask );
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public int OutputOn(uint usIOAddr)
|
|
|
+ public int OutputOn( uint usIOAddr )
|
|
|
{
|
|
|
//var outIO = this._inPutIOList.Where( x => strIOAddr.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
|
|
|
@@ -269,113 +269,113 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- public int OutputOn(string outputTag)
|
|
|
+ public int OutputOn( string outputTag )
|
|
|
{
|
|
|
int result = 0;
|
|
|
|
|
|
- var outIO = this._outPutIOList.Where(x => outputTag.Equals(x.Tag)).FirstOrDefault();
|
|
|
- var boardType = this.BoardList.Where(x => x.BoardID == outIO.BoardNo).FirstOrDefault().Type;
|
|
|
+ var outIO = this._outPutIOList.Where( x => outputTag.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
+ var boardType = this.BoardList.Where( x => x.BoardID == outIO.BoardNo ).FirstOrDefault().Type;
|
|
|
|
|
|
uint bitMask = 0;
|
|
|
- if (boardType == E_EzboardType.Servo)
|
|
|
+ if ( boardType == E_EzboardType.Servo )
|
|
|
{
|
|
|
bitMask = this.servoAmpOutputBitMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetIOOutput(outIO.BoardNo, bitMask, 0);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetIOOutput( outIO.BoardNo, bitMask, 0 );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bitMask = bitOnMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetOutput(outIO.BoardNo, bitMask, 0);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetOutput( outIO.BoardNo, bitMask, 0 );
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
#region 일정시간 이후 동작 구현
|
|
|
- void WriteOutputOn(string outputTag)
|
|
|
+ void WriteOutputOn( string outputTag )
|
|
|
{
|
|
|
int result = 0;
|
|
|
|
|
|
- var outIO = this._outPutIOList.Where(x => outputTag.Equals(x.Tag)).FirstOrDefault();
|
|
|
- var boardType = this.BoardList.Where(x => x.BoardID == outIO.BoardNo).FirstOrDefault().Type;
|
|
|
+ var outIO = this._outPutIOList.Where( x => outputTag.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
+ var boardType = this.BoardList.Where( x => x.BoardID == outIO.BoardNo ).FirstOrDefault().Type;
|
|
|
|
|
|
uint bitMask = 0;
|
|
|
- if (boardType == E_EzboardType.Servo)
|
|
|
+ if ( boardType == E_EzboardType.Servo )
|
|
|
{
|
|
|
bitMask = this.servoAmpOutputBitMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetIOOutput(outIO.BoardNo, bitMask, 0);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetIOOutput( outIO.BoardNo, bitMask, 0 );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bitMask = bitOnMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetOutput(outIO.BoardNo, bitMask, 0);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetOutput( outIO.BoardNo, bitMask, 0 );
|
|
|
}
|
|
|
}
|
|
|
- void WriteOutputOff(string strIOAddr)
|
|
|
+ void WriteOutputOff( string strIOAddr )
|
|
|
{
|
|
|
int result = 0;
|
|
|
|
|
|
- var outIO = this._outPutIOList.Where(x => strIOAddr.Equals(x.Tag)).FirstOrDefault();
|
|
|
- var boardType = this.BoardList.Where(x => x.BoardID == outIO.BoardNo).FirstOrDefault().Type;
|
|
|
+ var outIO = this._outPutIOList.Where( x => strIOAddr.Equals( x.Tag ) ).FirstOrDefault();
|
|
|
+ var boardType = this.BoardList.Where( x => x.BoardID == outIO.BoardNo ).FirstOrDefault().Type;
|
|
|
|
|
|
uint bitMask = 0;
|
|
|
- if (boardType == E_EzboardType.Servo)
|
|
|
+ if ( boardType == E_EzboardType.Servo )
|
|
|
{
|
|
|
bitMask = this.servoAmpOutputBitMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetIOOutput(outIO.BoardNo, 0, bitMask);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetIOOutput( outIO.BoardNo, 0, bitMask );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bitMask = bitOnMask[outIO.Index];
|
|
|
- result = EziMOTIONPlusELib.FAS_SetOutput(outIO.BoardNo, 0, bitMask);
|
|
|
+ result = EziMOTIONPlusELib.FAS_SetOutput( outIO.BoardNo, 0, bitMask );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void WriteOutputIO(string tag, bool on, int after = 0)
|
|
|
+ public void WriteOutputIO( string tag, bool on, int after = 0 )
|
|
|
{
|
|
|
- if ( on)
|
|
|
+ if ( on )
|
|
|
{
|
|
|
- if (after > 0)
|
|
|
- TimerUtils.Once(after, WriteOutputOn, tag);
|
|
|
+ if ( after > 0 )
|
|
|
+ TimerUtils.Once( after, WriteOutputOn, tag );
|
|
|
else
|
|
|
- WriteOutputOn(tag);
|
|
|
+ WriteOutputOn( tag );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (after > 0)
|
|
|
- TimerUtils.Once(after, WriteOutputOff, tag);
|
|
|
+ if ( after > 0 )
|
|
|
+ TimerUtils.Once( after, WriteOutputOff, tag );
|
|
|
else
|
|
|
- WriteOutputOff(tag);
|
|
|
+ WriteOutputOff( tag );
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
- public int OutputToggle(uint usIOAddr)
|
|
|
+ public int OutputToggle( uint usIOAddr )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int OutputToggle(string strIOAddr)
|
|
|
+ public int OutputToggle( string strIOAddr )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int PutByte(uint usIOAddr, byte pcValue)
|
|
|
+ public int PutByte( uint usIOAddr, byte pcValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int PutByte(string strIOAddr, byte pcValue)
|
|
|
+ public int PutByte( string strIOAddr, byte pcValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int PutWord(uint usIOAddr, short pwValue)
|
|
|
+ public int PutWord( uint usIOAddr, short pwValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- public int PutWord(string strIOAddr, short pwValue)
|
|
|
+ public int PutWord( string strIOAddr, short pwValue )
|
|
|
{
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
@@ -387,7 +387,7 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
{
|
|
|
ThreadStart();
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch ( Exception )
|
|
|
{
|
|
|
}
|
|
|
finally
|
|
|
@@ -397,26 +397,26 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
public void ThreadStart()
|
|
|
{
|
|
|
this.IsThreadAlive = true;
|
|
|
- this._readThread = ThreadUtils.Invoke(IOThread);
|
|
|
+ this._readThread = ThreadUtils.Invoke( IOThread );
|
|
|
|
|
|
- this.pullThread = ThreadUtils.Invoke(PullQueueThread);
|
|
|
+ this.pullThread = ThreadUtils.Invoke( PullQueueThread );
|
|
|
}
|
|
|
void IOThread()
|
|
|
{
|
|
|
var sTime = SwUtils.CurrentTimeMillis;
|
|
|
|
|
|
- while (IsThreadAlive)
|
|
|
+ while ( IsThreadAlive )
|
|
|
{
|
|
|
- Thread.Sleep(5);
|
|
|
+ Thread.Sleep( 5 );
|
|
|
try
|
|
|
{
|
|
|
- if (!IsConnetedAllBoard())
|
|
|
+ if ( !IsConnetedAllBoard() )
|
|
|
{
|
|
|
- if (!ConnectAllBoard())
|
|
|
+ if ( !ConnectAllBoard() )
|
|
|
{
|
|
|
IsConnectError = true;
|
|
|
}
|
|
|
- Thread.Sleep(1000);
|
|
|
+ Thread.Sleep( 1000 );
|
|
|
continue;
|
|
|
}
|
|
|
IsConnectError = false;
|
|
|
@@ -426,22 +426,22 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
//Console.WriteLine( $"Read Time - { SwUtils.Elapsed( sTime ) } mm" );
|
|
|
//sTime = SwUtils.CurrentTimeMillis;
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ catch ( Exception ex )
|
|
|
{
|
|
|
- logger.E($"Exception [EzIO IORead Thread] - {ex.StackTrace}");
|
|
|
+ logger.E( $"Exception [EzIO IORead Thread] - {ex.StackTrace}" );
|
|
|
}
|
|
|
}
|
|
|
- logger.D("[EzIO] - Dispose");
|
|
|
+ logger.D( "[EzIO] - Dispose" );
|
|
|
}
|
|
|
|
|
|
void ReadBoardIO()
|
|
|
{
|
|
|
- foreach (var board in this.BoardList)
|
|
|
+ foreach ( var board in this.BoardList )
|
|
|
{
|
|
|
- if (!IsConnetedBoard(board.BoardID))
|
|
|
+ if ( !IsConnetedBoard( board.BoardID ) )
|
|
|
continue;
|
|
|
|
|
|
- switch (board.Type)
|
|
|
+ switch ( board.Type )
|
|
|
{
|
|
|
case E_EzboardType.Servo:
|
|
|
{
|
|
|
@@ -449,28 +449,28 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
int cmdPos = 0, actPos = 0, posErr = 0, actVel = 0;
|
|
|
ushort posItemNo = 0;
|
|
|
|
|
|
- if (EziMOTIONPlusELib.FAS_GetAllStatus(board.BoardID, ref axisDIn, ref axisDOut, ref axisStatus,
|
|
|
- ref cmdPos, ref actPos, ref posErr, ref actVel, ref posItemNo) == EziMOTIONPlusELib.FMM_OK)
|
|
|
+ if ( EziMOTIONPlusELib.FAS_GetAllStatus( board.BoardID, ref axisDIn, ref axisDOut, ref axisStatus,
|
|
|
+ ref cmdPos, ref actPos, ref posErr, ref actVel, ref posItemNo ) == EziMOTIONPlusELib.FMM_OK )
|
|
|
{
|
|
|
//if ( this._inPutIOList.Where( x => x.BoardNo == board.BoardID ).Count() <= 0 ) break;
|
|
|
|
|
|
var input = this._inPutIOList.Where( x => x.BoardNo == board.BoardID ).ToList();
|
|
|
- input.ForEach(i =>
|
|
|
- {
|
|
|
- var isOn = Convert.ToBoolean(axisDIn & this.servoAmpInputBitOnMask[i.Index]) ? true : false;
|
|
|
- if (i.IsBitOn != isOn)
|
|
|
- i.IsChanged = true;
|
|
|
- i.IsBitOn = isOn;
|
|
|
- });
|
|
|
-
|
|
|
- var output = this._outPutIOList.Where(x => x.BoardNo == board.BoardID).ToList();
|
|
|
- output.ForEach(o =>
|
|
|
- {
|
|
|
- var isOn = Convert.ToBoolean(axisDOut & this.servoAmpOutputBitMask[o.Index]) ? true : false;
|
|
|
- if (o.IsBitOn != isOn)
|
|
|
- o.IsChanged = true;
|
|
|
- o.IsBitOn = isOn;
|
|
|
- });
|
|
|
+ input.ForEach( i =>
|
|
|
+ {
|
|
|
+ var isOn = Convert.ToBoolean( axisDIn & this.servoAmpInputBitOnMask[i.Index] ) ? true : false;
|
|
|
+ if ( i.IsBitOn != isOn )
|
|
|
+ i.IsChanged = true;
|
|
|
+ i.IsBitOn = isOn;
|
|
|
+ } );
|
|
|
+
|
|
|
+ var output = this._outPutIOList.Where( x => x.BoardNo == board.BoardID ).ToList();
|
|
|
+ output.ForEach( o =>
|
|
|
+ {
|
|
|
+ var isOn = Convert.ToBoolean( axisDOut & this.servoAmpOutputBitMask[o.Index] ) ? true : false;
|
|
|
+ if ( o.IsBitOn != isOn )
|
|
|
+ o.IsChanged = true;
|
|
|
+ o.IsBitOn = isOn;
|
|
|
+ } );
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -479,20 +479,20 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
{
|
|
|
uint inValue = 0, latchValue = 0;
|
|
|
int result = EziMOTIONPlusELib.FMM_OK;
|
|
|
- result = EziMOTIONPlusELib.FAS_GetInput(board.BoardID, ref inValue, ref latchValue);
|
|
|
- if (result == EziMOTIONPlusELib.FMM_OK)
|
|
|
+ result = EziMOTIONPlusELib.FAS_GetInput( board.BoardID, ref inValue, ref latchValue );
|
|
|
+ if ( result == EziMOTIONPlusELib.FMM_OK )
|
|
|
{
|
|
|
- var input = this._inPutIOList.Where(x => x.BoardNo == board.BoardID).ToList();
|
|
|
- input.ForEach(i =>
|
|
|
- {
|
|
|
- var isOn = Convert.ToBoolean(inValue & this.bitOnMask[i.Index]) ? true : false;
|
|
|
- if (i.IsBitOn != isOn)
|
|
|
- i.IsChanged = true;
|
|
|
- i.IsBitOn = isOn;
|
|
|
- });
|
|
|
+ var input = this._inPutIOList.Where( x => x.BoardNo == board.BoardID ).ToList();
|
|
|
+ input.ForEach( i =>
|
|
|
+ {
|
|
|
+ var isOn = Convert.ToBoolean( inValue & this.bitOnMask[i.Index] ) ? true : false;
|
|
|
+ if ( i.IsBitOn != isOn )
|
|
|
+ i.IsChanged = true;
|
|
|
+ i.IsBitOn = isOn;
|
|
|
+ } );
|
|
|
}
|
|
|
else
|
|
|
- logger.E($"EzIO - [{board.BoardID}] Read Fail Error Code {result}");
|
|
|
+ logger.E( $"EzIO - [{board.BoardID}] Read Fail Error Code {result}" );
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
@@ -500,20 +500,20 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
{
|
|
|
uint outValue = 0, outStatus = 0;
|
|
|
int result = EziMOTIONPlusELib.FMM_OK;
|
|
|
- result = EziMOTIONPlusELib.FAS_GetOutput(board.BoardID, ref outValue, ref outStatus);
|
|
|
- if (result == EziMOTIONPlusELib.FMM_OK)
|
|
|
+ result = EziMOTIONPlusELib.FAS_GetOutput( board.BoardID, ref outValue, ref outStatus );
|
|
|
+ if ( result == EziMOTIONPlusELib.FMM_OK )
|
|
|
{
|
|
|
- var output = this._outPutIOList.Where(x => x.BoardNo == board.BoardID).ToList();
|
|
|
- output.ForEach(o =>
|
|
|
- {
|
|
|
- var isOn = Convert.ToBoolean(outValue & this.bitOnMask[o.Index]) ? true : false;
|
|
|
- if (o.IsBitOn != isOn)
|
|
|
- o.IsChanged = true;
|
|
|
- o.IsBitOn = isOn;
|
|
|
- });
|
|
|
+ var output = this._outPutIOList.Where( x => x.BoardNo == board.BoardID ).ToList();
|
|
|
+ output.ForEach( o =>
|
|
|
+ {
|
|
|
+ var isOn = Convert.ToBoolean( outValue & this.bitOnMask[o.Index] ) ? true : false;
|
|
|
+ if ( o.IsBitOn != isOn )
|
|
|
+ o.IsChanged = true;
|
|
|
+ o.IsBitOn = isOn;
|
|
|
+ } );
|
|
|
}
|
|
|
else
|
|
|
- logger.E($"EzIO - [{board.BoardID}] Read Fail Error Code {result}");
|
|
|
+ logger.E( $"EzIO - [{board.BoardID}] Read Fail Error Code {result}" );
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
@@ -527,58 +527,58 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
|
|
|
void FireChangedIO()
|
|
|
{
|
|
|
- this.InPutIOList.ForEach(i =>
|
|
|
- {
|
|
|
- if (i.IsChanged)
|
|
|
- {
|
|
|
- i.IsChanged = false;
|
|
|
- var clone = ObjectCopyUtils.DeepClone<BitBlock>(i);
|
|
|
- this.qQ.Enqueue(new QoChangedIO { Arg0 = clone });
|
|
|
- NotifySyncBit(clone);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- this.OutPutIOList.ForEach(o =>
|
|
|
- {
|
|
|
- if (o.IsChanged)
|
|
|
- {
|
|
|
- o.IsChanged = false;
|
|
|
- var clone = ObjectCopyUtils.DeepClone<BitBlock>(o);
|
|
|
- this.qQ.Enqueue(new QoChangedIO { Arg0 = clone });
|
|
|
- }
|
|
|
- });
|
|
|
+ this.InPutIOList.ForEach( i =>
|
|
|
+ {
|
|
|
+ if ( i.IsChanged )
|
|
|
+ {
|
|
|
+ i.IsChanged = false;
|
|
|
+ var clone = ObjectCopyUtils.DeepClone<BitBlock>( i );
|
|
|
+ this.qQ.Enqueue( new QoChangedIO { Arg0 = clone } );
|
|
|
+ NotifySyncBit( clone );
|
|
|
+ }
|
|
|
+ } );
|
|
|
+
|
|
|
+ this.OutPutIOList.ForEach( o =>
|
|
|
+ {
|
|
|
+ if ( o.IsChanged )
|
|
|
+ {
|
|
|
+ o.IsChanged = false;
|
|
|
+ var clone = ObjectCopyUtils.DeepClone<BitBlock>( o );
|
|
|
+ this.qQ.Enqueue( new QoChangedIO { Arg0 = clone } );
|
|
|
+ }
|
|
|
+ } );
|
|
|
}
|
|
|
|
|
|
void PullQueueThread()
|
|
|
{
|
|
|
- while(IsThreadAlive)
|
|
|
+ while ( IsThreadAlive )
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
var o = qQ.Dequeue();
|
|
|
|
|
|
- if (o is QoConnected)
|
|
|
- DelegateUtils.Invoke(OnContd);
|
|
|
- else if (o is QoDiconnected)
|
|
|
- DelegateUtils.Invoke(OnDiscontd);
|
|
|
- else if (o is QoChangedIO)
|
|
|
- DelegateUtils.Invoke(OnChangedIO, o.Arg0);
|
|
|
- else if (o is QoWriteIO)
|
|
|
- DelegateUtils.Invoke(OnWriteIO, o.Arg0);
|
|
|
- else if (o is QoLog)
|
|
|
- DelegateUtils.Invoke(OnLog, o.Arg0, o.Arg1);
|
|
|
+ if ( o is QoConnected )
|
|
|
+ DelegateUtils.Invoke( OnContd );
|
|
|
+ else if ( o is QoDiconnected )
|
|
|
+ DelegateUtils.Invoke( OnDiscontd );
|
|
|
+ else if ( o is QoChangedIO )
|
|
|
+ DelegateUtils.Invoke( OnChangedIO, o.Arg0 );
|
|
|
+ else if ( o is QoWriteIO )
|
|
|
+ DelegateUtils.Invoke( OnWriteIO, o.Arg0 );
|
|
|
+ else if ( o is QoLog )
|
|
|
+ DelegateUtils.Invoke( OnLog, o.Arg0, o.Arg1 );
|
|
|
else
|
|
|
- Assert.Fail("Unk Object {0}", o);
|
|
|
+ Assert.Fail( "Unk Object {0}", o );
|
|
|
}
|
|
|
- catch (ThreadAbortException)
|
|
|
+ catch ( ThreadAbortException )
|
|
|
{
|
|
|
}
|
|
|
- catch (Exception e)
|
|
|
+ catch ( Exception e )
|
|
|
{
|
|
|
- logger.E(e);
|
|
|
+ logger.E( e );
|
|
|
}
|
|
|
}
|
|
|
- logger.D("[EzIO] - PullQueue Thread Dispose");
|
|
|
+ logger.D( "[EzIO] - PullQueue Thread Dispose" );
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -586,9 +586,9 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
/// InputIO 변경 알림
|
|
|
/// </summary>
|
|
|
/// <param name="block"></param>
|
|
|
- void NotifySyncBit(BitBlock block)
|
|
|
+ void NotifySyncBit( BitBlock block )
|
|
|
{
|
|
|
- if (ddWaitChgBlock.ContainsKey(block.Tag))
|
|
|
+ if ( ddWaitChgBlock.ContainsKey( block.Tag ) )
|
|
|
{
|
|
|
var so = ddWaitChgBlock[block.Tag];
|
|
|
so.Expect = block;
|
|
|
@@ -596,16 +596,16 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bool IsConnetedBoard(int boardNo)
|
|
|
+ bool IsConnetedBoard( int boardNo )
|
|
|
{
|
|
|
- return EziMOTIONPlusELib.FAS_IsSlaveExist(boardNo) == 1;
|
|
|
+ return EziMOTIONPlusELib.FAS_IsSlaveExist( boardNo ) == 1;
|
|
|
}
|
|
|
|
|
|
bool IsConnetedAllBoard()
|
|
|
{
|
|
|
- foreach (var b in this.BoardList)
|
|
|
+ foreach ( var b in this.BoardList )
|
|
|
{
|
|
|
- if (!IsConnetedBoard(b.BoardID))
|
|
|
+ if ( !IsConnetedBoard( b.BoardID ) )
|
|
|
{
|
|
|
this.qQ.Clear();//연결이 끊어지면 내용을 삭제.
|
|
|
return false;
|
|
|
@@ -617,16 +617,16 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
|
|
|
bool ConnectAllBoard()
|
|
|
{
|
|
|
- foreach (var b in this.BoardList)
|
|
|
+ foreach ( var b in this.BoardList )
|
|
|
{
|
|
|
- if (IsConnetedBoard(b.BoardID))
|
|
|
+ if ( IsConnetedBoard( b.BoardID ) )
|
|
|
continue;
|
|
|
|
|
|
var addr = b.IPAddress.Split( '.' );
|
|
|
byte boardNo = Convert.ToByte( addr[3] );
|
|
|
- if (EziMOTIONPlusELib.FAS_Connect((byte)192, (byte)168, (byte)0, boardNo, b.BoardID ) != EziMOTIONPlusELib.FMM_OK)
|
|
|
+ if ( EziMOTIONPlusELib.FAS_Connect( (byte)192, (byte)168, (byte)0, boardNo, b.BoardID ) != EziMOTIONPlusELib.FMM_OK )
|
|
|
{
|
|
|
- logger.E($"EzIO - Connect Fail {b.BoardID}");
|
|
|
+ logger.E( $"EzIO - Connect Fail {b.BoardID}" );
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
@@ -637,16 +637,16 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
public int Terminate()
|
|
|
{
|
|
|
this.IsThreadAlive = false;
|
|
|
- if (this._readThread != null && this._readThread.IsAlive)
|
|
|
+ if ( this._readThread != null && this._readThread.IsAlive )
|
|
|
{
|
|
|
- if (!this._readThread.Join(3000))
|
|
|
+ if ( !this._readThread.Join( 3000 ) )
|
|
|
this._readThread.Abort();
|
|
|
}
|
|
|
|
|
|
- this.BoardList.ForEach(b =>
|
|
|
- {
|
|
|
- EziMOTIONPlusELib.FAS_Close(b.BoardID);
|
|
|
- });
|
|
|
+ this.BoardList.ForEach( b =>
|
|
|
+ {
|
|
|
+ EziMOTIONPlusELib.FAS_Close( b.BoardID );
|
|
|
+ } );
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -656,7 +656,7 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
- int GetModuleAndBitNoByAddress(uint usIOAddr, out int boardNo, out int bitNo)
|
|
|
+ int GetModuleAndBitNoByAddress( uint usIOAddr, out int boardNo, out int bitNo )
|
|
|
{
|
|
|
long nOffset = 0;
|
|
|
long nCount = 0;
|
|
|
@@ -666,14 +666,14 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
boardNo = 0;
|
|
|
bitNo = 0;
|
|
|
|
|
|
- if (usIOAddr < OUTPUT_ORIGIN)
|
|
|
+ if ( usIOAddr < OUTPUT_ORIGIN )
|
|
|
{
|
|
|
nOffset = usIOAddr - INPUT_ORIGIN;
|
|
|
- for (int nModNo = 0; nModNo < this.BoardList.Count; nModNo++)
|
|
|
+ for ( int nModNo = 0; nModNo < this.BoardList.Count; nModNo++ )
|
|
|
{
|
|
|
// Get Input CH Count Using Module ID
|
|
|
//AxdInfoGetInputCount( nModNo, nCount );
|
|
|
- if (nOffset - nCount < 0)
|
|
|
+ if ( nOffset - nCount < 0 )
|
|
|
{
|
|
|
boardNo = nModNo;
|
|
|
bitNo = (int)nOffset;
|
|
|
@@ -685,11 +685,11 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
else
|
|
|
{
|
|
|
nOffset = usIOAddr - OUTPUT_ORIGIN;
|
|
|
- for (int nModNo = 0; nModNo < this.BoardList.Count; nModNo++)
|
|
|
+ for ( int nModNo = 0; nModNo < this.BoardList.Count; nModNo++ )
|
|
|
{
|
|
|
// Get Output CH Count Using Module ID
|
|
|
//AxdInfoGetOutputCount( nModNo, nCount );
|
|
|
- if (nOffset - nCount < 0)
|
|
|
+ if ( nOffset - nCount < 0 )
|
|
|
{
|
|
|
boardNo = nModNo;
|
|
|
bitNo = (int)nOffset;
|
|
|
@@ -705,24 +705,24 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
#region IDisposable Support
|
|
|
private bool disposedValue = false; // 중복 호출을 검색하려면
|
|
|
|
|
|
- protected virtual void Dispose(bool disposing)
|
|
|
+ protected virtual void Dispose( bool disposing )
|
|
|
{
|
|
|
- if (!disposedValue)
|
|
|
+ if ( !disposedValue )
|
|
|
{
|
|
|
- if (disposing)
|
|
|
+ if ( disposing )
|
|
|
{
|
|
|
// TODO: 관리되는 상태(관리되는 개체)를 삭제합니다.
|
|
|
- if (this.pullThread != null)
|
|
|
+ if ( this.pullThread != null )
|
|
|
{
|
|
|
this.IsThreadAlive = false;
|
|
|
- if (!this.pullThread.Join(2000) && this.pullThread.IsAlive)
|
|
|
+ if ( !this.pullThread.Join( 2000 ) && this.pullThread.IsAlive )
|
|
|
{
|
|
|
this.pullThread.Abort();
|
|
|
}
|
|
|
this.pullThread = null;
|
|
|
}
|
|
|
|
|
|
- ThreadUtils.Kill(this.pullThread);
|
|
|
+ ThreadUtils.Kill( this.pullThread );
|
|
|
|
|
|
Terminate(); //Board Close
|
|
|
}
|
|
|
@@ -745,7 +745,7 @@ namespace VehicleControlSystem.ControlLayer.IO
|
|
|
public void Dispose()
|
|
|
{
|
|
|
// 이 코드를 변경하지 마세요. 위의 Dispose(bool disposing)에 정리 코드를 입력하세요.
|
|
|
- Dispose(true);
|
|
|
+ Dispose( true );
|
|
|
// TODO: 위의 종료자가 재정의된 경우 다음 코드 줄의 주석 처리를 제거합니다.
|
|
|
// GC.SuppressFinalize(this);
|
|
|
}
|