diff --git a/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI.vb b/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI.vb index 14b0c54..a1222f2 100644 --- a/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI.vb +++ b/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI.vb @@ -948,6 +948,14 @@ Namespace CNC Public Overridable Function O_ReadCurrentAnomalyMsg(ByRef CurrMsgAnomaly As OPENcontrol.MSGANOMALY) As Boolean Return True End Function + ''' + ''' Restituisce posizione assi (tutti) + ''' + ''' + ''' + Public Overridable Function getAllAxisPos(ByRef AxisPos As OPENcontrol.GETINTDATA()) As Boolean + Return True + End Function #End Region diff --git a/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI_SOAP.vb b/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI_SOAP.vb index 4df943b..b990ccd 100644 --- a/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI_SOAP.vb +++ b/MTC_Adapter/CMSCncLib/CNC/CNC.OSAI/CNC.OSAI_SOAP.vb @@ -1095,35 +1095,40 @@ Retry: nRetry += 1 End Function -#If False Then - Public Function getAllAxisPos() As Focas1.ODBPOS + Public Overloads Overrides Function getAllAxisPos(ByRef AxisPos As OPENcontrol.GETINTDATA()) As Boolean ' RIFERIMENTO: - ' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Position\cnc_rdposition.htm + ' CndexLinkUser.pdf | pag 146, 266 - Dim nPathIdx As Integer - Dim nNumAxisRead As Integer - Dim nReturn As Integer + Dim szReturn As String = "" + Dim myGetAxesPositionR As OPENcontrol.GetAxesPositionR + Dim myGetAxesPosition As New OPENcontrol.GetAxesPosition + Dim ProcessId As Short + Dim nRetry As Integer +Retry: nRetry += 1 - Dim posizAssi As Focas1.ODBPOS + Try + O_GetSelectedProcess(ProcessId) + myGetAxesPosition.ProcNum = ProcessId + myGetAxesPosition.AxisName = "0" + myGetAxesPosition.NumAxis = AxisPos.Length + myGetAxesPosition.Select = 1 - 'leggo il numero del processo attivo - nPathIdx = GetActivePath() - 'leggo num max assi dal cn - nNumAxisRead = Focas1.MAX_AXIS - - If Is30Series Then - - ' leggo tutto!!! - nReturn = Focas1.cnc_rdposition(nLibHandle(nPathIdx), -1, nNumAxisRead, posizAssi) - - If F_CheckRetError_Cnc(nReturn, "cnc_rdposition RefreshAxisPosition CNC.FANUC.CMS_CncLib") Then - Throw New CmsNcException("ERR cnc_rdposition RefreshAxisPosition CNC.FANUC.CMS_CncLib") + myGetAxesPositionR = OPENws.GetAxesPosition(myGetAxesPosition) + If O_CheckRetError(myGetAxesPositionR.retval, myGetAxesPositionR.ErrClass, myGetAxesPositionR.ErrNum, "ReadCurrentAnomalyMsg() O_ReadCurrentAnomalyMsg CNC.OSAI_OPEN", szReturn) Then + Throw New CmsNcException(szReturn) + Return False End If - End If - Return posizAssi + AxisPos = myGetAxesPositionR.IntPos + Return True + Catch ex As System.ServiceModel.CommunicationException + If nRetry < MAXRET Then GoTo Retry + Throw New CmsNcException(ex.Message) + Return False + End Try End Function +#If False Then Public Function getAllAxisLoad() As Focas1.ODBSVLOAD ' RIFERIMENTO: diff --git a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs index 54b3255..ce4a88c 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs @@ -10,7 +10,9 @@ namespace MTC_Adapter { public class AdapterOsai : AdapterGeneric { - // vettore valori in file interscambio + /// + /// vettore valori in file interscambio + /// public Dictionary generalStatus; /// /// Contenuto valori maintenance data da PLC @@ -20,7 +22,6 @@ namespace MTC_Adapter /// Contenuto valori status data da PLC /// public otherData[] statusData; - /// /// Oggetto MAIN x connessione OSAI /// @@ -159,7 +160,6 @@ namespace MTC_Adapter } return answ; } - /// /// struttura dati OSAI x dati NC (pag 148) /// @@ -168,7 +168,6 @@ namespace MTC_Adapter /// Vettore degli allarmi CNC attivi /// public CMSCncLib.OPENcontrol.MSGERROR allarmiCNC; - /// /// estende l'init della classe base... /// @@ -318,7 +317,6 @@ namespace MTC_Adapter lg.Error("Errore connessione mancante in getStrobeAndAckStatus"); } } - /// /// processing strobe! /// @@ -361,7 +359,6 @@ namespace MTC_Adapter // gestione bit di watchdog... sulal DWord successiva sendWatchDog(); } - /// /// Processa strobe x un dato path /// @@ -531,7 +528,6 @@ namespace MTC_Adapter if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-B", retACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks); } } - /// /// Recupero info su test: numero + elenco parametri IN/OUT /// @@ -573,7 +569,6 @@ namespace MTC_Adapter return answ; } - /// /// Gestione STROBE --> ACK per codici M/S/T /// @@ -697,7 +692,6 @@ namespace MTC_Adapter } } } - /// /// Gestione strobe UserAction: salva dati e gestione ACK /// @@ -821,7 +815,6 @@ namespace MTC_Adapter } } } - /// /// processing! /// @@ -1086,12 +1079,9 @@ namespace MTC_Adapter vettPath[idxPath].mPathSubMode.Value = pathSubMode; } } - - public override void getConfigParam() - { - base.getConfigParam(); - } - + /// + /// Recupera dati a lenta variazione + /// public override void getSlowChangingData() { base.getSlowChangingData(); @@ -1100,8 +1090,7 @@ namespace MTC_Adapter reloadDataFromFile(); // area gestione dati utensili... in base al num max di UnOp recupero i dati utensile... PROCEDURA AD HOC!!! - getDatiUt_Fanuc(currAdpConf.nUnOp); - + getDatiUt_Osai(currAdpConf.nUnOp); } /// /// Gestione lettura dati manutenzione @@ -1153,8 +1142,10 @@ namespace MTC_Adapter inizio = DateTime.Now; OSAI_ref.O_GetNcInfo1(ref allNcData); if (utils.CRB("recTime")) TimingData.addResult("R-NcInfo", DateTime.Now.Subtract(inizio).Ticks); - // recupero feed... + + // recupero speed e feed... FeedRate = Convert.ToInt32(allNcData.realfeed); + SpeedRate = Convert.ToInt32(allNcData.realspeed); // area path1/2: 7 WORD x ogni path... int memIndex = 19151; @@ -1165,6 +1156,7 @@ namespace MTC_Adapter // inizio indicando feed... sb.AppendLine(string.Format("FeedRate: {0} mm/min", FeedRate)); + sb.AppendLine(string.Format("SpeedRate: {0} mm/min", SpeedRate)); // 2017.04.20: recupero OVER per Jog/Feed/Rapid/Spindle x i path multipli (qui cablati 1-2) ushort[] currPathData = new ushort[7]; @@ -1310,7 +1302,9 @@ namespace MTC_Adapter if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili status gestite", numRiga)); } - + /// + /// Processing allarmi CNC + /// public override void processAlarm() { base.processAlarm(); @@ -1318,7 +1312,6 @@ namespace MTC_Adapter // aggiungo gestione allarmi CNC checkCNCAlarms(); } - /// /// Verifica i 10 allarmi CNC SE presenti /// @@ -1329,7 +1322,6 @@ namespace MTC_Adapter sendAlarmIfPresent(allarmiCNC); } } - /// /// Invia singolo allarme CNC se presente /// @@ -1358,10 +1350,13 @@ namespace MTC_Adapter } } } - + /// + /// Recupero dati x UnOp + /// public override void getUnOp() { base.getUnOp(); + // !!!FARE!!! NON HO trovato nulla, verificare con Andrea... #if false // leggo in blocco tutte le speed da memoria... @@ -1373,13 +1368,6 @@ namespace MTC_Adapter OsaiMemRW(R, FANUC.MemType.D, memIndex, ref unOpSpeedMem); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-SPEED_UNOP", unOpSpeedMem.Length), DateTime.Now.Subtract(inizio).Ticks); - // NON VA: RICHIEDE OPZIONE... The extended driver/library function is necessary. -#if false - // recupero vettore load spindle... - inizio = DateTime.Now; - CMSCncLib.Focas1.ODBSPN spindleVect = FANUC_ref.getSpindleLoad(); - if (utils.CRB("recTime")) TimingData.addResult("R-SpindleLoad", DateTime.Now.Subtract(inizio).Ticks); -#endif StringBuilder sb = new StringBuilder(); int numUnOp = currAdpConf.nUnOp; @@ -1408,7 +1396,7 @@ namespace MTC_Adapter /// procedura di lettura (Multipla) dati da memoria x caricare dati utensile /// /// num max di teste da recuperare - private void getDatiUt_Fanuc(int maxNumOp) + private void getDatiUt_Osai(int maxNumOp) { #if false // variabili "Indice" utensile e famiglia da decodificare + utils @@ -1550,7 +1538,7 @@ namespace MTC_Adapter public override void getPath() { - //NON richiamo metodo base... ma faccio override qui (e altrove...) + // NON richiamo metodo base... ma faccio override qui (e altrove...) checkPath(); #if false @@ -1640,30 +1628,33 @@ namespace MTC_Adapter StringBuilder sb = new StringBuilder(); inizio = DateTime.Now; -#if false - CMSCncLib.Focas1.ODBPOS posAssi = OSAI_ref.getAllAxisPos(); + // inizializzo x numero assi... + CMSCncLib.OPENcontrol.GETINTDATA[] posAssi= new CMSCncLib.OPENcontrol.GETINTDATA[currAdpConf.nAxis]; + OSAI_ref.getAllAxisPos(ref posAssi); if (utils.CRB("recTime")) TimingData.addResult("R-AXIS_POS", DateTime.Now.Subtract(inizio).Ticks); + // NON c'รจ LOAD assi... +#if false inizio = DateTime.Now; CMSCncLib.Focas1.ODBSVLOAD loadAssi = OSAI_ref.getAllAxisLoad(); - if (utils.CRB("recTime")) TimingData.addResult("R-AXIS_LOAD", DateTime.Now.Subtract(inizio).Ticks); - - CMSCncLib.Focas1.LOADELM valLoad = new CMSCncLib.Focas1.LOADELM(); - CMSCncLib.Focas1.POSELMALL valPos = new CMSCncLib.Focas1.POSELMALL(); - + if (utils.CRB("recTime")) TimingData.addResult("R-AXIS_LOAD", DateTime.Now.Subtract(inizio).Ticks); +#endif + // nuova posizione (per calcoli) double newPos = 0; double distPerc = 0; int newDir = 0; string tipoAsse = ""; string direzione = ""; - + char axName; + // ciclo x assi for (int i = 0; i < currAdpConf.nAxis; i++) { // per sicurezza try-catch try { // in base a indice scelgo valore posizione e load +#if false switch (i) { case 0: @@ -1799,13 +1790,22 @@ namespace MTC_Adapter valPos = posAssi.p1; valLoad = loadAssi.svload1; break; - } + } +#endif + //string axName = System.Text.Encoding.ASCII.GetString(posAssi[i].AxisName); + axName = Convert.ToChar(posAssi[i].AxisName); + newPos = posAssi[i].position; // popolo valori... - vettAxis[i].mAxLoad.Value = (double)(valLoad.data) / Math.Pow(10, valLoad.dec); +#if false + vettAxis[i].mAxLoad.Value = (double)(valLoad.data) / Math.Pow(10, valLoad.dec); newPos = (double)(valPos.abs.data) / Math.Pow(10, valPos.abs.dec); +#endif + vettAxis[i].mAxPosAct.Value = newPos; - vettAxis[i].mAxPosTgt.Value = newPos + (double)(valPos.dist.data) / Math.Pow(10, valPos.dist.dec); +#if false + vettAxis[i].mAxPosTgt.Value = newPos + (double)(valPos.dist.data) / Math.Pow(10, valPos.dist.dec); +#endif vettAxis[i].mAxFeedAct.Value = FeedRate; @@ -1839,8 +1839,7 @@ namespace MTC_Adapter if (utils.CRB("verbose")) { - - sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3}, ToGo:{2:N3}{3} | {4}", valPos.abs.name, (double)(valPos.abs.data) / Math.Pow(10, valPos.abs.dec), valPos.dist.name, (double)(valPos.dist.data) / Math.Pow(10, valPos.dist.dec), direzione)); + sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3}, ToGo:{2:N3}{3} | {4}", axName, newPos, "", "...", direzione)); } // salvo valori vettore prec... @@ -1860,8 +1859,7 @@ namespace MTC_Adapter } } - parentForm.dataMonitor += sb.ToString(); -#endif + parentForm.dataMonitor += sb.ToString(); } } }