# Teste 09/07/2018

## Controlador Power Focus PF4000 
### OP: 2.2 
### SoftwareVersion: 10.15.6

---

[x] Realizar conexão

[x] Habilitar Link Layer

[x] Controlar sequenceNumber

[x] Operar em modo genérico
* Controlador não suporta

[x] Realizar requests

[x] Realizar commands

[x] Realizar subscribe

[x] Realizar unsubscribe

[x] Fechar conexão
* Controlador com resposta incorreta.

[x] Checar Alarm

[x] Comunicação  sem Link Layer
* MID 0001 Revision 1

[x] Realizar chamada de aperto e resultado

``` 
    Subscribe subscribeLastTightening()
    Command commandAbortJob()
    Command commandSelectParameterSet(1);
    Command commandVehicleIdNumberDownload("ASDEDCUHBG34563EDFRCVGFR6");
    Command commandDisableTool();
    Command commandEnableTool();
```



## Observações

- Detectada falha na resposta de sequenceNumber, os mid de ack 9997 e 9998 não tinha tratativa para mensagens recebidas com sequenceNumber 99;

- Controlador responde ao comando communicationStop MID0003 de maneira irregular, o controlador incrementa o sequenceNumber da resposta, gerando um erro do nosso lado.

    ``` 
    Ex: commandDisableTool MID 0042
        S [00200042001001010200 ]
        R [00249997        03000042 ]
        R [00240005        02000042 ]
    ```

    ```
    Ex: communicationStop MID0003
        S [00200003001001010700 ]
        R [00249997        08000003 ]
        R [00240005        08000003 ]
    ```    

- Chamadas de callback em locais errados. (Link Layer).    

### Respostas do controlador

#### MID 0002

```javascript
    {
        "mid":2,
        "revision":6,
        "noAck":false,
        "stationID":1,
        "spindleID":1,
        "sequenceNumber":5,
        "messageParts":0,
        "messageNumber":0,
        "payload":{
            "cellID":0,
            "channelID":0,
            "controllerName":"PA160LDA2",
            "supplierCode":"ACT",
            "openProtocolVersion":"2.2",
            "controllerSoftwareVersion":"10.15.6",
            "toolSoftwareVersion":"",
            "rbuType":"Silver (Ag)",
            "controllerSerialNumber":"D240003",
            "systemType":1,
            "systemSubtype":1,
            "sequenceNumberSupport":1,
            "linkingHandlingSupport":0
            }
    }
```

```javascript
    {
        "mid":2,
        "revision":1,
        "noAck":false,
        "stationID":1,
        "spindleID":1,
        "sequenceNumber":38,
        "messageParts":0,
        "messageNumber":0,
        "payload":{
            "cellID":0,
            "channelID":0,
            "controllerName":"PA160LDA2"
            }
    }
```

#### MID 0061

