Examples of PrmInterface


Examples of ru.vassaev.core.PrmInterface

              + e.getKey();
          // ta.setTaskParamObject(id_task, n, e.getValue());
          ta.setParamObject(id_task, n, e.getValue());
        }
      } else if (addprms instanceof PrmInterface) {
        PrmInterface aprms = (PrmInterface) addprms;
        for (String k : aprms.getFieldNames()) {
          String n = (grp == null) ? k : grp + "/" + k;
          // ta.setTaskParamString(id_task, n, aprms.getField(k));
          ta.setParamObject(id_task, n, aprms.getField(k));
        }
      } else if (addprms instanceof ByteMsg) {
        ByteMsg msg = (ByteMsg) addprms;
        PrmInterface aprms = msg.getPrmInterface();
        for (String k : aprms.getFieldNames()) {
          String n = (grp == null) ? k : grp + "/" + k;
          // ta.setTaskParamString(id_task, n, aprms.getField(k));
          ta.setParamObject(id_task, n, aprms.getField(k));
        }
      }
    try {
      String finish_duration = Strings
          .getString((this.finish_duration != null) ? this.finish_duration
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

    byte val[];
    val = Bytes.longToByte32(1234567890);
   
    System.out.print(Bytes.byteToLong(val));
    FileQueryRRAM fq = new FileQueryRRAM();
    PrmInterface prms = new PrmInterfaceInst();
    prms.setField("@port", args[1]);
    prms.setField("@server", args[0]);
    File f = new File(args[2]);
    long l = f.length();
    byte[] query = new byte[(int)l];
    FileInputStream fis = new FileInputStream(f);
    fis.read(query);
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

      Context child;
      Context cntx = getContext();
      Process cp = Process.currentProcess();
      try {
        cp.regResourceName(prms, "msg");
        PrmInterface prm = prms.getPrmInterface();
        ArrayList<String> flds = prm.getFieldNames();
        for (String k : flds) {
          String v = prm.getField(k);
          cp.regResourceName(v, "msg." + k);
        }
        child = getChild().createAndReadyTask(ta, cntx, id_processor, msg_grp_in, prms);
        if (child == null)
          return;
        long wait = Strings.parseIntegerNvl(cntx.getPrmString("wait"), 0);
        if (wait == 0)
          return;
        State st = child.ta.waitFinished(child.id_subject, child.id_task, wait);
        {
          boolean need_reply;
          try {
            need_reply = Boolean.parseBoolean(Strings.getString(child.getPrmString("need_reply")));
          } catch (Exception ex) {
            need_reply = true;
          }
          if (!need_reply)
            return;
          Map<String, Object> prms_out = child.getGroupParams(msg_grp_out);
          Iterator<Map.Entry<String, Object>> i = prms_out.entrySet().iterator();
          prm = prms.getPrmInterface();
          if (Strings.parseBooleanNvl(child.getPrmString("clear"), false))
            prm.clearFields();
          while (i.hasNext()) {
            Map.Entry<String, Object> e = i.next();
            Object o = e.getValue();
            String[] fn = cntx.getFullName(e.getKey());
            prm.setField(fn[1], Strings.getString(o));
          }
          synchronized(sync_sock) {
            prms.sendTo(socket.getOutputStream());
          }
        }
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

            prcs.free(prcr);
          }
//*/
          //{C06}
          Record r = new Record();
          PrmInterface prm = msg.getPrmInterface();
          for (String n : prm.getFieldNames()) {
            v = prm.getField(n);
            n = "msg." + n;
            cntx.log(false, n, "=", v);
            r.setObject(n, v);
            prc.regResourceName(v, n);
          }
          prc.regResourceName(r, "msg.*");
          catch_done++;
          prc.regResourceName(catch_done, "catch_done");
          //{C12}
          cntx.getPrmByFullName("update");// Расчитать
        }
        //{C07}
        need_send = cntx.getPrmNvl("need_send", true);
        if (need_send) {
          send_wait++;
          prc.regResourceName(send_wait, "send_wait");
          //*
          //{C08}
          String msg_grp_in = cntx.getPrmNvl("msg_grp_in", "in");
          Map<String, Object> prms = cntx.getGroupParams(msg_grp_in);
          msg.reset();
          //TPTPMsg msg = new TPTPMsg();
          try {
            PrmInterface prmi = msg.getPrmInterface();
            for (Map.Entry<String, Object> prm : prms.entrySet()) {
              String key = prm.getKey();
              String[] fn = cntx.getFullName(key);
              prmi.setField(fn[1], Strings.getString(cntx.getPrmString(key)));
            }
            //{C10}
            msg.sendTo(s.getOutputStream());

            //msg.sendTo(System.out);
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

        String keyNames = cntx.getPrmString("keyNames");
        m.setKeyNames(keyNames);

        Map<String, Object> prms_in = cntx.getGroupParams("in");
        PrmInterface prm = m.getPrmInterface();
        for (String n : prms_in.keySet()) {
          Object v = prms_in.get(n);
          n = n.substring("in/".length());
          if (v != null)
            prm.setField(n, v.toString());
          else
            prm.setField(n, null);
        }
        boolean isCalcKey = m.isCalcKey();
        key = (isCalcKey ? m.getCalcKey() : m.getKey());
        cntx.ta.setParamObject(cntx.id_task, "calcKey", key);
        is = m.getInputStream();
        int b = -1;
        while ((b = is.read()) != -1)
          os.write(b);
        os.flush();
        is = s.getInputStream();
        InfoBase<XMLMsg, XMLMsg> ib = new InfoBase<XMLMsg, XMLMsg>();
        ib.makeQuery(m, key);
        m.reset();
        Reader th = new Reader(is, ib, m, key, cntx.ta, cntx.id_task);
        try {
          th.start();
//====================================
          cntx.log(false, "Start waiting (", timeout, ")");
          XMLMsg r = ib.takeResponseWithWait(key, timeout); //, id_task, ta, id_processor);
          cntx.log(false, "End waiting");

          if (r == null) {
            throw new TaskException(State.DONE_TOUT, "An expected response was not received on time");
          }
          PrmInterface r_prm = r.getPrmInterface();
          StringList flds = r_prm.getFieldNames();
          for (int j = 0; j < flds.size(); j++) {
            String k = flds.get(j).toString();
            cntx.ta.setParamObject(cntx.id_task, "out." + k, r_prm.getField(k));
          }
        } finally {
          th.interrupt();
        }
      } finally {
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

           0x38, 0x30, 0x39, 0x37, 0x35, 0x30, 0x30, 0x33, 0x38, 0x31, 0x30, 0x30, 0x31,
           0x32, 0x39};
    msg.getOutputStream().write(res);
//*/
    msg.printStatusHeader();
    PrmInterface prm = msg.getPrmInterface();
    StringList flds = prm.getFieldNames();
    for (String fld : flds) {
      System.out.println(fld + " = " + prm.getField(fld));
    }
   
    msg.sendTo(System.out);
    System.out.println();
   
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

          } catch (IOException e) {
          }
          return null;
        }
        //System.out.println("Recived message:");
        PrmInterface prm;
        /*
        try {
          prm = msg.getPrmInterface();
          StringList names = prm.getFieldNames();
          for (int j = 0; j < names.size(); j++) {
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

      id_task = getTaskID();
      child = getChild();
    }

    public void processing(Object oprm) {
      PrmInterface prm;
      try {
        long id_processor = getProcessorID();
        prm = in.getPrmInterface();
        ArrayList<String> flds = prm.getFieldNames();
        for (String k : flds) {
          String v = prm.getField(k);
          Process.currentProcess().regResourceName(v, "msg." + k);
        }
        Context cntx = getContext();
        // Создать и подготовить для выполнения дочернюю задачу
        Context chld = child
            .createAndReadyTask(ta, cntx, id_processor, msg_grp_in, prm);

        need_reply = Strings.parseBooleanNvl(chld.getPrmByFullName("need_reply"), false);
        try {
          long wait = Strings.parseIntegerNvl(chld.getPrmByFullName("wait"), 120000);
          cntx.log(false, "Start waiting (", wait, ")");
          State r = chld.ta.waitFinished(chld.id_subject, chld.id_task, wait);
          cntx.log(false, "End waiting");
          need_reply = Strings.parseBooleanNvl(chld.getPrmByFullName("need_reply"), true);

          Map<String, Object> prms_out = chld.getGroupParams(msg_grp_out);
          Iterator<String> i = prms_out.keySet().iterator();
          prm = in.getPrmInterface();
          if ("true".equalsIgnoreCase(Strings.getString(chld.getPrmByFullName("clear"))))
            prm.clearFields();
          while (i.hasNext()) {
            String n = i.next();
            String[] fn = Context.getFullName(n);
            String o = Strings.getString(prms_out.get(n));
            //System.out.println("\t set " + n + " = " + o);
            prm.setField(fn[1], o);
//            ((ISO8583Msg)in).printStatusHeader();
          }
        } catch (SysException ex1) {
          ta.setTaskError(chld.id_task, ex1);
          chld.log(false, "The task was completed with errors");
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

    Socket s = null;
    try {
      Map<String, Object> prms = cntx.getGroupParams(msg_grp_in);
      ByteMsg msg = poolmsg.occupyOrNew();
      try {
        PrmInterface prmi = msg.getPrmInterface();
        for(Map.Entry<String, Object> prm : prms.entrySet()) {
          String key = prm.getKey();
          String[] fn = cntx.getFullName(key);
          prmi.setField(fn[1], Strings.getString(cntx.getPrmString(key)));
        }
        s = new Socket(host, port);
        msg.sendTo(s.getOutputStream());
      } finally {
        poolmsg.free(msg);
      }
      msg = poolmsg.getFactory().create();
      poolmsg.getFactory().initialization(msg);
      ReadMsg rm = new ReadMsg(msg);
      ByteMsg result;
      Process prc = null;
      try {
        synchronized(sync) {
          prc = prcs.occupyWait();
          prc.setTarget(rm);
          prc.setName("READ_MSG_" + cntx.id_task);
          prc.start(s.getInputStream());
          sync.wait(timeout);
          result = rm.getResultMsg();
          if (result == null) {
            prc.kill();
            throw new TaskException(State.DONE_TOUT, "Timeout of receiving message");
          }
        }
      } finally {
        prcs.free(prc);
      }
      PrmInterface prmi = result.getPrmInterface();
      StringList flds = prmi.getFieldNames();
      for (String fld : flds) {
        cntx.setPrmByFullName(msg_grp_out + "/" + fld, prmi.getField(fld), false);
      }
    } catch (UnknownHostException e) {
      throw new TaskException(State.DONE_ERR, e);
    } catch (IOException e) {
      throw new TaskException(State.DONE_ERR, e);
View Full Code Here

Examples of ru.vassaev.core.PrmInterface

      return st;
    Socket s = null;
    try {
      Map<String, Object> prms = cntx.getGroupParams(msg_grp_in);
      SAMsg q = new SAMsg();
      PrmInterface prmi;
      {
        prmi = q.getPrmInterface();
        for(Map.Entry<String, Object> prm : prms.entrySet()) {
          String key = prm.getKey();
          String[] fn = cntx.getFullName(key);
          prmi.setField(fn[1], Strings.getString(cntx.getPrmString(key)));
        }
      }
      s = new Socket(host, port);
      System.out.println("Opened link " + Sockets.getNameLink(s));
     
      InputStream is = s.getInputStream();
      OutputStream os = s.getOutputStream();
      SAMsg in = new SAMsg();
      SAMsg result = new SAMsg();
        int enq = is.read();
        System.out.print("<-- " + toHexString(enq));
        if (enq != SAMsg.ENQ)
          throw new TaskException(State.DONE_ERR, "Incorrect the first signal from host");
        q.sendTo(s.getOutputStream());
        System.out.print("\n-->");
        q.printTo(System.out);

        System.out.println();
        String v;
        for (String n : prmi.getFieldNames()) {
          v = prmi.getField(n);
          System.out.println(n + " = " + v);
        }

        int ch;
        PrmInterface inpi = in.getPrmInterface();
        CloseableOutputStream osc = in.getOutputStream();
        System.out.print("\n<--");
        boolean end = false;
        while (!end && (ch = is.read()) != -1) {
          System.out.print(" ");
          System.out.print(toHexString(ch));
          osc.write(ch);
          if (osc.isClosed()) {
            switch(Integer.parseInt(inpi.getField("type"))) {
            case  SAMsg.STX:
              System.out.println();
              PrmInterface rpi = result.getPrmInterface();
              for (String n : inpi.getFieldNames()) {
                v = inpi.getField(n);
                rpi.setField(n, v);
                System.out.println(n + " = " + v);
              }
              end = true;
              break;
            case  SAMsg.ACK:
              System.out.print("\n<--");
              break;
            case  SAMsg.ENQ:
              System.out.print("\n<--");
              break;
            default:
              System.out.print("\n<--");
              throw new TaskException(State.DONE_ERR, "Incorrect response from host");
            }
            in.reset();
            osc = in.getOutputStream();
          }
        }
       
        os.write(SAMsg.ACK);
        System.out.print("\n--> " + toHexString(SAMsg.ACK));
        os.write(SAMsg.EOT);
        System.out.println("\n--> " + toHexString(SAMsg.EOT));

      PrmInterface rpi = result.getPrmInterface();
      StringList flds = rpi.getFieldNames();
      for (String fld : flds) {
        cntx.setPrmByFullName(msg_grp_out + "/" + fld, rpi.getField(fld), false);
      }
    } catch (UnknownHostException e) {
      throw new TaskException(State.DONE_ERR, e);
    } catch (IOException e) {
      throw new TaskException(State.DONE_ERR, e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.