Ignore:
Timestamp:
01/23/03 13:32:58 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc

    r1703 r1727  
    11#include "shaftencoder.h"
    22
    3 #include "timer.h"
     3#include "base/timer.h"
    44#include "network.h"
    55
     
    1717ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out)
    1818    : NodeDrv(nodeid, name, out), fLabel(NULL), fPosHasChanged(false)
    19 {
    20 }
    21 
    22 ShaftEncoder::~ShaftEncoder()
    2319{
    2420}
     
    5551        return;
    5652
     53    case 0x100c:
     54        lout << "- Guardtime: " << dec << val << "ms" << endl;
     55        return;
     56
     57    case 0x100d:
     58        lout << "- Lifetimefactor: " << dec << val << endl;
     59        return;
     60
     61    case 0x100e:
     62        lout << "- CobId for guarding: 0x" << hex << val << endl;
     63        return;
     64
    5765    case 0x6000:
    5866    case 0x6500:
    59         lout << "- Counting: " << (val&1   ?"anti-clockwise":"clockwise") << "  ";
     67        lout << "- Counting: " << (val&1 ?"anti-clockwise":"clockwise") << "  ";
    6068        lout << "HwTest: " <<   (val&2   ?"on":"off") << "  ";
    6169        lout << "Scaling: " <<  (val&4   ?"on":"off") << "  ";
     
    95103void ShaftEncoder::DisplayVal()
    96104{
    97     if (fIsZombie)
     105    if (IsZombieNode())
    98106    {
    99107        fLabel[0]->SetText(new TGString(""));
     
    162170}
    163171
     172//#include <fstream.h>
     173//ofstream fout("log/shaftencoder.log");
     174
    164175void ShaftEncoder::HandlePDOType2(BYTE_t *data, timeval_t *tv)
    165176{
     
    188199    fPos  = pos;
    189200    fTurn = turn;
     201
     202    //fout << dec << (int)GetId() << " " << turn << " " << pos << endl;
     203
    190204    fTime.SetTimer(tv);
    191205    fPosHasChanged=true;
     
    208222    //-----------------------------------------------------------------------
    209223
     224    StopGuarding();
     225
    210226    //
    211227    // Requesting and checking (FIXME) type of encoder
     
    215231    WaitForSdo(0x1000);
    216232
    217     if (fIsZombie)
     233    if (IsZombieNode())
    218234    {
    219235        lout << GetNodeName() << " - Init failed!" << endl;
     
    274290    lout << "- " << GetNodeName() << ": Start Node (NMT)." << endl;
    275291    SendNMT(kNMT_START);
     292
     293    StartGuarding(125, 2);
    276294}
    277295
     
    282300    WaitForSdo(0x100b);
    283301}
    284 /*
    285 bool ShaftEncoder::InitDevice(Network *net)
    286 {
    287     NodeDrv::InitDevice(net);
    288 
    289     Init();
    290 
    291     return !fIsZombie;
    292 }
    293 
    294 // --------------------------------------------------------------------------
    295 //
    296 // This should be called from a master or main thread to get a node out
    297 // of the Zombie-Status.
    298 //
    299 bool ShaftEncoder::Reboot()
    300 {
    301     fIsZombie = false;
    302 
    303     Init();
    304 
    305     return !fIsZombie;
    306 }
    307 */
    308302
    309303void ShaftEncoder::ReqPos()
     
    321315    lout << "- " << GetNodeName() << ": Setting Preset." << endl;
    322316
    323     SendSDO(0x6003, (LWORD_t)fPos);
     317    SendSDO(0x6003, (LWORD_t)pre);
    324318    if (!WaitForSdo(0x6003))
    325319        return;
Note: See TracChangeset for help on using the changeset viewer.