userflowcontroller.cpp
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 
15 #include "userflowcontroller.h"
16 //---------------------------------------------------------------------------
17 
18 REGISTER_TYPE(XDriverList, FCST1000, "Fujikin FCST1000 Series Mass Flow Controllers");
19 
20 XFCST1000::XFCST1000(const char *name, bool runtime,
21  Transaction &tr_meas, const shared_ptr<XMeasure> &meas) :
22  XFujikinProtocolDriver<XFlowControllerDriver>(name, runtime, ref(tr_meas), meas) {
23  interface()->setSerialBaudRate(38400);
24  interface()->setSerialStopBits(1);
25  interface()->setSerialParity(XCharInterface::PARITY_NONE);
26 }
27 bool
29  XString unit = interface()->query<XString>(GasCalibrationClass, 1, 0x03);
30  return (unit == "SLM");
31 }
32 bool
33 XFCST1000::isController() {
34  unsigned int type = interface()->query<uint8_t>(ValveDriverClass, 1, 0xa0);
35  if(type >= 3)
36  throw XInterface::XInterfaceError(i18n("Unknown valve type."), __FILE__, __LINE__);
37  return (type != 0);
38 }
39 double
41  return interface()->query<uint16_t>(GasCalibrationClass, 1, 0x02) * 0.1;
42 }
43 void
44 XFCST1000::getStatus(double &flow, double &valve_v, bool &alarm, bool &warning) {
45  XScopedLock<XInterface> lock( *interface());
46  flow = interface()->query<uint16_t>(ValveDriverClass, 1, 0xa9);
47  flow = (flow - 0x4000) / 0x8000;
48  flow *= getFullScale();
49  valve_v = interface()->query<uint16_t>(ValveDriverClass, 1, 0xb6);
50  valve_v = (valve_v - 0x4000) / 0x8000 * 100.0;
51 
52  int bits = interface()->query<uint8_t>(ExceptionClass, 1, 0xa0);
53  alarm = bits & 2;
54  warning = bits & 32;
55 }
56 void
57 XFCST1000::setValveState(bool open) {
58  interface()->send(ValveDriverClass, 1, 0x01, open ? (uint8_t)0x02 : (uint8_t)0x01);
59 }
60 void
61 XFCST1000::changeControl(bool ctrl) {
62  XScopedLock<XInterface> lock( *interface());
63  interface()->send(ValveDriverClass, 1, 0x01, (uint8_t)0x00); //MFC
64  if(ctrl) {
65  interface()->send(FlowControllerClass, 1, 0x03, (uint8_t)0x01); //digital mode.
66  interface()->send(FlowControllerClass, 1, 0x05, (uint8_t)0x01); //freeze follow.
67  }
68  else
69  interface()->send(FlowControllerClass, 1, 0x03, (uint8_t)0x02); //analog mode.
70 }
71 void
72 XFCST1000::changeSetPoint(double target) {
73  XScopedLock<XInterface> lock( *interface());
74  interface()->send(ValveDriverClass, 1, 0x01, (uint8_t)0x00); //MFC
75  target = target / getFullScale();
76  target = std::max(0.0, target);
77  target = std::min(1.0, target);
78  uint16_t x = lrint(target * 0x8000 + 0x4000);
79  interface()->send(FlowControllerClass, 1, 0xa4, x);
80 }
81 void
82 XFCST1000::setRampTime(double time) {
83  interface()->send(ValveDriverClass, 1, 0xa4, (uint32_t)lrint(time));
84 }

Generated for KAME4 by  doxygen 1.8.3