Beispiel #1
0
static void do_reload(int write_flag)
{
  char name[100];

  //printf("%s",interpreter.line);
  interpreter.line[0] = '\0';
  center.lock();
  if(write_flag)
  {
    spreadsheat.write(SPREADSHEAT_FILE);
  }
  spreadsheat.read(SPREADSHEAT_FILE);
  set_header();
  for(int irow=FIRST_ROW; spreadsheat.exists(irow,1); irow++)
  {

    rlstrncpy(name,spreadsheat.text(T_name,irow),sizeof(name)-1);
    if(name[0] > 0)
    {
      spreadsheat.printf(T_credit,irow,"%s",spreadsheat.text(T_initial_credit,irow));
    }
  }
  construct_processlist();
  center.unlock();
}
Beispiel #2
0
void *profibus(void *arg)
{
#ifdef _RL_HILSCHER_CIF_H_
  THREAD_PARAM *p = (THREAD_PARAM *) arg;
  cif.debug = 1;
  if(cif.open() == DRV_NO_ERROR)
  {
    cif.debug = 0;
    while(p->running)
    {
      rlsleep(50);
      pbus.lock();
      cif.devExchangeIO(0,4,sendData,
                        0,4,receiveData,
                        1000);
      pbus.unlock();
    }
  }
  else 
  {
    printf("failed to cif.open()\n");
    printf("Please run me as root or\n");
    printf("make /dev/cif readable by normal user\n");
  }
#else
  printf("WARNING: you will have to install the hilscher driver and link to it. Then you can remove the ifdef _WIN32\n");
#endif  
  return arg;
}
Beispiel #3
0
static void watchdog()
{
  now.getLocalTime();
  center.lock();
  for(int row=FIRST_ROW; spreadsheat.exists(row,1); row++)
  {
    start_if_missing(row);
  }
  center.unlock();
}
Beispiel #4
0
static void do_sigkill()
{
  long pid;
  rlPcontrol *item;

  //printf("%s",interpreter.line);
  sscanf(interpreter.line,"sigkill(%ld)",&pid);
  interpreter.line[0] = '\0';
  center.lock();
  item = processlist;
  while(item != NULL)
  {
    if(item->pid() == pid)
    {
      item->sigkill();
      item->processTime()->getLocalTime(); // stop time
      break;
    }
    item = item->getNext();
  }
  center.unlock();
}
// read cycle on modbus
int modbusCycle(int offset, int slave, int function, int start_adr, int num_register)
{
  unsigned char data[256+1];
  int ret;

  watchcnt1++;
  if(watchcnt1 > 10000) watchcnt1 = 0;
  rlsleep(MODBUS_IDLETIME);
  thread.lock();
  ret = modbus.request(slave, function, start_adr, num_register);
  if(ret >= 0) ret = modbus.response( &slave, &function, data);
  if(ret < 0) sock.disconnect();
  thread.unlock();
  if(ret > 0) shm.write(offset,data,ret);
  else
  {
    readErrorCount++;
    if(readErrorCount >= 256*128) readErrorCount = 0;
    shm.write(modbusdaemon_READ_ERROR_COUNT_BASE,&readErrorCount,2);
  }
  printf("cycle ret=%d slave=%d function=%d data[0]=%d\n",ret,slave,function,data[0]);
  return ret;
}