```javascript
    {
        "mid":61,"revision":6,"noAck":false,"stationID":1,"spindleID":1,"sequenceNumber":30,"messageParts":0,"messageNumber":0,
        "payload":{
            "prevailTorqueCompensateValue":0,
            "tighteningErrorStatus2":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"_tighteningErrorStatus2":0,
            "customerToghteningErrorCode":"",
            "identifierPart2":"",
            "identifierPart3":"",
            "identifierPart4":"",
            "parameterSetName":"Barra diregco FOX eletro","torqueValuesUnit":"Nm",
            "resultType":"Tightening",
            "_torqueValuesUnit":1,
            "_resultType":1,
            "cellID":0,
            "channelID":0,
            "torqueControllerName":"PA160LDA2",
            "numberVIN":"ASDEDCUHBG3456",
            "jobID":0,
            "parameterSetID":1,
            "strategy":"Angle control / torque monitoring",
            "strategyOptions":["Torque","Angle","Batch",null,null,null,"Rundown",null,null,null,null],
            "batchSize":0,
            "batchCounter":0,
            "tighteningStatus":"NOK",
            "batchStatus":"NOK",
            "torqueStatus":"LOW",
            "angleStatus":"LOW",
            "rundownAngleStatus":"LOW",
            "currentMonitoringStatus":"OK",
            "selftapStatus":"OK",
            "prevailTorqueMonitoringStatus":"OK","prevailTorqueCompensateStatus":"OK",
            "tighteningErrorStatus":[null,"Rundown angle min shut off",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],
            "torqueMinLimit":32,
            "torqueMaxLimit":90,
            "torqueFinalTarget":9999,
            "torque":16.48,
            "angleMin":75,
            "angleMax":105,
            "finalAngleTarget":90,
            "angle":0,
            "rundownAngleMin":10,
            "rundownAngleMax":9999,
            "rundownAngle":1,
            "currentMonitoringMin":0,
            "currentMonitoringMax":150,
            "currentMonitoringValue":0,
            "selftapMin":3.3,
            "selftapMax":9999,
            "selftapTorque":0,
            "prevailTorqueMonitoringMin":3.3,
            "prevailTorqueMonitoringMax":22,
            "prevailTorque":0,
            "tighteningID":190736,
            "jobSequenceNumber":0,
            "syncTighteningID":0,
            "toolSerialNumber":56877,
            "timeStamp":"2018-07-09:13:31:44","timeLastChange":"2017-08-22:10:18:41",
            "_strategy":4,
            "_strategyOptions":71,
            "_torqueStatus":0,
            "_angleStatus":0,
            "_rundownAngleStatus":0,
            "_currentMonitoringStatus":1,
            "_selftapStatus":1,
            "_prevailTorqueMonitoringStatus":1,"_prevailTorqueCompensateStatus":1,
            "_tighteningErrorStatus":2,
            "_tighteningStatus":0,
            "_batchStatus":0
            }
    }
```

```javascript
    {
        "mid":61,
        "revision":1,
        "noAck":false,
        "stationID":1,
        "spindleID":1,
        "sequenceNumber":0,
        "messageParts":0,
        "messageNumber":0,
        "payload":{
            "cellID":0,
            "channelID":0,
            "torqueControllerName":"PA160LDA2",
            "numberVIN":"ASDEDCUHBG3456           ",
            "jobID":0,
            "parameterSetID":1,
            "batchSize":0,
            "batchCounter":0,
            "tighteningStatus":"NOK",
            "torqueStatus":"LOW",
            "angleStatus":"LOW",
            "torqueMinLimit":32,
            "torqueMaxLimit":90,
            "torqueFinalTarget":9999,
            "torque":16.04,
            "angleMin":75,
            "angleMax":105,
            "finalAngleTarget":90,
            "angle":0,
            "timeStamp":"2018-07-09:13:43:18","timeLastChange":"2017-08-22:10:18:41",
            "batchStatus":"NOK",
            "tighteningID":190742,
            "_torqueStatus":0,
            "_angleStatus":0,
            "_tighteningStatus":0,
            "_batchStatus":0
            }
    }
```

#### MID 0041

```javascript
[01800041003     32000156877         020000015450032018-07-03:12:10:000400309280  05012650061970-01-01:00:00:00070000014832080109071000011                   120110001301189014048786 ]

01: [56877         ],
02: [0000015450],
03: [2018-07-03:12:10:00],
04: [00309280  ],
05: [012650],
06: [1970-01-01:00:00:00],
07: [0000014832],
08: [01],
09: [07],
10: [000],
11: [                   ],
12: [011000],
13: [011890],
14: [048786] 

```

```javascript
[02060041005     58000156877         020000015450032018-07-03:12:10:000400309280  05012650061970-01-01:00:00:00070000014832080109071000011                   120110001301189014048786150116                     ]


01: [56877         ],
02: [0000015450],
03: [2018-07-03:12:10:00],
04: [00309280  ],
05: [012650],
06: [1970-01-01:00:00:00],
07: [0000014832],
08: [01],
09: [07],
10: [000],
11: [                   ],
12: [011000],
13: [011890],
14: [048786],
15: [01],
16: [            ] 

```