Index: /branches/LinuxBasicFEPClient/DataPacker.h
===================================================================
--- /branches/LinuxBasicFEPClient/DataPacker.h	(revision 154)
+++ /branches/LinuxBasicFEPClient/DataPacker.h	(revision 154)
@@ -0,0 +1,47 @@
+/* 
+ * File:   DataPacker.h
+ *
+ * DataPacker has a single static public method packData(..) that returns the
+ * packed data message that is sent to the ATMS Server in the fep_reply struct
+ * via RPC.
+ * 
+ * @author John A. Torres
+ * @version 9/8/2017
+ */
+
+#ifndef DATAPACKER_H
+#define	DATAPACKER_H
+
+// Include dependencies
+#include "network.h"
+#include <iostream>
+#include <string.h>
+
+class DataPacker {
+    
+public:
+    /**
+     * Returns packed data message to be sent to ATMS Server in fep_reply via RPC
+     * 
+     * @param station The station for which the message is to be made
+     * @return The packed data message
+     */
+    static unsigned char * packData(STATION *station);
+
+private:
+    static unsigned char *msg;
+    // Packs the static data in message sent to ATMS
+    unsigned char * staticDataPack(STATION *station);
+    // Packs dynamic data in message sent to ATMS
+    int dynamicDataPack(STATION *station, int packNo, int pos);
+    // Sets last byte of message
+    char chksum(unsigned char *dataptr, int len);
+    // Tells whether or not data is available for specified lane
+    bool DataAvail(char flag, int num);
+    // Helper function: packs vol and occ into two byte data packet
+    VOLOCC packVOLOCC(int vol, int occ);
+
+};
+
+#endif	/* DATAPACKER_H */
+
Index: /branches/LinuxBasicFEPClient/network_factory.h
===================================================================
--- /branches/LinuxBasicFEPClient/network_factory.h	(revision 154)
+++ /branches/LinuxBasicFEPClient/network_factory.h	(revision 154)
@@ -0,0 +1,28 @@
+/* 
+ * File:   network_factory.h
+ * Author: jtorres
+ *
+ * Created on October 18, 2017, 8:36 AM
+ */
+
+#ifndef NETWORK_FACTORY_H
+#define	NETWORK_FACTORY_H
+
+#include "network.h"
+
+class NetworkFactory
+{
+public:
+    bool DataAvail(char flag, int num);
+    void init_loop_dataPack(STATION *loop);
+    FEP_LINE * load_lines(int *size, const char * fName);
+    STATION * load_lds(const char * fName);
+
+
+private:
+    
+};
+
+
+#endif	/* NETWORK_FACTORY_H */
+
Index: /branches/LinuxBasicFEPClient/fep_xdr.c
===================================================================
--- /branches/LinuxBasicFEPClient/fep_xdr.c	(revision 154)
+++ /branches/LinuxBasicFEPClient/fep_xdr.c	(revision 154)
@@ -0,0 +1,1329 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "fep.h"
+/* RPC XDR test */
+/* RPC XDR Modifications */
+#undef MAXSHORTMESSAGELEN
+#undef MAXLONGMESSAGELEN
+#undef MAXSHORTPOLLS
+#undef MAXLONGPOLLS
+#undef MAXPOLLRETRY
+#undef MAXSHORTREPLYLEN
+#undef MAXLONGREPLYLEN
+#define MAXSHORTMESSAGELEN (objp->message_len?((objp->message_len>_MAXSHORTMESSAGELEN) ?_MAXSHORTMESSAGELEN:objp->message_len) :1)
+#define MAXLONGMESSAGELEN (objp->message_len?((objp->message_len>_MAXLONGMESSAGELEN) ?_MAXLONGMESSAGELEN:objp->message_len) :1)
+#define MAXSHORTPOLLS (objp->count? ((objp->count>_MAXSHORTPOLLS) ?_MAXSHORTPOLLS:objp->count) :1)
+#define MAXLONGPOLLS (objp->count? ((objp->count>_MAXLONGPOLLS) ?_MAXLONGPOLLS:objp->count) :1)
+#define MAXPOLLRETRY (objp->poll_error_count? ((objp->poll_error_count>_MAXPOLLRETRY) ?_MAXPOLLRETRY:objp->poll_error_count) :1)
+#define MAXSHORTREPLYLEN (objp->message_len? ((objp->message_len>_MAXSHORTREPLYLEN)?_MAXSHORTREPLYLEN:objp->message_len) :1)
+#define MAXLONGREPLYLEN (objp->message_len? ((objp->message_len>_MAXLONGREPLYLEN) ?_MAXLONGREPLYLEN:objp->message_len) :1)
+
+bool_t
+xdr_errorstatus (XDR *xdrs, errorstatus *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_Polling_FSM_States (XDR *xdrs, Polling_FSM_States *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_lineinfo (XDR *xdrs, fep_lineinfo *objp)
+{
+	register int32_t *buf;
+
+	int i;
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		 if (!xdr_int (xdrs, &objp->lineinfo))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->device, MAXDEVLEN))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 7 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->poll))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->command))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->sync))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->line_error_count))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->pid))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->semaphore))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->debug))
+				 return FALSE;
+		} else {
+			IXDR_PUT_LONG(buf, objp->poll);
+			IXDR_PUT_LONG(buf, objp->command);
+			IXDR_PUT_LONG(buf, objp->sync);
+			IXDR_PUT_LONG(buf, objp->line_error_count);
+			IXDR_PUT_LONG(buf, objp->pid);
+			IXDR_PUT_LONG(buf, objp->semaphore);
+			IXDR_PUT_LONG(buf, objp->debug);
+		}
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		 if (!xdr_int (xdrs, &objp->lineinfo))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->device, MAXDEVLEN))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 7 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->poll))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->command))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->sync))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->line_error_count))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->pid))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->semaphore))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->debug))
+				 return FALSE;
+		} else {
+			objp->poll = IXDR_GET_LONG(buf);
+			objp->command = IXDR_GET_LONG(buf);
+			objp->sync = IXDR_GET_LONG(buf);
+			objp->line_error_count = IXDR_GET_LONG(buf);
+			objp->pid = IXDR_GET_LONG(buf);
+			objp->semaphore = IXDR_GET_LONG(buf);
+			objp->debug = IXDR_GET_LONG(buf);
+		}
+	 return TRUE;
+	}
+
+	 if (!xdr_int (xdrs, &objp->lineinfo))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->device, MAXDEVLEN))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->command))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->sync))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->line_error_count))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->pid))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->semaphore))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->debug))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_lineinfo_ret (XDR *xdrs, lineinfo_ret *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_errorstatus (xdrs, &objp->status))
+		 return FALSE;
+	switch (objp->status) {
+	case FEP_OK:
+		 if (!xdr_fep_lineinfo (xdrs, &objp->lineinfo_ret_u.info))
+			 return FALSE;
+		break;
+	default:
+		break;
+	}
+	return TRUE;
+}
+
+bool_t
+xdr_fep_std_time (XDR *xdrs, fep_std_time *objp)
+{
+	register int32_t *buf;
+
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		buf = XDR_INLINE (xdrs, 7 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->year))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->month))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->day))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->hour))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->minute))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->second))
+				 return FALSE;
+			 if (!xdr_long (xdrs, &objp->time_t))
+				 return FALSE;
+		} else {
+			IXDR_PUT_LONG(buf, objp->year);
+			IXDR_PUT_LONG(buf, objp->month);
+			IXDR_PUT_LONG(buf, objp->day);
+			IXDR_PUT_LONG(buf, objp->hour);
+			IXDR_PUT_LONG(buf, objp->minute);
+			IXDR_PUT_LONG(buf, objp->second);
+			IXDR_PUT_LONG(buf, objp->time_t);
+		}
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		buf = XDR_INLINE (xdrs, 7 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->year))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->month))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->day))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->hour))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->minute))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->second))
+				 return FALSE;
+			 if (!xdr_long (xdrs, &objp->time_t))
+				 return FALSE;
+		} else {
+			objp->year = IXDR_GET_LONG(buf);
+			objp->month = IXDR_GET_LONG(buf);
+			objp->day = IXDR_GET_LONG(buf);
+			objp->hour = IXDR_GET_LONG(buf);
+			objp->minute = IXDR_GET_LONG(buf);
+			objp->second = IXDR_GET_LONG(buf);
+			objp->time_t = IXDR_GET_LONG(buf);
+		}
+	 return TRUE;
+	}
+
+	 if (!xdr_int (xdrs, &objp->year))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->month))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->day))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->hour))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->minute))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->second))
+		 return FALSE;
+	 if (!xdr_long (xdrs, &objp->time_t))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_std_time_ret (XDR *xdrs, std_time_ret *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_errorstatus (xdrs, &objp->status))
+		 return FALSE;
+	switch (objp->status) {
+	case FEP_OK:
+		 if (!xdr_fep_std_time (xdrs, &objp->std_time_ret_u.info))
+			 return FALSE;
+		break;
+	default:
+		break;
+	}
+	return TRUE;
+}
+
+bool_t
+xdr_protocoltype (XDR *xdrs, protocoltype *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_duplex (XDR *xdrs, duplex *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_poll_info (XDR *xdrs, fep_poll_info *objp)
+{
+	register int32_t *buf;
+
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		 if (!xdr_int (xdrs, &objp->D7_update))
+			 return FALSE;
+		 if (!xdr_protocoltype (xdrs, &objp->protocol))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 14 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->poll_user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->format))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->speed))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->mode))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->min_separation))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->delay_rts_on))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->max_send))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->delay_rts_off))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->max_reply))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->min_error))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->max_retry))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->reply_len))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_error_count))
+				 return FALSE;
+		} else {
+			IXDR_PUT_LONG(buf, objp->poll_user_info1);
+			IXDR_PUT_LONG(buf, objp->poll_user_info2);
+			IXDR_PUT_LONG(buf, objp->format);
+			IXDR_PUT_LONG(buf, objp->speed);
+			IXDR_PUT_LONG(buf, objp->mode);
+			IXDR_PUT_LONG(buf, objp->min_separation);
+			IXDR_PUT_LONG(buf, objp->delay_rts_on);
+			IXDR_PUT_LONG(buf, objp->max_send);
+			IXDR_PUT_LONG(buf, objp->delay_rts_off);
+			IXDR_PUT_LONG(buf, objp->max_reply);
+			IXDR_PUT_LONG(buf, objp->min_error);
+			IXDR_PUT_LONG(buf, objp->max_retry);
+			IXDR_PUT_LONG(buf, objp->reply_len);
+			IXDR_PUT_LONG(buf, objp->poll_error_count);
+		}
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		 if (!xdr_int (xdrs, &objp->D7_update))
+			 return FALSE;
+		 if (!xdr_protocoltype (xdrs, &objp->protocol))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 14 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->poll_user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->format))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->speed))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->mode))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->min_separation))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->delay_rts_on))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->max_send))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->delay_rts_off))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->max_reply))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->min_error))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->max_retry))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->reply_len))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_error_count))
+				 return FALSE;
+		} else {
+			objp->poll_user_info1 = IXDR_GET_LONG(buf);
+			objp->poll_user_info2 = IXDR_GET_LONG(buf);
+			objp->format = IXDR_GET_LONG(buf);
+			objp->speed = IXDR_GET_LONG(buf);
+			objp->mode = IXDR_GET_LONG(buf);
+			objp->min_separation = IXDR_GET_LONG(buf);
+			objp->delay_rts_on = IXDR_GET_LONG(buf);
+			objp->max_send = IXDR_GET_LONG(buf);
+			objp->delay_rts_off = IXDR_GET_LONG(buf);
+			objp->max_reply = IXDR_GET_LONG(buf);
+			objp->min_error = IXDR_GET_LONG(buf);
+			objp->max_retry = IXDR_GET_LONG(buf);
+			objp->reply_len = IXDR_GET_LONG(buf);
+			objp->poll_error_count = IXDR_GET_LONG(buf);
+		}
+	 return TRUE;
+	}
+
+	 if (!xdr_int (xdrs, &objp->D7_update))
+		 return FALSE;
+	 if (!xdr_protocoltype (xdrs, &objp->protocol))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll_user_info1))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll_user_info2))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->format))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->speed))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->mode))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->min_separation))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->delay_rts_on))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->max_send))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->delay_rts_off))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->max_reply))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->min_error))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->max_retry))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->reply_len))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll_error_count))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_poll_short_msg (XDR *xdrs, fep_poll_short_msg *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->message_len))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->message, MAXSHORTMESSAGELEN))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_shortpoll (XDR *xdrs, fep_shortpoll *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_fep_poll_info (xdrs, &objp->info))
+		 return FALSE;
+	 if (!xdr_fep_poll_short_msg (xdrs, &objp->msg))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_shortpoll_list (XDR *xdrs, fep_shortpoll_list *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->count))
+		 return FALSE;
+	 if (!xdr_vector (xdrs, (char *)objp->polls, MAXSHORTPOLLS,
+		sizeof (fep_shortpoll), (xdrproc_t) xdr_fep_shortpoll))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_poll_long_msg (XDR *xdrs, fep_poll_long_msg *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->message_len))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->message, MAXLONGMESSAGELEN))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_longpoll (XDR *xdrs, fep_longpoll *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_fep_poll_info (xdrs, &objp->info))
+		 return FALSE;
+	 if (!xdr_fep_poll_long_msg (xdrs, &objp->msg))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_longpoll_list (XDR *xdrs, fep_longpoll_list *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->count))
+		 return FALSE;
+	 if (!xdr_vector (xdrs, (char *)objp->polls, MAXLONGPOLLS,
+		sizeof (fep_longpoll), (xdrproc_t) xdr_fep_longpoll))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_poll_length (XDR *xdrs, poll_length *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_poll_list (XDR *xdrs, fep_poll_list *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_int (xdrs, &objp->size))
+		 return FALSE;
+	switch (objp->size) {
+	case SHORTPOLL:
+		 if (!xdr_fep_shortpoll_list (xdrs, &objp->fep_poll_list_u.shortp))
+			 return FALSE;
+		break;
+	case LONGPOLL:
+		 if (!xdr_fep_longpoll_list (xdrs, &objp->fep_poll_list_u.longp))
+			 return FALSE;
+		break;
+	default:
+		return FALSE;
+	}
+	return TRUE;
+}
+
+bool_t
+xdr_polltype (XDR *xdrs, polltype *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_commandtype (XDR *xdrs, commandtype *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_schedulestatus (XDR *xdrs, schedulestatus *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_schedule (XDR *xdrs, fep_schedule *objp)
+{
+	register int32_t *buf;
+
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		 if (!xdr_int (xdrs, &objp->schedule))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->lineinfo))
+			 return FALSE;
+		 if (!xdr_polltype (xdrs, &objp->kind))
+			 return FALSE;
+		 if (!xdr_commandtype (xdrs, &objp->priority))
+			 return FALSE;
+		 if (!xdr_protocoltype (xdrs, &objp->protocol))
+			 return FALSE;
+		 if (!xdr_fep_std_time (xdrs, &objp->time))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 11 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->interval))
+				 return FALSE;
+			 if (!xdr_long (xdrs, &objp->at_time))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->system_key))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->next))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->previous))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->report))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->sequence))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->status))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->retry))
+				 return FALSE;
+
+		} else {
+		IXDR_PUT_LONG(buf, objp->interval);
+		IXDR_PUT_LONG(buf, objp->at_time);
+		IXDR_PUT_LONG(buf, objp->user_info1);
+		IXDR_PUT_LONG(buf, objp->user_info2);
+		IXDR_PUT_LONG(buf, objp->system_key);
+		IXDR_PUT_LONG(buf, objp->next);
+		IXDR_PUT_LONG(buf, objp->previous);
+		IXDR_PUT_LONG(buf, objp->report);
+		IXDR_PUT_LONG(buf, objp->sequence);
+		IXDR_PUT_LONG(buf, objp->status);
+		IXDR_PUT_LONG(buf, objp->retry);
+		}
+		 if (!xdr_fep_poll_list (xdrs, &objp->fep_polls))
+			 return FALSE;
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		 if (!xdr_int (xdrs, &objp->schedule))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->lineinfo))
+			 return FALSE;
+		 if (!xdr_polltype (xdrs, &objp->kind))
+			 return FALSE;
+		 if (!xdr_commandtype (xdrs, &objp->priority))
+			 return FALSE;
+		 if (!xdr_protocoltype (xdrs, &objp->protocol))
+			 return FALSE;
+		 if (!xdr_fep_std_time (xdrs, &objp->time))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 11 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->interval))
+				 return FALSE;
+			 if (!xdr_long (xdrs, &objp->at_time))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->system_key))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->next))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->previous))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->report))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->sequence))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->status))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->retry))
+				 return FALSE;
+
+		} else {
+		objp->interval = IXDR_GET_LONG(buf);
+		objp->at_time = IXDR_GET_LONG(buf);
+		objp->user_info1 = IXDR_GET_LONG(buf);
+		objp->user_info2 = IXDR_GET_LONG(buf);
+		objp->system_key = IXDR_GET_LONG(buf);
+		objp->next = IXDR_GET_LONG(buf);
+		objp->previous = IXDR_GET_LONG(buf);
+		objp->report = IXDR_GET_LONG(buf);
+		objp->sequence = IXDR_GET_LONG(buf);
+		objp->status = IXDR_GET_LONG(buf);
+		objp->retry = IXDR_GET_LONG(buf);
+		}
+		 if (!xdr_fep_poll_list (xdrs, &objp->fep_polls))
+			 return FALSE;
+	 return TRUE;
+	}
+
+	 if (!xdr_int (xdrs, &objp->schedule))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->lineinfo))
+		 return FALSE;
+	 if (!xdr_polltype (xdrs, &objp->kind))
+		 return FALSE;
+	 if (!xdr_commandtype (xdrs, &objp->priority))
+		 return FALSE;
+	 if (!xdr_protocoltype (xdrs, &objp->protocol))
+		 return FALSE;
+	 if (!xdr_fep_std_time (xdrs, &objp->time))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->interval))
+		 return FALSE;
+	 if (!xdr_long (xdrs, &objp->at_time))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->user_info1))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->user_info2))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->system_key))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->next))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->previous))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->report))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->sequence))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->status))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->retry))
+		 return FALSE;
+	 if (!xdr_fep_poll_list (xdrs, &objp->fep_polls))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_answererror (XDR *xdrs, answererror *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_pollerror (XDR *xdrs, fep_pollerror *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_answererror (xdrs, &objp->msgerror))
+		 return FALSE;
+	 if (!xdr_Polling_FSM_States (xdrs, &objp->state))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->perrno))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->termination))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->count))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_replystatus (XDR *xdrs, replystatus *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_answer_info (XDR *xdrs, fep_answer_info *objp)
+{
+	register int32_t *buf;
+
+	int i;
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		 if (!xdr_long (xdrs, &objp->poll_time))
+			 return FALSE;
+		 if (!xdr_replystatus (xdrs, &objp->status))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->poll_user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->retries))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_error_count))
+				 return FALSE;
+
+		} else {
+		IXDR_PUT_LONG(buf, objp->poll_user_info1);
+		IXDR_PUT_LONG(buf, objp->poll_user_info2);
+		IXDR_PUT_LONG(buf, objp->retries);
+		IXDR_PUT_LONG(buf, objp->poll_error_count);
+		}
+		 if (!xdr_vector (xdrs, (char *)objp->pollerror, MAXPOLLRETRY,
+			sizeof (fep_pollerror), (xdrproc_t) xdr_fep_pollerror))
+			 return FALSE;
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		 if (!xdr_long (xdrs, &objp->poll_time))
+			 return FALSE;
+		 if (!xdr_replystatus (xdrs, &objp->status))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->poll_user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->retries))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->poll_error_count))
+				 return FALSE;
+
+		} else {
+		objp->poll_user_info1 = IXDR_GET_LONG(buf);
+		objp->poll_user_info2 = IXDR_GET_LONG(buf);
+		objp->retries = IXDR_GET_LONG(buf);
+		objp->poll_error_count = IXDR_GET_LONG(buf);
+		}
+		 if (!xdr_vector (xdrs, (char *)objp->pollerror, MAXPOLLRETRY,
+			sizeof (fep_pollerror), (xdrproc_t) xdr_fep_pollerror))
+			 return FALSE;
+	 return TRUE;
+	}
+
+	 if (!xdr_long (xdrs, &objp->poll_time))
+		 return FALSE;
+	 if (!xdr_replystatus (xdrs, &objp->status))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll_user_info1))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll_user_info2))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->retries))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->poll_error_count))
+		 return FALSE;
+	 if (!xdr_vector (xdrs, (char *)objp->pollerror, MAXPOLLRETRY,
+		sizeof (fep_pollerror), (xdrproc_t) xdr_fep_pollerror))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_answer_short_msg (XDR *xdrs, fep_answer_short_msg *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->message_len))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->message, MAXSHORTREPLYLEN))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_shortanswer (XDR *xdrs, fep_shortanswer *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_fep_answer_info (xdrs, &objp->info))
+		 return FALSE;
+	 if (!xdr_fep_answer_short_msg (xdrs, &objp->msg))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_shortanswer_list (XDR *xdrs, fep_shortanswer_list *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->count))
+		 return FALSE;
+	 if (!xdr_vector (xdrs, (char *)objp->answers, MAXSHORTPOLLS,
+		sizeof (fep_shortanswer), (xdrproc_t) xdr_fep_shortanswer))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_answer_long_msg (XDR *xdrs, fep_answer_long_msg *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->message_len))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->message, MAXLONGREPLYLEN))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_longanswer (XDR *xdrs, fep_longanswer *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_fep_answer_info (xdrs, &objp->info))
+		 return FALSE;
+	 if (!xdr_fep_answer_long_msg (xdrs, &objp->msg))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_longanswer_list (XDR *xdrs, fep_longanswer_list *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_int (xdrs, &objp->count))
+		 return FALSE;
+	 if (!xdr_vector (xdrs, (char *)objp->answers, MAXLONGPOLLS,
+		sizeof (fep_longanswer), (xdrproc_t) xdr_fep_longanswer))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_answer_list (XDR *xdrs, fep_answer_list *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_int (xdrs, &objp->size))
+		 return FALSE;
+	switch (objp->size) {
+	case SHORTPOLL:
+		 if (!xdr_fep_shortanswer_list (xdrs, &objp->fep_answer_list_u.shortp))
+			 return FALSE;
+		break;
+	case LONGPOLL:
+		 if (!xdr_fep_longanswer_list (xdrs, &objp->fep_answer_list_u.longp))
+			 return FALSE;
+		break;
+	default:
+		return FALSE;
+	}
+	return TRUE;
+}
+
+bool_t
+xdr_replykind (XDR *xdrs, replykind *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_reply (XDR *xdrs, fep_reply *objp)
+{
+	register int32_t *buf;
+
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->reply))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->schedule))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->lineinfo))
+				 return FALSE;
+
+		} else {
+		IXDR_PUT_LONG(buf, objp->reply);
+		IXDR_PUT_LONG(buf, objp->schedule);
+		IXDR_PUT_LONG(buf, objp->lineinfo);
+		}
+		 if (!xdr_polltype (xdrs, &objp->kind))
+			 return FALSE;
+		 if (!xdr_replykind (xdrs, &objp->flag))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->schedule_sequence))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->global_sequence))
+				 return FALSE;
+			 if (!xdr_long (xdrs, &objp->schedule_time))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->system_key))
+				 return FALSE;
+
+		} else {
+		IXDR_PUT_LONG(buf, objp->schedule_sequence);
+		IXDR_PUT_LONG(buf, objp->global_sequence);
+		IXDR_PUT_LONG(buf, objp->schedule_time);
+		IXDR_PUT_LONG(buf, objp->user_info1);
+		IXDR_PUT_LONG(buf, objp->user_info2);
+		IXDR_PUT_LONG(buf, objp->system_key);
+		}
+		 if (!xdr_fep_answer_list (xdrs, &objp->answers))
+			 return FALSE;
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->reply))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->schedule))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->lineinfo))
+				 return FALSE;
+
+		} else {
+		objp->reply = IXDR_GET_LONG(buf);
+		objp->schedule = IXDR_GET_LONG(buf);
+		objp->lineinfo = IXDR_GET_LONG(buf);
+		}
+		 if (!xdr_polltype (xdrs, &objp->kind))
+			 return FALSE;
+		 if (!xdr_replykind (xdrs, &objp->flag))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->schedule_sequence))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->global_sequence))
+				 return FALSE;
+			 if (!xdr_long (xdrs, &objp->schedule_time))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info1))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->user_info2))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->system_key))
+				 return FALSE;
+
+		} else {
+		objp->schedule_sequence = IXDR_GET_LONG(buf);
+		objp->global_sequence = IXDR_GET_LONG(buf);
+		objp->schedule_time = IXDR_GET_LONG(buf);
+		objp->user_info1 = IXDR_GET_LONG(buf);
+		objp->user_info2 = IXDR_GET_LONG(buf);
+		objp->system_key = IXDR_GET_LONG(buf);
+		}
+		 if (!xdr_fep_answer_list (xdrs, &objp->answers))
+			 return FALSE;
+	 return TRUE;
+	}
+
+	 if (!xdr_int (xdrs, &objp->reply))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->schedule))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->lineinfo))
+		 return FALSE;
+	 if (!xdr_polltype (xdrs, &objp->kind))
+		 return FALSE;
+	 if (!xdr_replykind (xdrs, &objp->flag))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->schedule_sequence))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->global_sequence))
+		 return FALSE;
+	 if (!xdr_long (xdrs, &objp->schedule_time))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->user_info1))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->user_info2))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->system_key))
+		 return FALSE;
+	 if (!xdr_fep_answer_list (xdrs, &objp->answers))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_schedule_ret (XDR *xdrs, schedule_ret *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_errorstatus (xdrs, &objp->status))
+		 return FALSE;
+	switch (objp->status) {
+	case FEP_OK:
+		 if (!xdr_fep_schedule (xdrs, &objp->schedule_ret_u.info))
+			 return FALSE;
+		break;
+	default:
+		break;
+	}
+	return TRUE;
+}
+
+bool_t
+xdr_fep_reply_request (XDR *xdrs, fep_reply_request *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_int (xdrs, &objp->schedule))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->sequence))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->block))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_reply_ret (XDR *xdrs, reply_ret *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_errorstatus (xdrs, &objp->status))
+		 return FALSE;
+	switch (objp->status) {
+	case FEP_OK:
+		 if (!xdr_fep_reply (xdrs, &objp->reply_ret_u.info))
+			 return FALSE;
+		break;
+	default:
+		break;
+	}
+	return TRUE;
+}
+
+bool_t
+xdr_init_form (XDR *xdrs, init_form *objp)
+{
+	register int32_t *buf;
+
+	int i;
+	 if (!xdr_vector (xdrs, (char *)objp->host, 10,
+		sizeof (char), (xdrproc_t) xdr_char))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->config))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_setschedule (XDR *xdrs, fep_setschedule *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_int (xdrs, &objp->lineinfo))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->schedule))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->debug))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_statusflags (XDR *xdrs, statusflags *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_lineop (XDR *xdrs, fep_lineop *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_int (xdrs, &objp->lineinfo))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->flags))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->modem_signals))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_ipprotocol (XDR *xdrs, ipprotocol *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_action (XDR *xdrs, action *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_portstatus (XDR *xdrs, portstatus *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_enum (xdrs, (enum_t *) objp))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_fep_report (XDR *xdrs, fep_report *objp)
+{
+	register int32_t *buf;
+
+	int i;
+
+	if (xdrs->x_op == XDR_ENCODE) {
+		 if (!xdr_int (xdrs, &objp->report))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->dest, MAXADDRLEN))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->logfile, MAXADDRLEN))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->monitor, MAXADDRLEN))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->port))
+			 return FALSE;
+		 if (!xdr_ipprotocol (xdrs, &objp->protocol))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->update))
+			 return FALSE;
+		 if (!xdr_action (xdrs, &objp->action))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->reconnect))
+			 return FALSE;
+		 if (!xdr_portstatus (xdrs, &objp->status))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->perrno))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->debug))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->pid))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->semaphore))
+				 return FALSE;
+		} else {
+			IXDR_PUT_LONG(buf, objp->perrno);
+			IXDR_PUT_LONG(buf, objp->debug);
+			IXDR_PUT_LONG(buf, objp->pid);
+			IXDR_PUT_LONG(buf, objp->semaphore);
+		}
+		return TRUE;
+	} else if (xdrs->x_op == XDR_DECODE) {
+		 if (!xdr_int (xdrs, &objp->report))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->dest, MAXADDRLEN))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->logfile, MAXADDRLEN))
+			 return FALSE;
+		 if (!xdr_opaque (xdrs, objp->monitor, MAXADDRLEN))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->port))
+			 return FALSE;
+		 if (!xdr_ipprotocol (xdrs, &objp->protocol))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->update))
+			 return FALSE;
+		 if (!xdr_action (xdrs, &objp->action))
+			 return FALSE;
+		 if (!xdr_int (xdrs, &objp->reconnect))
+			 return FALSE;
+		 if (!xdr_portstatus (xdrs, &objp->status))
+			 return FALSE;
+		buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+		if (buf == NULL) {
+			 if (!xdr_int (xdrs, &objp->perrno))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->debug))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->pid))
+				 return FALSE;
+			 if (!xdr_int (xdrs, &objp->semaphore))
+				 return FALSE;
+		} else {
+			objp->perrno = IXDR_GET_LONG(buf);
+			objp->debug = IXDR_GET_LONG(buf);
+			objp->pid = IXDR_GET_LONG(buf);
+			objp->semaphore = IXDR_GET_LONG(buf);
+		}
+	 return TRUE;
+	}
+
+	 if (!xdr_int (xdrs, &objp->report))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->dest, MAXADDRLEN))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->logfile, MAXADDRLEN))
+		 return FALSE;
+	 if (!xdr_opaque (xdrs, objp->monitor, MAXADDRLEN))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->port))
+		 return FALSE;
+	 if (!xdr_ipprotocol (xdrs, &objp->protocol))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->update))
+		 return FALSE;
+	 if (!xdr_action (xdrs, &objp->action))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->reconnect))
+		 return FALSE;
+	 if (!xdr_portstatus (xdrs, &objp->status))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->perrno))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->debug))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->pid))
+		 return FALSE;
+	 if (!xdr_int (xdrs, &objp->semaphore))
+		 return FALSE;
+	return TRUE;
+}
+
+bool_t
+xdr_report_ret (XDR *xdrs, report_ret *objp)
+{
+	register int32_t *buf;
+
+	 if (!xdr_errorstatus (xdrs, &objp->status))
+		 return FALSE;
+	switch (objp->status) {
+	case FEP_OK:
+		 if (!xdr_fep_report (xdrs, &objp->report_ret_u.info))
+			 return FALSE;
+		break;
+	default:
+		break;
+	}
+	return TRUE;
+}
Index: /branches/LinuxBasicFEPClient/fep_client.cpp
===================================================================
--- /branches/LinuxBasicFEPClient/fep_client.cpp	(revision 154)
+++ /branches/LinuxBasicFEPClient/fep_client.cpp	(revision 154)
@@ -0,0 +1,176 @@
+#include "fep.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "time.h"
+#include "network_factory.h"
+#include "DataPacker.h"
+/* Author: John A. Torres
+   The fep_program_32 function creates a new RPC Client which
+   sends an fep_reply structure to the ATMS Server. After the
+   reply is sent, the ATMS Sends a response and the RPC Client
+   is destroyed.
+ */
+
+/* Handles the ATMS's response to RPC Call */
+void handle_ATMS_response(CLIENT *clnt, void *response)
+{
+	/* If ATMS reply call fails */
+	if (response == NULL)
+	{
+		clnt_perror(clnt, "RPC call failed");
+	}
+	/* If ATMS reply is successful */
+	else
+	{
+		printf("Successful RPC call to ATMS...\n");
+	}
+}
+
+void xfer_replys(CLIENT *clnt, FEP_LINE *lines, int lines_size, STATION *ldsMap)
+{
+	int i, j; // i == line_index, j == lds_index
+	void *rv;
+
+	// Send one reply for every "line" in the FEP
+	for (i = 0; i < lines_size; i++)
+	{
+		fep_reply  fepReply;
+		
+		// populate reply
+		fepReply.reply = SHORTPOLL;
+		fepReply.schedule = lines[i].schedule;
+		fepReply.lineinfo = lines[i].lineInfo;
+		fepReply.kind = (enum polltype) 0;
+		fepReply.flag = (enum replykind) 0;
+		
+		/***********************************
+			 This is an update to an extern, this should happen on the Java driver side?? 
+		lines[i].schedleSeq += 1;
+		lines[i].globalSeq += 51;
+		*/
+
+		fepReply.schedule_sequence = lines[i].schedleSeq;
+		fepReply.global_sequence = lines[i].globalSeq;
+		/************************************
+			 Need to find out what appropriate schedule time is: look at uci_unix_simulation_time src code		
+		fepReply.schedule_time = 
+			uci_unix_simulation_time(uci_simulation_time());	// GMT time
+		*/
+		fepReply.schedule_time = time(NULL);
+
+		fepReply.user_info1 = lines[i].lineNum;
+		fepReply.user_info2 = lines[i].lineNum;
+		fepReply.system_key = lines[i].systemKey;
+
+		fepReply.answers.size = 1;
+		fepReply.answers.fep_answer_list_u.shortp.count = 1;
+		
+		/* for each LDS in the Line.... (constructs the short_answer message) */
+		for (j = 0; j < lines[i].lds.size(); j++)
+		{
+			fep_shortanswer fsa;
+			int index = lines[i].ldsIndex[j];
+
+			// msg: oa, od, ldsMap[index].dataPack, od, ff
+			fsa.msg.message_len = ldsMap[index].length + 2;
+			fsa.msg.message[0] = 0x0d;
+			fsa.msg.message[1] = 0x0a;
+			for (int k = 0; k < ldsMap[index].length; k++)
+				fsa.msg.message[2 + k]	= ldsMap[index].dataPack[k];
+			int aa = ldsMap[index].length;
+			fsa.msg.message[2 + aa] = 0x0d;
+			fsa.msg.message[3 + aa] = 0xff;	//????????????? warning ?????
+
+			// info
+			fsa.info.poll_error_count = 0; 
+			/***************************************
+				 Need to find out polltime uci time function src code
+			fsa.info.poll_time = uci_unix_simulation_time(uci_simulation_time()); 
+			*/
+			fsa.info.poll_user_info1 = ldsMap[index].drop;	// drop number
+			fsa.info.poll_user_info2 = 1;	//always 1
+			fsa.info.retries = 0;
+			fsa.info.status = (enum replystatus) 1;
+			
+			//fepReply.answers.fep_answer_list_u.shortp.answers[j] = fsa;	
+			fepReply.answers.fep_answer_list_u.shortp.answers[0] = fsa;	
+			
+			// send out data
+			printf("Transferring line=%d, lds_drop_no=%d...\n", lines[i].lineNum, ldsMap[index].drop);
+			rv = fep_reply_xfer_32(&fepReply, clnt);
+
+			/* Handle ATMS response to RPC Call */
+			printf("Handling ATMS response...\n");
+			handle_ATMS_response(clnt, rv);
+		}
+	}		
+}
+
+/* Creates an RPC Client which communicates with the ATMS through RPC Calls */
+CLIENT * create_client(char *host)
+{
+	CLIENT *clnt;
+	
+	/* Create RPC Client to communicate with ATMS */
+	printf("Preparing to create RPC client...\n");
+	clnt = clnt_create(host, /*100090,*/ 103121, 32, "tcp");
+
+	/* Check if client creation failed */ 
+	if (clnt == (CLIENT *) NULL)
+	{
+		fprintf(stderr, "Can't create client to %s\n", host);
+		exit(1);
+	}
+	
+	return clnt;
+}
+
+/* update_ATMS transfers fep_replys to the ATMS Server. 
+	It creates an RPC client, loads data from line_atms.txt and lds_atms.txt,
+	updates the ATMS with the fep_reply data, and destroys the RPC client.
+ */
+void update_ATMS(char *host)
+{
+	CLIENT *clnt = create_client(host);
+	
+	/* Load data to be xfered to ATMS */
+	int lines_size = 0;
+	printf("Loading lines\n");
+        
+        NetworkFactory nf;
+	FEP_LINE *lines = nf.load_lines(&lines_size, "./lines_atms.txt");
+	printf("Loading ldsMap...\n");
+	STATION *ldsMap = nf.load_lds("./lds_atms.txt");
+
+	/* Transfer data to ATMS */
+	printf("Transferring data to ATMS...\n");
+	xfer_replys(clnt, lines, lines_size, ldsMap);
+
+	/* Free allocated memory */
+	printf("Freeing lines and ldsMap...\n");
+	free(lines);
+	free(ldsMap);
+
+	/* Destroy client */
+	printf("Destroying client...\n");
+	clnt_destroy(clnt);
+	printf("Returning to main...\n");
+}
+
+/* Main driver function to create an RPC Client, make a single RPC Call to the
+   ATMS Server */
+int main(int argc, char *argv[]) {
+	char *host;
+
+	if (argc < 2)
+	{
+		printf("usage:  %s server_host\n", argv[0]);
+		exit(1);
+	}
+
+	/* Create RPC Client to send an fep_reply to ATMS */
+	host = argv[1];
+	update_ATMS(host);
+
+	return 0;
+}
Index: /branches/LinuxBasicFEPClient/fep_clnt.c
===================================================================
--- /branches/LinuxBasicFEPClient/fep_clnt.c	(revision 154)
+++ /branches/LinuxBasicFEPClient/fep_clnt.c	(revision 154)
@@ -0,0 +1,446 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include <memory.h> /* for memset */
+#include "fep.h"
+/* RPC CLNT test */
+
+/* Default timeout can be changed using clnt_control() */
+static struct timeval TIMEOUT = { 25, 0 };
+
+int *
+fep_getlineinfocount_32(void *argp, CLIENT *clnt)
+{
+	static int clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETLINEINFOCOUNT,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_int, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+lineinfo_ret *
+fep_getlineinfo_32(int *argp, CLIENT *clnt)
+{
+	static lineinfo_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETLINEINFO,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_lineinfo_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+lineinfo_ret *
+fep_getlineinfovalue_32(int *argp, CLIENT *clnt)
+{
+	static lineinfo_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETLINEINFOVALUE,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_lineinfo_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+lineinfo_ret *
+fep_sendlineinfo_32(fep_lineinfo *argp, CLIENT *clnt)
+{
+	static lineinfo_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SENDLINEINFO,
+		(xdrproc_t) xdr_fep_lineinfo, (caddr_t) argp,
+		(xdrproc_t) xdr_lineinfo_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+std_time_ret *
+fep_gettime_32(void *argp, CLIENT *clnt)
+{
+	static std_time_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETTIME,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_std_time_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+std_time_ret *
+fep_settime_32(fep_std_time *argp, CLIENT *clnt)
+{
+	static std_time_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SETTIME,
+		(xdrproc_t) xdr_fep_std_time, (caddr_t) argp,
+		(xdrproc_t) xdr_std_time_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+std_time_ret *
+fep_advancetime_32(int *argp, CLIENT *clnt)
+{
+	static std_time_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_ADVANCETIME,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_std_time_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+int *
+fep_getschedulecount_32(void *argp, CLIENT *clnt)
+{
+	static int clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETSCHEDULECOUNT,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_int, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+schedule_ret *
+fep_getschedule_32(int *argp, CLIENT *clnt)
+{
+	static schedule_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETSCHEDULE,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_schedule_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+schedule_ret *
+fep_getschedulevalue_32(int *argp, CLIENT *clnt)
+{
+	static schedule_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETSCHEDULEVALUE,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_schedule_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+schedule_ret *
+fep_sendschedule_32(fep_schedule *argp, CLIENT *clnt)
+{
+	static schedule_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SENDSCHEDULE,
+		(xdrproc_t) xdr_fep_schedule, (caddr_t) argp,
+		(xdrproc_t) xdr_schedule_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_setlinemgr_schedule_32(fep_setschedule *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SETLINEMGR_SCHEDULE,
+		(xdrproc_t) xdr_fep_setschedule, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_free_schedule_32(int *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_FREE_SCHEDULE,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_idleline_32(fep_lineop *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_IDLELINE,
+		(xdrproc_t) xdr_fep_lineop, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_modemsignals_32(fep_lineop *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_MODEMSIGNALS,
+		(xdrproc_t) xdr_fep_lineop, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+reply_ret *
+fep_getreply_32(fep_reply_request *argp, CLIENT *clnt)
+{
+	static reply_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETREPLY,
+		(xdrproc_t) xdr_fep_reply_request, (caddr_t) argp,
+		(xdrproc_t) xdr_reply_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_clearreply_32(void *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_CLEARREPLY,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+schedule_ret *
+fep_updateschedule_32(fep_schedule *argp, CLIENT *clnt)
+{
+	static schedule_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_UPDATESCHEDULE,
+		(xdrproc_t) xdr_fep_schedule, (caddr_t) argp,
+		(xdrproc_t) xdr_schedule_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+int *
+fep_getreportcount_32(void *argp, CLIENT *clnt)
+{
+	static int clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETREPORTCOUNT,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_int, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+report_ret *
+fep_getreport_32(int *argp, CLIENT *clnt)
+{
+	static report_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETREPORT,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_report_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+report_ret *
+fep_getreportvalue_32(int *argp, CLIENT *clnt)
+{
+	static report_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GETREPORTVALUE,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_report_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+report_ret *
+fep_sendreport_32(fep_report *argp, CLIENT *clnt)
+{
+	static report_ret clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SENDREPORT,
+		(xdrproc_t) xdr_fep_report, (caddr_t) argp,
+		(xdrproc_t) xdr_report_ret, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+void *
+fep_reply_xfer_32(fep_reply *argp, CLIENT *clnt)
+{
+	static char clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_REPLY_XFER,
+		(xdrproc_t) xdr_fep_reply, (caddr_t) argp,
+		(xdrproc_t) xdr_void, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return ((void *)&clnt_res);
+}
+
+errorstatus *
+fep_set_debug_32(int *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SET_DEBUG,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+int *
+fep_get_stack_left_32(void *argp, CLIENT *clnt)
+{
+	static int clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_GET_STACK_LEFT,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_int, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_setlmdebug_32(fep_setschedule *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SETLMDEBUG,
+		(xdrproc_t) xdr_fep_setschedule, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+errorstatus *
+fep_shutdown_32(void *argp, CLIENT *clnt)
+{
+	static errorstatus clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_SHUTDOWN,
+		(xdrproc_t) xdr_void, (caddr_t) argp,
+		(xdrproc_t) xdr_errorstatus, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+int *
+fep_initsystem_32(int *argp, CLIENT *clnt)
+{
+	static int clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_INITSYSTEM,
+		(xdrproc_t) xdr_int, (caddr_t) argp,
+		(xdrproc_t) xdr_int, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
+
+int *
+fep_initrealix_32(init_form *argp, CLIENT *clnt)
+{
+	static int clnt_res;
+
+	memset((char *)&clnt_res, 0, sizeof(clnt_res));
+	if (clnt_call (clnt, FEP_INITREALIX,
+		(xdrproc_t) xdr_init_form, (caddr_t) argp,
+		(xdrproc_t) xdr_int, (caddr_t) &clnt_res,
+		TIMEOUT) != RPC_SUCCESS) {
+		return (NULL);
+	}
+	return (&clnt_res);
+}
Index: /branches/LinuxBasicFEPClient/network.h
===================================================================
--- /branches/LinuxBasicFEPClient/network.h	(revision 154)
+++ /branches/LinuxBasicFEPClient/network.h	(revision 154)
@@ -0,0 +1,78 @@
+#ifndef __NETWORK_H_INCLUDED__
+#define __NETWORK_H_INCLUDED__
+
+#include <stdlib.h>
+#include <math.h>
+#include <vector>
+
+using namespace std;
+
+/*** CONSTANTS ***/
+const int Fixed_Byte_To_Checksum = 25; // the first byte is not considered in the calculation of "BYTE 2"
+const int CONTROL_DATA_LEN = 27;
+
+char * const dp5[8] = { "ML_1", "ML_2", "ML_3", "ML_4", "ML_5",
+                                                "ML_6", "HOV_Lane", "FYW_Conn"};
+char * const dp6[8] = { "OS_1", "OS_2", "OS_3", "OS_4", "OS_5",
+                                                "OS_6", "COLL_DIST_2", "COLL_DIST_OFF"};
+char * const dp7[8] = { "DEMAND", "PASSAGE", "QUEUE", "RAMP_ON",
+                                                "RAMP_OFF", "RAMP_HOV", "COLL_DIST_1", "COLL_DIST_ON"};
+char * const dp8[8] = { "SD_1", "SD_2", "SD_3", "SD_4", "SD_5",
+                                                "SD_6", "Pass_Vol_Count", "X"};
+
+// FEP line: has several lds
+typedef struct fep_line FEP_LINE;
+struct  fep_line
+{
+	int             lineNum;
+	vector<long>    lds;
+	vector<long>    ldsIndex;	// location in ldsMap
+
+	short   count;	// actual count from caltrans
+	int	schedule;
+	int	lineInfo;
+	long	systemKey;
+	long	globalSeq;
+	long	schedleSeq;
+};
+
+// Loop detector
+typedef struct loop LOOP;
+struct loop
+{
+    long loopID;
+    char *loop_loc;
+    
+    int vol;
+    float occ;
+    double spd;
+};
+
+// Loop detector station: has several loops
+typedef struct Station STATION;
+struct  Station
+{
+	// Each lds has its own line_num and drop (Caltrans use)
+	long	lds;
+	short	line_num;
+	short	drop;
+        
+        vector<LOOP*> loops;
+
+	// LDS data
+	unsigned char	*dataPack;
+	int		length;		// total length of data (max: 87)
+	int		pos;		// pointer for data preparation
+	int		MlTotVol;	// each 30 sec, the following will be updated
+	int		OppTotVol;	// each 30 sec, the following will be updated
+};
+
+typedef struct volOcc VOLOCC;
+struct  volOcc
+{
+   char high;
+   char low;
+};
+
+
+#endif
Index: /branches/LinuxBasicFEPClient/DataPacker.cpp
===================================================================
--- /branches/LinuxBasicFEPClient/DataPacker.cpp	(revision 154)
+++ /branches/LinuxBasicFEPClient/DataPacker.cpp	(revision 154)
@@ -0,0 +1,269 @@
+#include "DataPacker.h"
+#include <stdio.h>
+
+unsigned char * DataPacker::msg;
+
+unsigned char * DataPacker::packData(STATION *station) {
+    int pos = 26;
+    DataPacker packer;
+    msg = packer.staticDataPack(station);
+    pos = packer.dynamicDataPack(station, 5, pos);    
+    pos = packer.dynamicDataPack(station, 6, pos);
+    pos = packer.dynamicDataPack(station, 7, pos);
+    pos = packer.dynamicDataPack(station, 8, pos);
+    // Update data for BYTE 9, 16, 21, 22, 23, 24
+
+    // what is the current metering rate?
+    // check each LDS, if there is demand detector, the downstream node the
+    // ldsMap[i].dataPack[22-1] = ldsMap[i].dataPack[9-1] = ;
+
+    // will need to check if queue override is enabled (Currently, no queue
+    // ldsMap[i].dataPack[16-1] = ;
+
+    // byte 23: MAINLINE total volume
+    msg[23 - 1] = station->MlTotVol;
+
+    // byte 24: opposite total volume
+    msg[24 - 1] = station->OppTotVol;
+
+    // last BYTE: checksum 
+    msg[station->length - 1] =
+            packer.chksum(msg, station->length - 1 - 1);
+    
+    for (int j = 0; j < station->length; j++) {
+        printf("%02X", msg[j]);
+    }
+    printf("\n");
+
+    return msg;	
+}
+
+int DataPacker::dynamicDataPack(STATION *station, int packNo, int pos) {
+    int i, j, vol, occ, haveData;
+    //used for data byte 23 and 24
+    station->MlTotVol = 0;
+    station->OppTotVol = 0;
+
+    for (j = 1; j <= 8; j++) {
+        
+        if (DataAvail(msg[packNo - 1], j)) {
+            // loop at bit j has data
+            for (int lane = 0; lane < station->loops.size(); lane++) {
+                // what's the corresponding loop of bit j
+                char * currLoopLoc = station->loops.at(lane)->loop_loc;
+                if (packNo == 5)
+                    haveData = strcmp(currLoopLoc, dp5[j - 1]);
+                else if (packNo == 6)
+                    haveData = strcmp(currLoopLoc, dp6[j - 1]);
+                else if (packNo == 7)
+                    haveData = strcmp(currLoopLoc, dp7[j - 1]);
+                else if (packNo == 8)
+                    haveData = strcmp(currLoopLoc, dp8[j - 1]);
+                else
+                    return -1;
+                
+                // if we have data (strcmp returns 0 if a string match)
+                if (haveData == 0) {
+                    LOOP *currLoop = station->loops.at(lane);
+                    vol = currLoop->vol;
+                    occ = (int) (currLoop->occ * 900 + 0.5);
+                    cout << "Volume: " << vol << endl;
+                    cout << "OCC : " << occ << endl;
+                    VOLOCC packedVOLOCC = packVOLOCC(vol, occ);
+                    pos++;
+                    msg[pos - 1] = packedVOLOCC.high;
+                    pos++;
+                    msg[pos - 1] = packedVOLOCC.low;
+                    
+                    if (packNo == 5) {
+                        station->MlTotVol += vol;
+                    } else if (packNo == 6) {
+                        station->OppTotVol += vol;
+                    }
+                }
+            }
+        }
+    }
+    return pos;
+}
+
+unsigned char * DataPacker::staticDataPack(STATION *station) {
+    int j;
+    // Allocate memory for dataPack
+    unsigned char *dataPack = (unsigned char *) calloc(sizeof(unsigned char), station->length);
+
+    // dataPack 5-8: lane config
+    char d5 = 0, d6 = 0, d7 = 0, d8 = 0;
+    for (j = 0; j < station->loops.size(); j++) {
+        for (int k = 0; k < 8; k++) {
+            char * currLoopLoc = station->loops.at(j)->loop_loc;
+            if (strcmp(currLoopLoc, dp5[k]) == 0)
+                d5 += pow(2, k);
+            if (strcmp(currLoopLoc, dp6[k]) == 0)
+                d6 += pow(2, k);
+            if (strcmp(currLoopLoc, dp7[k]) == 0)
+                d7 += pow(2, k);
+            if (strcmp(currLoopLoc, dp8[k]) == 0)
+                d8 += pow(2, k);
+        }
+    }
+    dataPack[5 - 1] = d5;
+    dataPack[6 - 1] = d6;
+    dataPack[7 - 1] = d7;
+    dataPack[8 - 1] = d8;
+
+    // dataPack 1: Drop number, i.e. station address
+    dataPack[1 - 1] = station->drop;
+    // dataPack2 (2 bytes per loop)
+    dataPack[2 - 1] = station->loops.size() * 2 + Fixed_Byte_To_Checksum;
+
+    // dataPacket 3 (lowbyte: # of mainline loops, highbyte: # of opposite loops)
+    int low = 0, high = 0;
+    for (j = 1; j <= 6; j++) {
+        low += DataAvail(dataPack[5 - 1], j);
+        high += DataAvail(dataPack[6 - 1], j);
+    }
+    high = high << 4;
+    dataPack[3 - 1] = high | low;
+
+    // dataPack4 (Miscl. flags: samples are: 80, A0, E0, 00)
+    dataPack[4 - 1] = 0xA0;
+
+    // dataPack 9: initialized as 00 (meaning no metering); need to be updated every 30 sec
+    dataPack[9 - 1] = 0;
+
+    // datadataPack 10-13: lane malfunction? Assuming all functional
+    dataPack[10 - 1] = 0;
+    dataPack[11 - 1] = 0;
+    dataPack[12 - 1] = 0;
+    dataPack[13 - 1] = 0;
+
+    // dataPack 14-22: ramp metering data
+    // BYTE 16 and 22 need to be updated every 30 sec
+    bool found = false;
+    for (j = 0; j < station->loops.size(); j++) {
+        if (strcmp(station->loops.at(j)->loop_loc, "DEMAND") == 0) {
+            found = true;
+            break;
+        }
+    }
+    if (found) {
+        // BYTE 14: mostly 07, some are 05, 03, 00
+        dataPack[14 - 1] = 0x07;
+        // mostly 06(TOD table 1); some are 0B (No metering) or 05(traffic responsive)
+        dataPack[15 - 1] = 0x06;
+        // most 00, some are 01 (queue override) or 80(Meter ON sign)
+        dataPack[16 - 1] = 0x00;
+        // Field Manual Rate
+        dataPack[17 - 1] = 0xFF;
+        // TOC Manual Rate
+        dataPack[18 - 1] = 0xFF;
+        // PSO Manual Rate
+        dataPack[19 - 1] = 0xFF;
+        // CORM Rate
+        dataPack[20 - 1] = 0xFF;
+        // Local Responsive Rate. DON'T UNDERSTAND YET
+        dataPack[21 - 1] = 0x00;
+        // TOD Rate: need to query RAMP plugin!
+        dataPack[22 - 1] = 0x00;
+    }// LDS: NO Metering
+    else {
+        dataPack[14 - 1] = 0x00;
+        dataPack[15 - 1] = 0x0B;
+        dataPack[16 - 1] = 0x00;
+        dataPack[17 - 1] = 0xFF;
+        dataPack[18 - 1] = 0xFF;
+        dataPack[19 - 1] = 0xFF;
+        dataPack[20 - 1] = 0xFF;
+        dataPack[21 - 1] = 0x00;
+        dataPack[22 - 1] = 0x00;
+    }
+
+    // dataPack 23-24: sum of mainline/Opp traffic data; need to be updated every 30 sec
+    station->MlTotVol = 0;
+    station->OppTotVol = 0;
+    dataPack[23 - 1] = station->MlTotVol;
+    dataPack[24 - 1] = station->OppTotVol;
+
+    // dataPack 25-26: BYTE 25 is fixed, i.e. 03; BYTE 26 is either 0xA2 or 0x84
+    dataPack[25 - 1] = 0x03;
+    dataPack[26 - 1] = 0x84;
+
+    return dataPack;
+}
+
+bool DataPacker::DataAvail(char flag, int num) {
+    int mag, fel;
+
+    // find mask value
+    if (num == 1)
+        mag = 0x01;
+    else if (num == 2)
+        mag = 0x02;
+    else if (num == 3)
+        mag = 0x04;
+    else if (num == 4)
+        mag = 0x08;
+    else if (num == 5)
+        mag = 0x10;
+    else if (num == 6)
+        mag = 0x20;
+    else if (num == 7)
+        mag = 0x40;
+    else if (num == 8)
+        mag = 0x80;
+
+    fel = flag & mag;
+    fel = fel >> (num - 1);
+
+    if (fel == 1)
+        return true;
+    else
+        return false;
+}
+
+// checksum based on data from byte 1 (after 0DOA) to the second last byte (the 
+char DataPacker::chksum(unsigned char *dataptr, int len) {
+    int i;
+    unsigned char checksum = 0;
+
+    for (i = 0; i < len; i++)
+        checksum += dataptr[i];
+
+    return checksum;
+}
+
+// convert vol and occ data to a two-byte data packet
+VOLOCC DataPacker::packVOLOCC(int vol, int occ)
+{
+   int bit, i;
+   int   high, low; 
+   int high_high = 0, high_low = 0;
+   VOLOCC com;
+   
+   // occ data: 10 bits
+   low = 0;
+   for (i=9; i>=0; i--) 
+   {
+      if (i >= 8)
+      {
+         bit = ((occ >> i) & 1);
+         high_low += pow(2, (i - 8)) * bit; 
+      }
+      // lower byte
+      else
+      {
+         bit = ((occ >> i) & 1);
+         low += pow(2, i) * bit;
+      }
+   }
+
+   // vol: 6 bits (1. vol, shift to the left for two times; 2. combine data)
+   high_high = vol << 2;
+   high = high_high | high_low;
+
+   com.high = high;
+   com.low = low;
+
+   return com;
+}
Index: /branches/LinuxBasicFEPClient/fep.h
===================================================================
--- /branches/LinuxBasicFEPClient/fep.h	(revision 154)
+++ /branches/LinuxBasicFEPClient/fep.h	(revision 154)
@@ -0,0 +1,761 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _FEP_H_RPCGEN
+#define _FEP_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* RPC HDR test */
+#ifndef FEP_PROGRAM
+#define MAXDEVLEN 32
+#define _MAXSHORTMESSAGELEN 128
+#define _MAXLONGMESSAGELEN 1024
+#define _MAXSHORTPOLLS 20
+#define _MAXLONGPOLLS 2
+#define _MAXPOLLRETRY 2
+#define _MAXSHORTREPLYLEN 128
+#define _MAXLONGREPLYLEN 1024
+#define MAXADDRLEN 64
+#define MAXSHORTMESSAGELEN _MAXSHORTMESSAGELEN
+#define MAXLONGMESSAGELEN _MAXLONGMESSAGELEN
+#define MAXSHORTPOLLS _MAXSHORTPOLLS
+#define MAXLONGPOLLS _MAXLONGPOLLS
+#define MAXPOLLRETRY _MAXPOLLRETRY
+#define MAXSHORTREPLYLEN _MAXSHORTREPLYLEN
+#define MAXLONGREPLYLEN _MAXLONGREPLYLEN
+
+enum errorstatus {
+	FEP_OK = 0,
+	FEP_OUTOFRANGE = 1,
+	FEP_BADHANDLE = 2,
+	FEP_NOREPLY = 3,
+	FEP_SCHBUSY = 4,
+	FEP_LINEBUSY = 5,
+	FEP_REPORTBUSY = 6,
+	FEP_NOREPORT = 7,
+	FEP_NOMEMORY = 8,
+	FEP_BADTIME = 9,
+	FEP_BADTIMESYNCH = 10,
+	FEP_BADKIND = 11,
+	FEP_BADCONNECT = 12,
+	FEP_NOAUTHORITY = 13,
+};
+typedef enum errorstatus errorstatus;
+
+enum Polling_FSM_States {
+	INITSTATE = 0x01,
+	WRALARMSTATE = 0x10,
+	CLRSTATE = 0x20,
+	RTSONSTATE = 0x30,
+	CTSSTATE = 0x40,
+	WRITESTATE = 0x50,
+	RTSOFFSTATE = 0x60,
+	RDALARMSTATE = 0x70,
+	RDSTATE = 0x80,
+	DONESTATE = 0x00,
+};
+typedef enum Polling_FSM_States Polling_FSM_States;
+
+struct fep_lineinfo {
+	int lineinfo;
+	char device[MAXDEVLEN];
+	int poll;
+	int command;
+	int sync;
+	int line_error_count;
+	int pid;
+	int semaphore;
+	int debug;
+};
+typedef struct fep_lineinfo fep_lineinfo;
+
+struct lineinfo_ret {
+	errorstatus status;
+	union {
+		fep_lineinfo info;
+	} lineinfo_ret_u;
+};
+typedef struct lineinfo_ret lineinfo_ret;
+
+struct fep_std_time {
+	int year;
+	int month;
+	int day;
+	int hour;
+	int minute;
+	int second;
+	long time_t;
+};
+typedef struct fep_std_time fep_std_time;
+
+struct std_time_ret {
+	errorstatus status;
+	union {
+		fep_std_time info;
+	} std_time_ret_u;
+};
+typedef struct std_time_ret std_time_ret;
+
+enum protocoltype {
+	DEFAULT = 0,
+	SATMSPROT = 1,
+	SDRMSPROT = 2,
+	INACTIVE = 3,
+	CLEARPROT = 4,
+	CMS500PROT = 5,
+	CMSHPPROT = 6,
+	TIMESYNCPOLL = 7,
+};
+typedef enum protocoltype protocoltype;
+
+enum duplex {
+	HALFDUPLEX = 0,
+	FULLDUPLEX = 1,
+};
+typedef enum duplex duplex;
+
+struct fep_poll_info {
+	int D7_update;
+	protocoltype protocol;
+	int poll_user_info1;
+	int poll_user_info2;
+	int format;
+	int speed;
+	int mode;
+	int min_separation;
+	int delay_rts_on;
+	int max_send;
+	int delay_rts_off;
+	int max_reply;
+	int min_error;
+	int max_retry;
+	int reply_len;
+	int poll_error_count;
+};
+typedef struct fep_poll_info fep_poll_info;
+
+struct fep_poll_short_msg {
+	int message_len;
+	char message[MAXSHORTMESSAGELEN];
+};
+typedef struct fep_poll_short_msg fep_poll_short_msg;
+
+struct fep_shortpoll {
+	fep_poll_info info;
+	fep_poll_short_msg msg;
+};
+typedef struct fep_shortpoll fep_shortpoll;
+
+struct fep_shortpoll_list {
+	int count;
+	fep_shortpoll polls[MAXSHORTPOLLS];
+};
+typedef struct fep_shortpoll_list fep_shortpoll_list;
+
+struct fep_poll_long_msg {
+	int message_len;
+	char message[MAXLONGMESSAGELEN];
+};
+typedef struct fep_poll_long_msg fep_poll_long_msg;
+
+struct fep_longpoll {
+	fep_poll_info info;
+	fep_poll_long_msg msg;
+};
+typedef struct fep_longpoll fep_longpoll;
+
+struct fep_longpoll_list {
+	int count;
+	fep_longpoll polls[MAXLONGPOLLS];
+};
+typedef struct fep_longpoll_list fep_longpoll_list;
+
+enum poll_length {
+	SHORTPOLL = 0,
+	LONGPOLL = 1,
+};
+typedef enum poll_length poll_length;
+
+struct fep_poll_list {
+	int size;
+	union {
+		fep_shortpoll_list shortp;
+		fep_longpoll_list longp;
+	} fep_poll_list_u;
+};
+typedef struct fep_poll_list fep_poll_list;
+
+enum polltype {
+	POLL = 0,
+	COMMAND = 1,
+	TIMESYNC = 2,
+};
+typedef enum polltype polltype;
+
+enum commandtype {
+	AFTERPOLL = 0,
+	BEFOREPOLL = 1,
+	IMMEDIATE = 2,
+};
+typedef enum commandtype commandtype;
+
+enum schedulestatus {
+	IDLE = 0,
+	ACTIVE = 1,
+	COMPLETE = 2,
+};
+typedef enum schedulestatus schedulestatus;
+
+struct fep_schedule {
+	int schedule;
+	int lineinfo;
+	polltype kind;
+	commandtype priority;
+	protocoltype protocol;
+	fep_std_time time;
+	int interval;
+	long at_time;
+	int user_info1;
+	int user_info2;
+	int system_key;
+	int next;
+	int previous;
+	int report;
+	int sequence;
+	int status;
+	int retry;
+	fep_poll_list fep_polls;
+};
+typedef struct fep_schedule fep_schedule;
+
+enum answererror {
+	ERR_BSCF_ERR = -1,
+	ERR_NONE = 0,
+	ERR_MSG_LEN = 2,
+	ERR_MSG_HDR = 3,
+	ERR_MSG_CHKSUM = 4,
+	ERR_MSG_TRAILER = 5,
+};
+typedef enum answererror answererror;
+
+struct fep_pollerror {
+	answererror msgerror;
+	Polling_FSM_States state;
+	int perrno;
+	int termination;
+	int count;
+};
+typedef struct fep_pollerror fep_pollerror;
+
+enum replystatus {
+	FAILURE = 2,
+	DONE = 1,
+	UNUSED = 3,
+};
+typedef enum replystatus replystatus;
+
+struct fep_answer_info {
+	long poll_time;
+	replystatus status;
+	int poll_user_info1;
+	int poll_user_info2;
+	int retries;
+	int poll_error_count;
+	fep_pollerror pollerror[MAXPOLLRETRY];
+};
+typedef struct fep_answer_info fep_answer_info;
+
+struct fep_answer_short_msg {
+	int message_len;
+	char message[MAXSHORTREPLYLEN];
+};
+typedef struct fep_answer_short_msg fep_answer_short_msg;
+
+struct fep_shortanswer {
+	fep_answer_info info;
+	fep_answer_short_msg msg;
+};
+typedef struct fep_shortanswer fep_shortanswer;
+
+struct fep_shortanswer_list {
+	int count;
+	fep_shortanswer answers[MAXSHORTPOLLS];
+};
+typedef struct fep_shortanswer_list fep_shortanswer_list;
+
+struct fep_answer_long_msg {
+	int message_len;
+	char message[MAXLONGREPLYLEN];
+};
+typedef struct fep_answer_long_msg fep_answer_long_msg;
+
+struct fep_longanswer {
+	fep_answer_info info;
+	fep_answer_long_msg msg;
+};
+typedef struct fep_longanswer fep_longanswer;
+
+struct fep_longanswer_list {
+	int count;
+	fep_longanswer answers[MAXLONGPOLLS];
+};
+typedef struct fep_longanswer_list fep_longanswer_list;
+
+struct fep_answer_list {
+	int size;
+	union {
+		fep_shortanswer_list shortp;
+		fep_longanswer_list longp;
+	} fep_answer_list_u;
+};
+typedef struct fep_answer_list fep_answer_list;
+
+enum replykind {
+	POLLREPLY = 0,
+	SCHEDNEW = 1,
+	SCHEDDONE = 2,
+};
+typedef enum replykind replykind;
+
+struct fep_reply {
+	int reply;
+	int schedule;
+	int lineinfo;
+	polltype kind;
+	replykind flag;
+	int schedule_sequence;
+	int global_sequence;
+	long schedule_time;
+	int user_info1;
+	int user_info2;
+	int system_key;
+	struct fep_answer_list answers;
+};
+typedef struct fep_reply fep_reply;
+
+struct schedule_ret {
+	errorstatus status;
+	union {
+		fep_schedule info;
+	} schedule_ret_u;
+};
+typedef struct schedule_ret schedule_ret;
+
+struct fep_reply_request {
+	int schedule;
+	int sequence;
+	int block;
+};
+typedef struct fep_reply_request fep_reply_request;
+
+struct reply_ret {
+	errorstatus status;
+	union {
+		fep_reply info;
+	} reply_ret_u;
+};
+typedef struct reply_ret reply_ret;
+
+struct init_form {
+	char host[10];
+	int config;
+};
+typedef struct init_form init_form;
+
+struct fep_setschedule {
+	int lineinfo;
+	int schedule;
+	int debug;
+};
+typedef struct fep_setschedule fep_setschedule;
+
+enum statusflags {
+	ENABLED_FLAG = 1,
+	POLL_FLAG = 2,
+	TIME_FLAG = 4,
+	CMD_FLAG = 8,
+};
+typedef enum statusflags statusflags;
+
+struct fep_lineop {
+	int lineinfo;
+	int flags;
+	int modem_signals;
+};
+typedef struct fep_lineop fep_lineop;
+
+enum ipprotocol {
+	TCPPROT = 0,
+	UDPPROT = 1,
+};
+typedef enum ipprotocol ipprotocol;
+
+enum action {
+	REP = 0,
+	LOG = 1,
+};
+typedef enum action action;
+
+enum portstatus {
+	NOCONNECTION = 0,
+	CONNECTION = 1,
+	FAILED = 2,
+};
+typedef enum portstatus portstatus;
+
+struct fep_report {
+	int report;
+	char dest[MAXADDRLEN];
+	char logfile[MAXADDRLEN];
+	char monitor[MAXADDRLEN];
+	int port;
+	ipprotocol protocol;
+	int update;
+	action action;
+	int reconnect;
+	portstatus status;
+	int perrno;
+	int debug;
+	int pid;
+	int semaphore;
+};
+typedef struct fep_report fep_report;
+
+struct report_ret {
+	errorstatus status;
+	union {
+		fep_report info;
+	} report_ret_u;
+};
+typedef struct report_ret report_ret;
+#define fep_getlineinfocount fep_getlineinfocount ## _ ## 32
+#define fep_getlineinfo fep_getlineinfo ## _ ## 32
+#define fep_getlineinfovalue fep_getlineinfovalue ## _ ## 32
+#define fep_sendlineinfo fep_sendlineinfo ## _ ## 32
+#define fep_gettime fep_gettime ## _ ## 32
+#define fep_settime fep_settime ## _ ## 32
+#define fep_advancetime fep_advancetime ## _ ## 32
+#define fep_getschedulecount fep_getschedulecount ## _ ## 32
+#define fep_getschedule fep_getschedule ## _ ## 32
+#define fep_getschedulevalue fep_getschedulevalue ## _ ## 32
+#define fep_sendschedule fep_sendschedule ## _ ## 32
+#define fep_setlinemgr_schedule fep_setlinemgr_schedule ## _ ## 32
+#define fep_free_schedule fep_free_schedule ## _ ## 32
+#define fep_updateschedule fep_updateschedule ## _ ## 32
+#define fep_idleline fep_idleline ## _ ## 32
+#define fep_modemsignals fep_modemsignals ## _ ## 32
+#define fep_getreply fep_getreply ## _ ## 32
+#define fep_clearreply fep_clearreply ## _ ## 32
+#define fep_getreportcount fep_getreportcount ## _ ## 32
+#define fep_getreport fep_getreport ## _ ## 32
+#define fep_getreportvalue fep_getreportvalue ## _ ## 32
+#define fep_sendreport fep_sendreport ## _ ## 32
+#define fep_reply_xfer fep_reply_xfer ## _ ## 32
+#define fep_schedule_xfer fep_schedule_xfer ## _ ## 32
+#define fep_fake_reply fep_fake_reply ## _ ## 32
+#define fep_set_debug fep_set_debug ## _ ## 32
+#define fep_get_stack_left fep_get_stack_left ## _ ## 32
+#define fep_setlmdebug fep_setlmdebug ## _ ## 32
+#define fep_shutdown fep_shutdown ## _ ## 32
+#define fep_initsystem fep_initsystem ## _ ## 32
+#define fep_initrealix fep_initrealix ## _ ## 32
+/* RPC HDR test */
+#endif
+
+#define FEP_PROGRAM 100090
+#define FEP_VERSION 32
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define FEP_GETLINEINFOCOUNT 1
+extern  int * fep_getlineinfocount_32(void *, CLIENT *);
+extern  int * fep_getlineinfocount_32_svc(void *, struct svc_req *);
+#define FEP_GETLINEINFO 2
+extern  lineinfo_ret * fep_getlineinfo_32(int *, CLIENT *);
+extern  lineinfo_ret * fep_getlineinfo_32_svc(int *, struct svc_req *);
+#define FEP_GETLINEINFOVALUE 3
+extern  lineinfo_ret * fep_getlineinfovalue_32(int *, CLIENT *);
+extern  lineinfo_ret * fep_getlineinfovalue_32_svc(int *, struct svc_req *);
+#define FEP_SENDLINEINFO 4
+extern  lineinfo_ret * fep_sendlineinfo_32(fep_lineinfo *, CLIENT *);
+extern  lineinfo_ret * fep_sendlineinfo_32_svc(fep_lineinfo *, struct svc_req *);
+#define FEP_GETTIME 5
+extern  std_time_ret * fep_gettime_32(void *, CLIENT *);
+extern  std_time_ret * fep_gettime_32_svc(void *, struct svc_req *);
+#define FEP_SETTIME 6
+extern  std_time_ret * fep_settime_32(fep_std_time *, CLIENT *);
+extern  std_time_ret * fep_settime_32_svc(fep_std_time *, struct svc_req *);
+#define FEP_ADVANCETIME 7
+extern  std_time_ret * fep_advancetime_32(int *, CLIENT *);
+extern  std_time_ret * fep_advancetime_32_svc(int *, struct svc_req *);
+#define FEP_GETSCHEDULECOUNT 8
+extern  int * fep_getschedulecount_32(void *, CLIENT *);
+extern  int * fep_getschedulecount_32_svc(void *, struct svc_req *);
+#define FEP_GETSCHEDULE 9
+extern  schedule_ret * fep_getschedule_32(int *, CLIENT *);
+extern  schedule_ret * fep_getschedule_32_svc(int *, struct svc_req *);
+#define FEP_GETSCHEDULEVALUE 10
+extern  schedule_ret * fep_getschedulevalue_32(int *, CLIENT *);
+extern  schedule_ret * fep_getschedulevalue_32_svc(int *, struct svc_req *);
+#define FEP_SENDSCHEDULE 11
+extern  schedule_ret * fep_sendschedule_32(fep_schedule *, CLIENT *);
+extern  schedule_ret * fep_sendschedule_32_svc(fep_schedule *, struct svc_req *);
+#define FEP_SETLINEMGR_SCHEDULE 12
+extern  errorstatus * fep_setlinemgr_schedule_32(fep_setschedule *, CLIENT *);
+extern  errorstatus * fep_setlinemgr_schedule_32_svc(fep_setschedule *, struct svc_req *);
+#define FEP_FREE_SCHEDULE 13
+extern  errorstatus * fep_free_schedule_32(int *, CLIENT *);
+extern  errorstatus * fep_free_schedule_32_svc(int *, struct svc_req *);
+#define FEP_IDLELINE 14
+extern  errorstatus * fep_idleline_32(fep_lineop *, CLIENT *);
+extern  errorstatus * fep_idleline_32_svc(fep_lineop *, struct svc_req *);
+#define FEP_MODEMSIGNALS 15
+extern  errorstatus * fep_modemsignals_32(fep_lineop *, CLIENT *);
+extern  errorstatus * fep_modemsignals_32_svc(fep_lineop *, struct svc_req *);
+#define FEP_GETREPLY 16
+extern  reply_ret * fep_getreply_32(fep_reply_request *, CLIENT *);
+extern  reply_ret * fep_getreply_32_svc(fep_reply_request *, struct svc_req *);
+#define FEP_CLEARREPLY 17
+extern  errorstatus * fep_clearreply_32(void *, CLIENT *);
+extern  errorstatus * fep_clearreply_32_svc(void *, struct svc_req *);
+#define FEP_UPDATESCHEDULE 18
+extern  schedule_ret * fep_updateschedule_32(fep_schedule *, CLIENT *);
+extern  schedule_ret * fep_updateschedule_32_svc(fep_schedule *, struct svc_req *);
+#define FEP_GETREPORTCOUNT 20
+extern  int * fep_getreportcount_32(void *, CLIENT *);
+extern  int * fep_getreportcount_32_svc(void *, struct svc_req *);
+#define FEP_GETREPORT 21
+extern  report_ret * fep_getreport_32(int *, CLIENT *);
+extern  report_ret * fep_getreport_32_svc(int *, struct svc_req *);
+#define FEP_GETREPORTVALUE 22
+extern  report_ret * fep_getreportvalue_32(int *, CLIENT *);
+extern  report_ret * fep_getreportvalue_32_svc(int *, struct svc_req *);
+#define FEP_SENDREPORT 23
+extern  report_ret * fep_sendreport_32(fep_report *, CLIENT *);
+extern  report_ret * fep_sendreport_32_svc(fep_report *, struct svc_req *);
+#define FEP_REPLY_XFER 30
+extern  void * fep_reply_xfer_32(fep_reply *, CLIENT *);
+extern  void * fep_reply_xfer_32_svc(fep_reply *, struct svc_req *);
+#define FEP_SET_DEBUG 36
+extern  errorstatus * fep_set_debug_32(int *, CLIENT *);
+extern  errorstatus * fep_set_debug_32_svc(int *, struct svc_req *);
+#define FEP_GET_STACK_LEFT 37
+extern  int * fep_get_stack_left_32(void *, CLIENT *);
+extern  int * fep_get_stack_left_32_svc(void *, struct svc_req *);
+#define FEP_SETLMDEBUG 38
+extern  errorstatus * fep_setlmdebug_32(fep_setschedule *, CLIENT *);
+extern  errorstatus * fep_setlmdebug_32_svc(fep_setschedule *, struct svc_req *);
+#define FEP_SHUTDOWN 39
+extern  errorstatus * fep_shutdown_32(void *, CLIENT *);
+extern  errorstatus * fep_shutdown_32_svc(void *, struct svc_req *);
+#define FEP_INITSYSTEM 40
+extern  int * fep_initsystem_32(int *, CLIENT *);
+extern  int * fep_initsystem_32_svc(int *, struct svc_req *);
+#define FEP_INITREALIX 41
+extern  int * fep_initrealix_32(init_form *, CLIENT *);
+extern  int * fep_initrealix_32_svc(init_form *, struct svc_req *);
+extern int fep_program_32_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define FEP_GETLINEINFOCOUNT 1
+extern  int * fep_getlineinfocount_32();
+extern  int * fep_getlineinfocount_32_svc();
+#define FEP_GETLINEINFO 2
+extern  lineinfo_ret * fep_getlineinfo_32();
+extern  lineinfo_ret * fep_getlineinfo_32_svc();
+#define FEP_GETLINEINFOVALUE 3
+extern  lineinfo_ret * fep_getlineinfovalue_32();
+extern  lineinfo_ret * fep_getlineinfovalue_32_svc();
+#define FEP_SENDLINEINFO 4
+extern  lineinfo_ret * fep_sendlineinfo_32();
+extern  lineinfo_ret * fep_sendlineinfo_32_svc();
+#define FEP_GETTIME 5
+extern  std_time_ret * fep_gettime_32();
+extern  std_time_ret * fep_gettime_32_svc();
+#define FEP_SETTIME 6
+extern  std_time_ret * fep_settime_32();
+extern  std_time_ret * fep_settime_32_svc();
+#define FEP_ADVANCETIME 7
+extern  std_time_ret * fep_advancetime_32();
+extern  std_time_ret * fep_advancetime_32_svc();
+#define FEP_GETSCHEDULECOUNT 8
+extern  int * fep_getschedulecount_32();
+extern  int * fep_getschedulecount_32_svc();
+#define FEP_GETSCHEDULE 9
+extern  schedule_ret * fep_getschedule_32();
+extern  schedule_ret * fep_getschedule_32_svc();
+#define FEP_GETSCHEDULEVALUE 10
+extern  schedule_ret * fep_getschedulevalue_32();
+extern  schedule_ret * fep_getschedulevalue_32_svc();
+#define FEP_SENDSCHEDULE 11
+extern  schedule_ret * fep_sendschedule_32();
+extern  schedule_ret * fep_sendschedule_32_svc();
+#define FEP_SETLINEMGR_SCHEDULE 12
+extern  errorstatus * fep_setlinemgr_schedule_32();
+extern  errorstatus * fep_setlinemgr_schedule_32_svc();
+#define FEP_FREE_SCHEDULE 13
+extern  errorstatus * fep_free_schedule_32();
+extern  errorstatus * fep_free_schedule_32_svc();
+#define FEP_IDLELINE 14
+extern  errorstatus * fep_idleline_32();
+extern  errorstatus * fep_idleline_32_svc();
+#define FEP_MODEMSIGNALS 15
+extern  errorstatus * fep_modemsignals_32();
+extern  errorstatus * fep_modemsignals_32_svc();
+#define FEP_GETREPLY 16
+extern  reply_ret * fep_getreply_32();
+extern  reply_ret * fep_getreply_32_svc();
+#define FEP_CLEARREPLY 17
+extern  errorstatus * fep_clearreply_32();
+extern  errorstatus * fep_clearreply_32_svc();
+#define FEP_UPDATESCHEDULE 18
+extern  schedule_ret * fep_updateschedule_32();
+extern  schedule_ret * fep_updateschedule_32_svc();
+#define FEP_GETREPORTCOUNT 20
+extern  int * fep_getreportcount_32();
+extern  int * fep_getreportcount_32_svc();
+#define FEP_GETREPORT 21
+extern  report_ret * fep_getreport_32();
+extern  report_ret * fep_getreport_32_svc();
+#define FEP_GETREPORTVALUE 22
+extern  report_ret * fep_getreportvalue_32();
+extern  report_ret * fep_getreportvalue_32_svc();
+#define FEP_SENDREPORT 23
+extern  report_ret * fep_sendreport_32();
+extern  report_ret * fep_sendreport_32_svc();
+#define FEP_REPLY_XFER 30
+extern  void * fep_reply_xfer_32();
+extern  void * fep_reply_xfer_32_svc();
+#define FEP_SET_DEBUG 36
+extern  errorstatus * fep_set_debug_32();
+extern  errorstatus * fep_set_debug_32_svc();
+#define FEP_GET_STACK_LEFT 37
+extern  int * fep_get_stack_left_32();
+extern  int * fep_get_stack_left_32_svc();
+#define FEP_SETLMDEBUG 38
+extern  errorstatus * fep_setlmdebug_32();
+extern  errorstatus * fep_setlmdebug_32_svc();
+#define FEP_SHUTDOWN 39
+extern  errorstatus * fep_shutdown_32();
+extern  errorstatus * fep_shutdown_32_svc();
+#define FEP_INITSYSTEM 40
+extern  int * fep_initsystem_32();
+extern  int * fep_initsystem_32_svc();
+#define FEP_INITREALIX 41
+extern  int * fep_initrealix_32();
+extern  int * fep_initrealix_32_svc();
+extern int fep_program_32_freeresult ();
+#endif /* K&R C */
+
+/* the xdr functions */
+
+#if defined(__STDC__) || defined(__cplusplus)
+extern  bool_t xdr_errorstatus (XDR *, errorstatus*);
+extern  bool_t xdr_Polling_FSM_States (XDR *, Polling_FSM_States*);
+extern  bool_t xdr_fep_lineinfo (XDR *, fep_lineinfo*);
+extern  bool_t xdr_lineinfo_ret (XDR *, lineinfo_ret*);
+extern  bool_t xdr_fep_std_time (XDR *, fep_std_time*);
+extern  bool_t xdr_std_time_ret (XDR *, std_time_ret*);
+extern  bool_t xdr_protocoltype (XDR *, protocoltype*);
+extern  bool_t xdr_duplex (XDR *, duplex*);
+extern  bool_t xdr_fep_poll_info (XDR *, fep_poll_info*);
+extern  bool_t xdr_fep_poll_short_msg (XDR *, fep_poll_short_msg*);
+extern  bool_t xdr_fep_shortpoll (XDR *, fep_shortpoll*);
+extern  bool_t xdr_fep_shortpoll_list (XDR *, fep_shortpoll_list*);
+extern  bool_t xdr_fep_poll_long_msg (XDR *, fep_poll_long_msg*);
+extern  bool_t xdr_fep_longpoll (XDR *, fep_longpoll*);
+extern  bool_t xdr_fep_longpoll_list (XDR *, fep_longpoll_list*);
+extern  bool_t xdr_poll_length (XDR *, poll_length*);
+extern  bool_t xdr_fep_poll_list (XDR *, fep_poll_list*);
+extern  bool_t xdr_polltype (XDR *, polltype*);
+extern  bool_t xdr_commandtype (XDR *, commandtype*);
+extern  bool_t xdr_schedulestatus (XDR *, schedulestatus*);
+extern  bool_t xdr_fep_schedule (XDR *, fep_schedule*);
+extern  bool_t xdr_answererror (XDR *, answererror*);
+extern  bool_t xdr_fep_pollerror (XDR *, fep_pollerror*);
+extern  bool_t xdr_replystatus (XDR *, replystatus*);
+extern  bool_t xdr_fep_answer_info (XDR *, fep_answer_info*);
+extern  bool_t xdr_fep_answer_short_msg (XDR *, fep_answer_short_msg*);
+extern  bool_t xdr_fep_shortanswer (XDR *, fep_shortanswer*);
+extern  bool_t xdr_fep_shortanswer_list (XDR *, fep_shortanswer_list*);
+extern  bool_t xdr_fep_answer_long_msg (XDR *, fep_answer_long_msg*);
+extern  bool_t xdr_fep_longanswer (XDR *, fep_longanswer*);
+extern  bool_t xdr_fep_longanswer_list (XDR *, fep_longanswer_list*);
+extern  bool_t xdr_fep_answer_list (XDR *, fep_answer_list*);
+extern  bool_t xdr_replykind (XDR *, replykind*);
+extern  bool_t xdr_fep_reply (XDR *, fep_reply*);
+extern  bool_t xdr_schedule_ret (XDR *, schedule_ret*);
+extern  bool_t xdr_fep_reply_request (XDR *, fep_reply_request*);
+extern  bool_t xdr_reply_ret (XDR *, reply_ret*);
+extern  bool_t xdr_init_form (XDR *, init_form*);
+extern  bool_t xdr_fep_setschedule (XDR *, fep_setschedule*);
+extern  bool_t xdr_statusflags (XDR *, statusflags*);
+extern  bool_t xdr_fep_lineop (XDR *, fep_lineop*);
+extern  bool_t xdr_ipprotocol (XDR *, ipprotocol*);
+extern  bool_t xdr_action (XDR *, action*);
+extern  bool_t xdr_portstatus (XDR *, portstatus*);
+extern  bool_t xdr_fep_report (XDR *, fep_report*);
+extern  bool_t xdr_report_ret (XDR *, report_ret*);
+
+#else /* K&R C */
+extern bool_t xdr_errorstatus ();
+extern bool_t xdr_Polling_FSM_States ();
+extern bool_t xdr_fep_lineinfo ();
+extern bool_t xdr_lineinfo_ret ();
+extern bool_t xdr_fep_std_time ();
+extern bool_t xdr_std_time_ret ();
+extern bool_t xdr_protocoltype ();
+extern bool_t xdr_duplex ();
+extern bool_t xdr_fep_poll_info ();
+extern bool_t xdr_fep_poll_short_msg ();
+extern bool_t xdr_fep_shortpoll ();
+extern bool_t xdr_fep_shortpoll_list ();
+extern bool_t xdr_fep_poll_long_msg ();
+extern bool_t xdr_fep_longpoll ();
+extern bool_t xdr_fep_longpoll_list ();
+extern bool_t xdr_poll_length ();
+extern bool_t xdr_fep_poll_list ();
+extern bool_t xdr_polltype ();
+extern bool_t xdr_commandtype ();
+extern bool_t xdr_schedulestatus ();
+extern bool_t xdr_fep_schedule ();
+extern bool_t xdr_answererror ();
+extern bool_t xdr_fep_pollerror ();
+extern bool_t xdr_replystatus ();
+extern bool_t xdr_fep_answer_info ();
+extern bool_t xdr_fep_answer_short_msg ();
+extern bool_t xdr_fep_shortanswer ();
+extern bool_t xdr_fep_shortanswer_list ();
+extern bool_t xdr_fep_answer_long_msg ();
+extern bool_t xdr_fep_longanswer ();
+extern bool_t xdr_fep_longanswer_list ();
+extern bool_t xdr_fep_answer_list ();
+extern bool_t xdr_replykind ();
+extern bool_t xdr_fep_reply ();
+extern bool_t xdr_schedule_ret ();
+extern bool_t xdr_fep_reply_request ();
+extern bool_t xdr_reply_ret ();
+extern bool_t xdr_init_form ();
+extern bool_t xdr_fep_setschedule ();
+extern bool_t xdr_statusflags ();
+extern bool_t xdr_fep_lineop ();
+extern bool_t xdr_ipprotocol ();
+extern bool_t xdr_action ();
+extern bool_t xdr_portstatus ();
+extern bool_t xdr_fep_report ();
+extern bool_t xdr_report_ret ();
+
+#endif /* K&R C */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_FEP_H_RPCGEN */
Index: /branches/LinuxBasicFEPClient/network_factory.cpp
===================================================================
--- /branches/LinuxBasicFEPClient/network_factory.cpp	(revision 154)
+++ /branches/LinuxBasicFEPClient/network_factory.cpp	(revision 154)
@@ -0,0 +1,240 @@
+#include "network.h"
+#include <vector>
+#include <math.h>
+#include "network_factory.h"
+#include "DataPacker.h"
+
+// determine if a loop has data based on lane config data
+bool NetworkFactory::DataAvail(char flag, int num) {
+	int mag, fel;
+
+	// find mask value
+	if (num == 1)
+		mag = 0x01;
+	else if (num == 2)
+		mag = 0x02;
+	else if (num == 3)
+		mag = 0x04;
+	else if (num == 4)
+		mag = 0x08;
+	else if (num == 5)
+		mag = 0x10;
+	else if (num == 6)
+		mag = 0x20;
+	else if (num == 7)
+		mag = 0x40;
+	else if (num == 8)
+		mag = 0x80;
+	
+	fel = flag & mag;
+	fel = fel >> (num - 1);
+	
+	if (fel == 1)
+		return true;
+	else 
+		return false;
+}
+
+// Initializes the LOOP dataPack with all necessary static data and default dynamic data
+void NetworkFactory::init_loop_dataPack(STATION *loop)
+{
+	int j;
+	// Allocate memory for dataPack
+	loop->dataPack = (unsigned char *) calloc(sizeof(unsigned char), loop->length);
+
+	// dataPack 5-8: lane config
+	char d5 = 0, d6 = 0, d7 = 0, d8 = 0;		
+	for (j = 0; j < loop->loops.size(); j++)
+	{
+            char * currLoc = loop->loops[j]->loop_loc;
+		for (int k = 0; k < 8; k++)
+		{
+			if (strcmp(currLoc, dp5[k]) == 0)
+				d5 += pow(2, k);
+			if (strcmp(currLoc, dp6[k]) == 0)
+				d6 += pow(2, k);
+			if (strcmp(currLoc, dp7[k]) == 0)
+				d7 += pow(2, k);
+			if (strcmp(currLoc, dp8[k]) == 0)
+				d8 += pow(2, k);
+		}
+	}
+	loop->dataPack[5-1] = d5;
+	loop->dataPack[6-1] = d6;
+	loop->dataPack[7-1] = d7;
+	loop->dataPack[8-1] = d8;
+
+	// dataPack 1: Drop number, i.e. station address
+	loop->dataPack[1-1] = loop->drop;
+
+	// dataPack2 (2 bytes per loop)
+	loop->dataPack[2-1] = loop->loops.size() * 2 + Fixed_Byte_To_Checksum;
+
+	// dataPacket 3 (lowbyte: # of mainline loops, highbyte: # of opposite loops)
+	int low = 0, high = 0;
+	for (j = 1; j <= 6; j++)
+	{
+		low += DataAvail(loop->dataPack[5-1], j);
+		high += DataAvail(loop->dataPack[6-1], j);
+	}
+	high = high << 4;
+	loop->dataPack[3-1] = high | low;
+
+	// dataPack4 (Miscl. flags: samples are: 80, A0, E0, 00)
+	loop->dataPack[4-1] = 0xA0;
+
+	// dataPack 9: initialized as 00 (meaning no metering); need to be updated every 30 sec
+	loop->dataPack[9-1] = 0;
+
+	// datadataPack 10-13: lane malfunction? Assuming all functional
+	loop->dataPack[10-1] = 0;
+	loop->dataPack[11-1] = 0;
+	loop->dataPack[12-1] = 0;
+	loop->dataPack[13-1] = 0;
+
+	// dataPack 14-22: ramp metering data
+	// BYTE 16 and 22 need to be updated every 30 sec
+	bool found = false;
+	for (j = 0; j < loop->loops.size(); j++)
+	{
+		if (strcmp(loop->loops.at(0)->loop_loc, "DEMAND") == 0)
+		{
+			found = true;
+			break;
+		}
+	}
+	if (found)
+	{
+		// BYTE 14: mostly 07, some are 05, 03, 00
+		loop->dataPack[14-1] = 0x07;
+		// mostly 06(TOD table 1); some are 0B (No metering) or 05(traffic responsive)
+		loop->dataPack[15-1] = 0x06;
+		// most 00, some are 01 (queue override) or 80(Meter ON sign)
+		loop->dataPack[16-1] = 0x00;
+		// Field Manual Rate
+		loop->dataPack[17-1] = 0xFF;
+		// TOC Manual Rate
+		loop->dataPack[18-1] = 0xFF;
+		// PSO Manual Rate
+		loop->dataPack[19-1] = 0xFF;
+		// CORM Rate
+		loop->dataPack[20-1] = 0xFF;
+		// Local Responsive Rate. DON'T UNDERSTAND YET
+		loop->dataPack[21-1] = 0x00;
+		// TOD Rate: need to query RAMP plugin! 
+		loop->dataPack[22-1] = 0x00;
+	}
+	// LDS: NO Metering
+	else
+	{
+		loop->dataPack[14-1] = 0x00;
+		loop->dataPack[15-1] = 0x0B;
+		loop->dataPack[16-1] = 0x00;			
+		loop->dataPack[17-1] = 0xFF;
+		loop->dataPack[18-1] = 0xFF;
+		loop->dataPack[19-1] = 0xFF;
+		loop->dataPack[20-1] = 0xFF;
+		loop->dataPack[21-1] = 0x00;
+		loop->dataPack[22-1] = 0x00;
+	}
+
+	// dataPack 23-24: sum of mainline/Oppsite traffic data; need to be updated every 30 sec
+	loop->MlTotVol = 0;
+	loop->OppTotVol = 0;
+	loop->dataPack[23-1] = loop->MlTotVol;	
+	loop->dataPack[24-1] = loop->OppTotVol;	
+	
+	// dataPack 25-26: BYTE 25 is fixed, i.e. 03; BYTE 26 is either 0xA2 or 0x84
+	loop->dataPack[25-1] = 0x03;
+	loop->dataPack[26-1] = 0x84;
+
+	printf("lds=%d (%d), p1=%2X, p2=%2X, p3=%2X, p5=%2X, p6=%X, p7=%X, p8=%2X\n", 
+		loop->lds, loop->length, loop->dataPack[1-1], loop->dataPack[2-1], 
+		loop->dataPack[3-1], loop->dataPack[5-1], 
+		loop->dataPack[6-1], loop->dataPack[7-1], loop->dataPack[8-1]);
+}
+
+// TEST DATA
+// lds_id	line 	drop sch lineinfo	system_key	sch_seq glo_seq		count	freeway	Dir	ca_pm	lds_name		
+// 1203103	50	13	13	13	1123005873	24148	1357650		19	55	S	6.88	MACARTHU1 
+FEP_LINE * NetworkFactory::load_lines(int *size, const char * fName)
+{
+	FEP_LINE *lines = (FEP_LINE *) calloc(sizeof(FEP_LINE), 1);
+	*size = 1;
+	lines[0].lineNum = 50;
+	lines[0].lds.push_back(1203103);
+	lines[0].ldsIndex.push_back(0);
+	lines[0].count = 19;
+	lines[0].schedule = 13;
+	lines[0].globalSeq = 1357650;
+	lines[0].schedleSeq = 24148;
+	return lines;	
+}
+
+// TEST DATA
+//FWY	Dir     POSTMI	LDS_ID	VDS_ID	LOOP_ID LOC    LANE LOOP_LOC      	PARAMICS_NAME  PARAMICS_LANE    
+//55	S	6.88	1203103	1203104	1203105	QU	1	QUEUE      	55s6.88ora   	0
+
+//55	S	6.88	1203103	1203104	1203106	DM	2	DEMAND     	55s6.88ora   	0
+
+//55	S	6.88	1203103	1203104	1203107	PA	3	PASSAGE    	55s6.88ora   	0
+
+//55	S	6.88	1203103	1203108	1203109	HV	1	SD_1       	?            	0
+
+//55	S	6.88	1203103	1203110	1203111	ML	1	ML_1       	55s6.88ml    	4
+
+//55	S	6.88	1203103	1203110	1203112	ML	2	ML_2       	55s6.88ml    	3
+
+//55	S	6.88	1203103	1203110	1203113	ML	3	ML_3       	55s6.88ml    	2
+
+//55	S	6.88	1203103	1203110	1203114	ML	4	ML_4       	55s6.88ml    	1
+STATION * NetworkFactory::load_lds(const char * fName)
+{
+	/* Read loop meta data */
+	STATION *lds_map = (STATION *) calloc(sizeof(STATION), 1);
+	lds_map[0].lds = 1203103;
+	lds_map[0].line_num = 50;
+	lds_map[0].drop = 13;
+        LOOP *loop = new LOOP;
+        loop->loopID = 1203111;
+        loop->loop_loc = "ML_1";
+        
+        LOOP *looptwo = new LOOP;
+        looptwo->loopID = 1203112;
+        looptwo->loop_loc = "ML_2";
+        // occ 30
+        // vol 15 makes a speed of 20 RED
+        
+        // occ 30
+        // vol 20 makes a speed of 26 YELLOW
+        
+        // occ 30
+        // vol 30 makes a speed of 39 GREEN
+        loop->occ = 30;
+        loop->vol = 20;
+        
+        looptwo->occ = 30;
+        looptwo->vol = 15;
+        
+	// Loop ids
+	long *loopIDs = (long *) calloc(sizeof(long), lds_map[0].loops.size());
+	loopIDs[0] = 1203113;
+        loopIDs[1] = 1203112;
+        lds_map[0].loops.push_back(loop);
+        lds_map[0].loops.push_back(looptwo);
+        
+	// Init Loop dataPack
+	lds_map[0].length = lds_map[0].loops.size() * 2 + CONTROL_DATA_LEN;
+ 	// init_loop_dataPack(lds_map);
+
+	lds_map[0].pos = 0;
+
+	lds_map[0].MlTotVol = 0;
+	lds_map[0].OppTotVol = 0;
+        
+        DataPacker dp;
+        lds_map[0].dataPack = dp.packData(&lds_map[0]);
+        
+
+	return lds_map;
+}
